Skip to content

Commit 4bb8edd

Browse files
committed
fix point tests
1 parent 21ffc8d commit 4bb8edd

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

plotpy/plot/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,15 @@ def __del__(self):
434434
# This happens when object has already been deleted
435435
pass
436436

437-
def on_active_curve(self, x: float, y: float) -> None:
437+
def on_active_curve(self, x: float, y: float) -> tuple[float, float]:
438438
"""
439439
Callback called when the active curve is moved
440440
441441
Args:
442442
x (float): the x position
443443
y (float): the y position
444444
"""
445-
curve: CurveItem = self.get_last_active_item(itf.ITrackableItemType)
445+
curve: CurveItem = self.get_last_active_item(itf.ICurveItemType)
446446
if curve:
447447
x, y = curve.get_closest_coordinates(x, y)
448448
return x, y
@@ -542,7 +542,7 @@ def do_pan_view(
542542
self,
543543
dx: tuple[float, float, float, float],
544544
dy: tuple[float, float, float, float],
545-
replot: bool = True
545+
replot: bool = True,
546546
) -> None:
547547
"""
548548
Translate the active axes according to dx, dy axis 'state' tuples
@@ -1676,6 +1676,7 @@ def set_active_item(self, item: itf.IBasePlotItem) -> None:
16761676
self.active_item = item
16771677
if self.active_item is not None:
16781678
if not item.selected:
1679+
print(f"Selecting item {item}")
16791680
self.select_item(self.active_item)
16801681
self._active_xaxis = item.xAxis()
16811682
self._active_yaxis = item.yAxis()

plotpy/tests/unit/test_point_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ def test_edit_point_tool():
118118

119119
drag_mouse(win, qapp, x_path, y_path)
120120
curve_changes = tool.get_changes()[curve_item]
121+
122+
x_arr, y_arr = curve_item.get_data()
121123
for i, (x, y) in curve_changes.items():
122-
x_arr, y_arr = curve_item.get_data()
123124
assert x == x_arr[i]
124125
assert y == y_arr[i]
125126

plotpy/tests/unit/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,10 @@ def create_window(
147147
items: list[CurveItem | BaseImageItem] = make_curve_image_legend()
148148
win = ptv.show_items(items, wintitle="Unit test plot", auto_tools=False)
149149
plot = win.manager.get_plot()
150-
for item in win.manager.get_plot().get_items()[::-1]:
150+
for item in items:
151151
plot.set_active_item(item)
152152
last_active_item = plot.get_last_active_item(active_item_type)
153153
plot.set_active_item(last_active_item)
154-
155154
if panels is not None:
156155
for panel in panels:
157156
win.manager.add_panel(panel())

plotpy/tools/curve.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,10 +1028,10 @@ def stop(self, filter: StatefulEventFilter, event: QG.QMouseEvent) -> None:
10281028
if not (isinstance(self.__x, np.ndarray) and isinstance(self.__y, np.ndarray)):
10291029
return
10301030

1031-
backup_x_arr, backup_y_arr = self.__curve_item_array_backup[curve_item]
1032-
if self.__idx < backup_x_arr.size and (
1033-
self.__x[self.__idx] != backup_x_arr[self.__idx]
1034-
or self.__y[self.__idx] != backup_y_arr[self.__idx]
1031+
self.__x_bkp, self.__y_bkp = self.__curve_item_array_backup[curve_item]
1032+
if self.__idx < self.__x_bkp.size and (
1033+
self.__x[self.__idx] != self.__x_bkp[self.__idx]
1034+
or self.__y[self.__idx] != self.__y_bkp[self.__idx]
10351035
):
10361036
self.__indexed_changes.setdefault(curve_item, {})[self.__idx] = (
10371037
self.__x[self.__idx],

0 commit comments

Comments
 (0)