Use `._pathops.slice_from_time()` for overlay intersects

It's way faster since it uses a uniform time arithmetic to narrow the
`numpy.searchsorted()` range before actually doing the index search B)
multichartz_backup
Tyler Goodlet 2023-01-24 13:04:10 -05:00
parent 66c455a2e8
commit fc13743e9c
1 changed files with 11 additions and 8 deletions

View File

@ -43,6 +43,7 @@ from ..log import get_logger
from .._profile import Profiler from .._profile import Profiler
from .._profile import pg_profile_enabled, ms_slower_then from .._profile import pg_profile_enabled, ms_slower_then
from ..data.types import Struct from ..data.types import Struct
from ..data._pathops import slice_from_time
# from ._style import _min_points_to_show # from ._style import _min_points_to_show
from ._editors import SelectRect from ._editors import SelectRect
from . import _event from . import _event
@ -1230,20 +1231,22 @@ class ChartView(ViewBox):
# major has later timestamp adjust minor # major has later timestamp adjust minor
if tdiff > 0: if tdiff > 0:
y_minor_i = np.searchsorted( slc = slice_from_time(
minor_in_view['time'], arr=minor_in_view,
major_i_start_t, start_t=major_i_start_t,
stop_t=major_i_start_t,
) )
y_minor_intersect = minor_in_view[y_minor_i][key] y_minor_intersect = minor_in_view[slc.start][key]
profiler(f'{viz.name}@{chart_name} intersect by t') profiler(f'{viz.name}@{chart_name} intersect by t')
# minor has later timestamp adjust major # minor has later timestamp adjust major
elif tdiff < 0: elif tdiff < 0:
y_major_i = np.searchsorted( slc = slice_from_time(
major_in_view['time'], arr=major_in_view,
minor_i_start_t, start_t=minor_i_start_t,
stop_t=minor_i_start_t,
) )
y_major_intersect = major_in_view[y_major_i][key] y_major_intersect = major_in_view[slc.start][key]
profiler(f'{viz.name}@{chart_name} intersect by t') profiler(f'{viz.name}@{chart_name} intersect by t')