is_inside_bounds¶
-
odl.tomo.util.utility.
is_inside_bounds
(value, params)[source]¶ Return
True
ifvalue
is contained inparams
.This method supports broadcasting in the sense that for
params.ndim >= 2
, if more than one value is given, the inputs are broadcast against each other.- Parameters
- value
array-like
Value(s) to be checked. For several inputs, the final bool tells whether all inputs pass the check or not.
- params
IntervalProd
Set in which the value is / the values are supposed to lie.
- value
- Returns
- is_inside_boundsbool
True
is all values lie inparams
,False
otherwise.
Examples
Check a single point:
>>> params = odl.IntervalProd([0, 0], [1, 2]) >>> is_inside_bounds([0, 0], params) True >>> is_inside_bounds([0, -1], params) False
Using broadcasting:
>>> pts_ax0 = np.array([0, 0, 1, 0, 1])[:, None] >>> pts_ax1 = np.array([2, 0, 1])[None, :] >>> is_inside_bounds([pts_ax0, pts_ax1], params) True >>> pts_ax1 = np.array([-2, 1])[None, :] >>> is_inside_bounds([pts_ax0, pts_ax1], params) False