@@ -184,6 +184,9 @@ def get(self, indices: tuple[Any, ...]):
184184 Note that we do not use __getitem__ here since the index is a tuple specifying a single integer
185185 index for each dimension. Slices are not allowed, therefore __getitem__ is not suitable here.
186186 """
187+ # apply any slider index mappings
188+ indices = tuple ([m (i ) for m , i in zip (self .index_mappings , indices )])
189+
187190 if len (indices ) > 1 :
188191 # there are dims in addition to the n_datapoints dim
189192 # apply window funcs
@@ -195,7 +198,8 @@ def get(self, indices: tuple[Any, ...]):
195198 # TODO: window function on the `p` n_datapoints dimension
196199
197200 if self .display_window is not None :
198- dw = self .display_window
201+ # display window is interpreted using the index mapping for the `p` dim
202+ dw = self .index_mappings [- 1 ](self .display_window )
199203
200204 if dw == 1 :
201205 slices = [slice (indices [- 1 ], indices [- 1 ] + 1 )]
@@ -244,7 +248,7 @@ def get(self, indices: tuple[Any, ...]):
244248 apply_dims = self .datapoints_window_func [1 ]
245249 ws = self .datapoints_window_size
246250
247- # apply user's window func and return
251+ # apply user's window func
248252 # result will be of shape [n, p, 2 | 3]
249253 if apply_dims == "all" :
250254 # windows will be of shape [n, p, 1 | 2 | 3, ws]
@@ -260,11 +264,11 @@ def get(self, indices: tuple[Any, ...]):
260264 ).squeeze ()
261265
262266 # this reshape is required to reshape wf outputs of shape [n, p] -> [n, p, 1] only when necessary
263- graphic_data [..., : self . display_window , dims ] = wf (
267+ graphic_data [..., : dw , dims ] = wf (
264268 windows , axis = - 1
265- ).reshape (graphic_data .shape [0 ], self . display_window , len (dims ))
269+ ).reshape (graphic_data .shape [0 ], dw , len (dims ))
266270
267- return graphic_data [..., : self . display_window , :]
271+ return graphic_data [..., : dw , :]
268272
269273 return graphic_data
270274
@@ -285,6 +289,7 @@ def __init__(
285289 display_window : int = 10 ,
286290 window_funcs : tuple [WindowFuncCallable | None ] | None = None ,
287291 window_sizes : tuple [int | None ] | None = None ,
292+ index_mappings : tuple [Callable [[Any ], int ] | None ] | None = None ,
288293 ):
289294 if issubclass (graphic , LineCollection ):
290295 multi = True
@@ -295,6 +300,7 @@ def __init__(
295300 display_window = display_window ,
296301 window_funcs = window_funcs ,
297302 window_sizes = window_sizes ,
303+ index_mappings = index_mappings ,
298304 )
299305
300306 self ._indices = tuple ([0 ] * self ._processor .n_slider_dims )
0 commit comments