{ } Raw JSON

bundles / scipy latest / scipy / _lib / _util / _lazyselect

function

scipy._lib._util:_lazyselect

source: /scipy/_lib/_util.py :88

Signature

def   _lazyselect ( condlist choicelist arrays default = 0 )

Summary

Mimic np.select(condlist, choicelist).

Extended Summary

Notice, it assumes that all arrays are of the same shape or can be broadcasted together.

All functions in choicelist must accept array arguments in the order given in arrays and must return an array of the same shape as broadcasted arrays.

Examples

import numpy as np
x = np.arange(6)
np.select([x <3, x > 3], [x**2, x**3], default=0)
_lazyselect([x < 3, x > 3], [lambda x: x**2, lambda x: x**3], (x,))
a = -np.ones_like(x)
_lazyselect([x < 3, x > 3],
            [lambda x, a: x**2, lambda x, a: a * x**3],
            (x, a), default=np.nan)

Aliases

  • scipy.stats._continuous_distns._lazyselect