inRange¶
-
utilipy.data_utils.
inRange
(*args: Union[numpy.array, Sequence], rng: Union[Sequence, ellipsis] = Ellipsis, lbi: bool = True, ubi: bool = False, as_ind: bool = False) → numpy.array[source]¶ Multidimensional box selection.
- Parameters
- argsSequence
list of values along each dimension must be the same length can be same-shaped ND arrays, each treated as a series of rows.
- rngSequence or Ellipsis, optional
(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, optional
(default True) Lower Bound Inclusive, whether to be inclusive on the lower bound
- ubibool, optional
(default False) Upper Bound Inclusive, whether to be inclusive on the upper bound
- as_indbool, optional
(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.
- Raises
ValueError
if
as_ind
is “flatten” and cannot be flattened (len > 1)
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]])
Todo
allow lbi & rbi to be lists, matching args, for individual adjustment