Skip to content

Commit 6bec90f

Browse files
committed
Merge remote-tracking branch 'Codra/develop-2.1_tools-unit-tests' into develop
2 parents dd255dc + 4bb8edd commit 6bec90f

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
@@ -441,15 +441,15 @@ def __del__(self):
441441
# This happens when object has already been deleted
442442
pass
443443

444-
def on_active_curve(self, x: float, y: float) -> None:
444+
def on_active_curve(self, x: float, y: float) -> tuple[float, float]:
445445
"""
446446
Callback called when the active curve is moved
447447
448448
Args:
449449
x (float): the x position
450450
y (float): the y position
451451
"""
452-
curve: CurveItem = self.get_last_active_item(itf.ITrackableItemType)
452+
curve: CurveItem = self.get_last_active_item(itf.ICurveItemType)
453453
if curve:
454454
x, y = curve.get_closest_coordinates(x, y)
455455
return x, y
@@ -549,7 +549,7 @@ def do_pan_view(
549549
self,
550550
dx: tuple[float, float, float, float],
551551
dy: tuple[float, float, float, float],
552-
replot: bool = True
552+
replot: bool = True,
553553
) -> None:
554554
"""
555555
Translate the active axes according to dx, dy axis 'state' tuples
@@ -1683,6 +1683,7 @@ def set_active_item(self, item: itf.IBasePlotItem) -> None:
16831683
self.active_item = item
16841684
if self.active_item is not None:
16851685
if not item.selected:
1686+
print(f"Selecting item {item}")
16861687
self.select_item(self.active_item)
16871688
self._active_xaxis = item.xAxis()
16881689
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
@@ -145,11 +145,10 @@ def create_window(
145145
items: list[CurveItem | BaseImageItem] = make_curve_image_legend()
146146
win = ptv.show_items(items, wintitle="Unit test plot", auto_tools=False)
147147
plot = win.manager.get_plot()
148-
for item in win.manager.get_plot().get_items()[::-1]:
148+
for item in items:
149149
plot.set_active_item(item)
150150
last_active_item = plot.get_last_active_item(active_item_type)
151151
plot.set_active_item(last_active_item)
152-
153152
if panels is not None:
154153
for panel in panels:
155154
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)