Skip to content

Commit 16080b1

Browse files
committed
small fix of index out of range
1 parent 8c3ab84 commit 16080b1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

plotpy/tools/curve.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,6 @@ def insert_point_at_selection(
858858
0, QC.QPointF(*new_pos) # type: ignore
859859
)
860860

861-
862861
def __get_plot(self, filter: StatefulEventFilter) -> BasePlot:
863862
"""Get plot. Simple method to avoid type checking errors
864863
@@ -953,7 +952,10 @@ def start(self, filter: StatefulEventFilter, event: QG.QMouseEvent) -> None:
953952
self.__current_location_marker = self.__get_current_marker(filter)
954953
self.__current_location_marker.move_local_point_to(0, event.pos())
955954
x_value = self.__current_location_marker.xValue()
956-
self.__dsampled_idx = int(np.searchsorted(self.downsampled_x, x_value))
955+
self.__dsampled_idx = min(
956+
int(np.searchsorted(self.downsampled_x, x_value)),
957+
len(self.downsampled_x) - 1,
958+
)
957959
self.__idx = self.__dsampled_idx * self.__dsampling # type: ignore
958960
self.__lower_upper_x_bounds = self.__get_x_bounds(curve_x, self.__idx)
959961
self.__selection_threshold = self.__get_selection_threshold(filter)

0 commit comments

Comments
 (0)