From 1e037af007c70da4038a1bfbb306d951b4b66fb9 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 2 Sep 2024 17:29:30 -0400 Subject: [PATCH 1/3] LinearSelectionFeature uses np.float32 for selection type --- fastplotlib/graphics/_features/_selection_features.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastplotlib/graphics/_features/_selection_features.py b/fastplotlib/graphics/_features/_selection_features.py index e499e72c9..c385f820f 100644 --- a/fastplotlib/graphics/_features/_selection_features.py +++ b/fastplotlib/graphics/_features/_selection_features.py @@ -48,7 +48,7 @@ def __init__(self, axis: str, value: float, limits: tuple[float, float]): self._value = value @property - def value(self) -> float: + def value(self) -> np.float32: """ selection, data x or y value """ @@ -56,7 +56,7 @@ def value(self) -> float: def set_value(self, selector, value: float): # clip value between limits - value = np.clip(value, self._limits[0], self._limits[1]) + value = np.clip(value, self._limits[0], self._limits[1], dtype=np.float32) # set position if self._axis == "x": From a5c3516f76cc14a4dd14a12e7bb69303d88e3d1f Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 2 Sep 2024 17:32:14 -0400 Subject: [PATCH 2/3] move_to_pointer which works for both linear and linear region selectors --- fastplotlib/graphics/selectors/_base_selector.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fastplotlib/graphics/selectors/_base_selector.py b/fastplotlib/graphics/selectors/_base_selector.py index 3729adda5..30643bbe4 100644 --- a/fastplotlib/graphics/selectors/_base_selector.py +++ b/fastplotlib/graphics/selectors/_base_selector.py @@ -280,7 +280,16 @@ def _move_to_pointer(self, ev): elif self.axis == "y": offset = self.offset[1] - current_pos_world: np.ndarray = self.selection + offset + if self.selection.size > 1: + # linear region selectors + # TODO: get center for rectangle and polygon selectors + center = self.selection.mean(axis=0) + + else: + # linear selectors + center = self.selection + + current_pos_world: np.ndarray = center + offset world_pos = self._plot_area.map_screen_to_world(ev) From 7841693737c874ef4cbb0036dea4c142472ec7c2 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 2 Sep 2024 17:32:43 -0400 Subject: [PATCH 3/3] skip move_to_pointer for rectangle selector for now --- fastplotlib/graphics/selectors/_rectangle.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fastplotlib/graphics/selectors/_rectangle.py b/fastplotlib/graphics/selectors/_rectangle.py index aae99803e..38bb0d2f9 100644 --- a/fastplotlib/graphics/selectors/_rectangle.py +++ b/fastplotlib/graphics/selectors/_rectangle.py @@ -515,3 +515,6 @@ def _move_graphic(self, delta: np.ndarray): self._selection.set_value(self, (xmin, xmax, ymin_new, ymax)) if self._move_info.source == self.edges[3]: self._selection.set_value(self, (xmin, xmax, ymin, ymax_new)) + + def _move_to_pointer(self, ev): + pass pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy