inRange

utilipy.data_utils.inRange(*args: Union[numpy.array, Sequence], rng: Union[list, ellipsis] = Ellipsis, lbi: bool = True, ubi: bool = False, as_ind: bool = False) numpy.array[source]

Multidimensional box selection.

Parameters
argslist

list of values along each dimension must be the same length can be same-shaped ND arrays, each treated as a series of rows.

rnglist

(default Ellipsis) the domain for each argument in args:

args = [[x1], [x2], ...]
rng =   [1st [lower, upper],
         2nd [lower, upper],
         ...]

if each ‘xn’ is multidimensional

lbibool

(default True) Lower Bound Inclusive, whether to be inclusive on the lower bound

ubibool

(default False) Upper Bound Inclusive, whether to be inclusive on the upper bound

as_indbool (default False)

whether to return bool array or the indices (where(bool array == True)) sets the default behavior for the wrapped fnction func

Returns
inrangebool ndarray

boolean array to select values in box selection

Other Parameters
as_indbool or “flatten”, optional

(default False) whether to return a boolean array, or array of indices.

See also

outRange

multidimensional box exclusion

ioRange

inRange and outRange combined

Examples

list of args:

>>> x = np.arange(5)
>>> y = np.arange(5) + 10
>>> inRange(x, y, rng=[[0, 3], [10, 15]]) 
array([ True,  True,  True, False, False])

multidimensional arg:

>>> x = np.array([[ 0,  1], [10, 11]])
>>> rng = [[0, 3], [9, 11]]
>>> inRange(x, rng=rng) 
array([[ True,  True],
       [ True, False]])