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
Tyler Goodlet 2023-03-07 14:36:19 -05:00
parent 51f3733487
commit 712f1a47a0
1 changed files with 2 additions and 8 deletions

View File

@ -295,7 +295,7 @@ def slice_from_time(
arr: np.ndarray,
start_t: float,
stop_t: float,
step: int | None = None,
step: float, # sampler period step-diff
) -> slice:
'''
@ -324,12 +324,6 @@ def slice_from_time(
# end of the input array.
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
i_start_t = floor(start_t)
read_i_start = floor(((i_start_t - t_first) // step)) - 1
@ -412,7 +406,7 @@ def slice_from_time(
times[read_i_start:],
# times,
i_stop_t,
side='left',
side='right',
)
if (