Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a363713

Browse filesBrowse files
authored
Selector fixes (#304)
* bugfix for axis=y, use round() instead of int() in get_selected_index(), more accurate * add _pygfx_event = None to BaseSelector init * fix type annotation for Synchronizer
1 parent 2b97c9d commit a363713
Copy full SHA for a363713

File tree

Expand file treeCollapse file tree

3 files changed

+9
-7
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+9
-7
lines changed

‎fastplotlib/graphics/selectors/_base_selector.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_base_selector.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def __init__(
8787
# otherwise annoying and requires too much accuracy to move just an edge
8888
self._edge_hovered: bool = False
8989

90+
self._pygfx_event = None
91+
9092
def get_selected_index(self):
9193
"""Not implemented for this selector"""
9294
raise NotImplementedError

‎fastplotlib/graphics/selectors/_linear.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_linear.py
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def __init__(
107107

108108
line_data = np.column_stack([xs, ys, zs])
109109
elif axis == "y":
110-
xs = np.zeros(end_points)
111-
ys = np.array(2)
110+
xs = np.array(end_points)
111+
ys = np.zeros(2)
112112
zs = np.zeros(2)
113113

114114
line_data = np.column_stack([xs, ys, zs])
@@ -158,7 +158,6 @@ def __init__(
158158
)
159159

160160
self._move_info: dict = None
161-
self._pygfx_event = None
162161

163162
self.parent = parent
164163

@@ -349,17 +348,17 @@ def _get_selected_index(self, graphic):
349348
or math.fabs(find_value - geo_positions[idx - 1])
350349
< math.fabs(find_value - geo_positions[idx])
351350
):
352-
return int(idx - 1)
351+
return round(idx - 1)
353352
else:
354-
return int(idx)
353+
return round(idx)
355354

356355
if (
357356
"Heatmap" in graphic.__class__.__name__
358357
or "Image" in graphic.__class__.__name__
359358
):
360359
# indices map directly to grid geometry for image data buffer
361360
index = self.selection() - offset
362-
return int(index)
361+
return round(index)
363362

364363
def _move_graphic(self, delta: np.ndarray):
365364
"""

‎fastplotlib/graphics/selectors/_sync.py

Copy file name to clipboardExpand all lines: fastplotlib/graphics/selectors/_sync.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from . import LinearSelector
2+
from typing import *
23

34

45
class Synchronizer:
5-
def __init__(self, *selectors: LinearSelector, key_bind: str = "Shift"):
6+
def __init__(self, *selectors: LinearSelector, key_bind: Union[str, None] = "Shift"):
67
"""
78
Synchronize the movement of `Selectors`. Selectors will move in sync only when the selected `"key_bind"` is
89
used during the mouse movement event. Valid key binds are: ``"Control"``, ``"Shift"`` and ``"Alt"``.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.