Selection vector improve#1061
Conversation
|
|
||
| @selection.setter | ||
| def selection(self, value: Iterable[int] | dict[Literal["rows", "cols", "pixels"], list]) -> None: | ||
| def selection(self, value: Iterable[int] | dict[Literal["rows", "cols", "pixels"], list] | None) -> None: |
There was a problem hiding this comment.
value can also be Iterable[int | None]
| import numpy as np | ||
| from ._protocols import SelectorProtocol, MultiSelectorProtocol | ||
|
|
||
| from fastplotlib.graphics.features._base import GraphicFeatureEvent |
There was a problem hiding this comment.
deleting for now because SelectionVector just works with VisibilitySelector + HighlightSelector (+ subclasses)
| # selector -> (map, map_inv) | ||
| self._selectors: dict[ | ||
| SelectorProtocol | MultiSelectorProtocol, tuple[Callable, Callable] | ||
| SelectorProtocol | MultiSelectorProtocol, tuple[Callable, Callable, list] |
There was a problem hiding this comment.
list[Callable] for the handlers
There was a problem hiding this comment.
code comment above when type signature is large
| self._block_reentrance = True | ||
| if isinstance(new, Integral): | ||
| new = [new] | ||
| self._selection = [i for i in new] |
There was a problem hiding this comment.
this doesn't do anything, can just be self._selection = new
There was a problem hiding this comment.
@kushalkolar thought about this -- this does something. if the input is any iterable other than a list, it makes the input a list.
| self._selection = [i for i in new] | ||
| # iterate through each selector that operates in its own "local" space | ||
| for selector_local, (map_, map_inv, handler) in self._selectors.items(): | ||
| cumulated_output = [] |
| for value in new: | ||
| curr_indices = map_(value) | ||
| cumulated_output.append(curr_indices) | ||
| # indices_local = map_(new) |
| if not isinstance(selector, MultiSelectorProtocol): | ||
| continue | ||
|
|
||
| index_local = map_([index]) |
There was a problem hiding this comment.
this should be a scalar now and not a vector
| ), | ||
| ): | ||
| """ | ||
| User specifies (1) the selector and (2) The master --> local index mapping. This |
There was a problem hiding this comment.
they can also specify a mapping Callable directly
…adds partial instead of lambda functions, improves typing in highlight selector
Addresses #1047.
Concrete changes: