r""" Return the slice selecting entries of an ordered array within a window. Parameters ---------- x_array : array_like 1D sequence of monotonically non-decreasing values. Any iterable that yields values in order is accepted. x_min : float Lower bound of
(x_array, x_min, x_max)
| 60 | """ |
| 61 | |
| 62 | def clip_array(x_array, x_min, x_max): |
| 63 | r""" |
| 64 | Return the slice selecting entries of an ordered array within a window. |
| 65 | |
| 66 | Parameters |
| 67 | ---------- |
| 68 | x_array : array_like |
| 69 | 1D sequence of monotonically non-decreasing values. Any |
| 70 | iterable that yields values in order is accepted. |
| 71 | x_min : float |
| 72 | Lower bound of the window (inclusive). |
| 73 | x_max : float |
| 74 | Upper bound of the window (inclusive). |
| 75 | |
| 76 | Returns |
| 77 | ------- |
| 78 | slice |
| 79 | Slice ``sl`` such that every element of ``x_array[sl]`` lies in |
| 80 | ``[x_min, x_max]``. Returns ``slice(0, 0)`` when no element |
| 81 | satisfies ``x >= x_min``. |
| 82 | |
| 83 | Raises |
| 84 | ------ |
| 85 | AssertionError |
| 86 | If ``x_max < x_min``. |
| 87 | """ |
| 88 | assert x_max >= x_min, "Windowing error" |
| 89 | |
| 90 | try: |
| 91 | low = next((i for i, x in enumerate(x_array) if not(x < x_min))) |
| 92 | except StopIteration: |
| 93 | return slice(0, 0) # there is no x >= x_min |
| 94 | |
| 95 | try: |
| 96 | high = next((i for i, x in enumerate(x_array) if x > x_max)) |
| 97 | r = slice(low, high) |
| 98 | except StopIteration: |
| 99 | r = slice(low, len(x_array)) # there is no x > x_max |
| 100 | |
| 101 | return r |
| 102 | |
| 103 | |
| 104 | def plot_protocol_apply(ob, opt_dict, xlims): |
no outgoing calls
no test coverage detected