Drop edge case from `slice_from_time()`
Doesn't seem like we really need to handle the situation where the start or stop input time stamps are outside the index range of the data since the new binary search handling via `numpy.searchsorted()` covers this case at minimal runtime cost and with an equally correct output. Allows us to drop some other indexing endpoint internal variables as well.epoch_indexing_and_dataviz_layer
parent
a7d78a3f40
commit
fc17187ff4
|
@ -309,25 +309,9 @@ def slice_from_time(
|
||||||
|
|
||||||
times = arr['time']
|
times = arr['time']
|
||||||
t_first = round(times[0])
|
t_first = round(times[0])
|
||||||
t_last = round(times[-1])
|
|
||||||
|
|
||||||
index = arr['index']
|
|
||||||
i_first = index[0]
|
|
||||||
# i_last = index[-1]
|
|
||||||
read_i_max = arr.shape[0]
|
read_i_max = arr.shape[0]
|
||||||
|
|
||||||
if (
|
|
||||||
start_t < t_first
|
|
||||||
and stop_t > t_last
|
|
||||||
):
|
|
||||||
read_i_start = 0
|
|
||||||
read_i_stop = read_i_max
|
|
||||||
read_slc = slice(
|
|
||||||
0,
|
|
||||||
read_i_max,
|
|
||||||
)
|
|
||||||
return read_slc
|
|
||||||
|
|
||||||
if step is None:
|
if step is None:
|
||||||
step = round(times[-1] - times[-2])
|
step = round(times[-1] - times[-2])
|
||||||
if step == 0:
|
if step == 0:
|
||||||
|
@ -359,11 +343,9 @@ def slice_from_time(
|
||||||
# NOTE: this is usually the result of a time series with time gaps
|
# NOTE: this is usually the result of a time series with time gaps
|
||||||
# where it is expected that each index step maps to a uniform step
|
# where it is expected that each index step maps to a uniform step
|
||||||
# in the time stamp series.
|
# in the time stamp series.
|
||||||
i_iv_start = index[read_i_start]
|
|
||||||
t_iv_start = times[read_i_start]
|
t_iv_start = times[read_i_start]
|
||||||
if (
|
if (
|
||||||
i_iv_start >= i_first
|
t_iv_start > i_start_t
|
||||||
and t_iv_start > i_start_t
|
|
||||||
):
|
):
|
||||||
# do a binary search for the best index mapping to ``start_t``
|
# do a binary search for the best index mapping to ``start_t``
|
||||||
# given we measured an overshoot using the uniform-time-step
|
# given we measured an overshoot using the uniform-time-step
|
||||||
|
@ -396,7 +378,6 @@ def slice_from_time(
|
||||||
# )
|
# )
|
||||||
read_i_start = new_read_i_start - 1
|
read_i_start = new_read_i_start - 1
|
||||||
|
|
||||||
# i_iv_stop = index[read_i_stop - 1]
|
|
||||||
t_iv_stop = times[read_i_stop - 1]
|
t_iv_stop = times[read_i_stop - 1]
|
||||||
if (
|
if (
|
||||||
t_iv_stop > i_stop_t
|
t_iv_stop > i_stop_t
|
||||||
|
@ -441,6 +422,7 @@ def slice_from_time(
|
||||||
|
|
||||||
# NOTE: if caller needs absolute buffer indices they can
|
# NOTE: if caller needs absolute buffer indices they can
|
||||||
# slice the buffer abs index like so:
|
# slice the buffer abs index like so:
|
||||||
|
# index = arr['index']
|
||||||
# abs_indx = index[read_slc]
|
# abs_indx = index[read_slc]
|
||||||
# abs_slc = slice(
|
# abs_slc = slice(
|
||||||
# int(abs_indx[0]),
|
# int(abs_indx[0]),
|
||||||
|
|
Loading…
Reference in New Issue