Require `step: float` input to `slice_from_time()`
There's been way too many issues when trying to calculate this dynamically from the input array, so just expect the caller to know what it's doing and don't bother with ever hitting the error case of calculating and incorrect value internally.log_linearized_curve_overlays
parent
51f3733487
commit
712f1a47a0
|
@ -295,7 +295,7 @@ def slice_from_time(
|
||||||
arr: np.ndarray,
|
arr: np.ndarray,
|
||||||
start_t: float,
|
start_t: float,
|
||||||
stop_t: float,
|
stop_t: float,
|
||||||
step: int | None = None,
|
step: float, # sampler period step-diff
|
||||||
|
|
||||||
) -> slice:
|
) -> slice:
|
||||||
'''
|
'''
|
||||||
|
@ -324,12 +324,6 @@ def slice_from_time(
|
||||||
# end of the input array.
|
# end of the input array.
|
||||||
read_i_max = arr.shape[0]
|
read_i_max = arr.shape[0]
|
||||||
|
|
||||||
# TODO: require this is always passed in?
|
|
||||||
if step is None:
|
|
||||||
step = round(t_last - times[-2])
|
|
||||||
if step == 0:
|
|
||||||
step = 1
|
|
||||||
|
|
||||||
# compute (presumed) uniform-time-step index offsets
|
# compute (presumed) uniform-time-step index offsets
|
||||||
i_start_t = floor(start_t)
|
i_start_t = floor(start_t)
|
||||||
read_i_start = floor(((i_start_t - t_first) // step)) - 1
|
read_i_start = floor(((i_start_t - t_first) // step)) - 1
|
||||||
|
@ -412,7 +406,7 @@ def slice_from_time(
|
||||||
times[read_i_start:],
|
times[read_i_start:],
|
||||||
# times,
|
# times,
|
||||||
i_stop_t,
|
i_stop_t,
|
||||||
side='left',
|
side='right',
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in New Issue