|
8 | 8 |
|
9 | 9 | import numpy as np |
10 | 10 | from guidata.dataset import ChoiceItem, DataSet, FloatItem, IntItem |
| 11 | +from guidata.qthelpers import execenv |
11 | 12 | from guidata.widgets.arrayeditor import ArrayEditor |
12 | 13 | from qtpy import QtCore as QC |
13 | 14 | from qtpy import QtGui as QG |
@@ -846,18 +847,17 @@ def insert_point_at_selection( |
846 | 847 | param.index = self.__idx |
847 | 848 | param.value = self.__y[self.__idx - 1 : self.__idx + 1].mean() |
848 | 849 |
|
849 | | - if not param.edit(): |
850 | | - return |
| 850 | + if param.edit() or execenv.unattended: |
| 851 | + insertion_index: int = param.index + param.index_offset # type: ignore |
| 852 | + new_x: float = self.__x[insertion_index - 1 : insertion_index + 1].mean() |
| 853 | + self.__x = np.insert(self.__x, insertion_index, new_x) # type: ignore |
| 854 | + self.__y = np.insert(self.__y, insertion_index, param.value) # type: ignore |
| 855 | + curve_item.set_data(self.__x, self.__y) |
| 856 | + new_pos = axes_to_canvas(curve_item, new_x, param.value) # type: ignore |
| 857 | + self.__current_location_marker.move_local_point_to( |
| 858 | + 0, QC.QPointF(*new_pos) # type: ignore |
| 859 | + ) |
851 | 860 |
|
852 | | - insertion_index: int = param.index + param.index_offset # type: ignore |
853 | | - new_x: float = self.__x[insertion_index - 1 : insertion_index + 1].mean() |
854 | | - self.__x = np.insert(self.__x, insertion_index, new_x) # type: ignore |
855 | | - self.__y = np.insert(self.__y, insertion_index, param.value) # type: ignore |
856 | | - curve_item.set_data(self.__x, self.__y) |
857 | | - new_pos = axes_to_canvas(curve_item, new_x, param.value) # type: ignore |
858 | | - self.__current_location_marker.move_local_point_to( |
859 | | - 0, QC.QPointF(*new_pos) # type: ignore |
860 | | - ) |
861 | 861 |
|
862 | 862 | def __get_plot(self, filter: StatefulEventFilter) -> BasePlot: |
863 | 863 | """Get plot. Simple method to avoid type checking errors |
|
0 commit comments