Returns True if all elements of x are inside x_range, inclusive of the edge values. Parameters ---------- x : array-like A numpy array of values. x_range : tuple of float A tuple defining a range like (xmin, xmax)
(x, x_range)
| 366 | |
| 367 | |
| 368 | def allinrange(x, x_range): |
| 369 | """ Returns True if all elements of x are inside x_range, inclusive of the |
| 370 | edge values. |
| 371 | |
| 372 | Parameters |
| 373 | ---------- |
| 374 | x : array-like |
| 375 | A numpy array of values. |
| 376 | x_range : tuple of float |
| 377 | A tuple defining a range like (xmin, xmax) |
| 378 | """ |
| 379 | if isinstance(x, (int, float, np.float, np.int)): |
| 380 | x = np.array([x]) |
| 381 | return np.where(np.logical_or(x < x_range[0], x > x_range[1]))[0].size == 0 |
| 382 | |
| 383 | |
| 384 | # Vector helpers |