Skip to content

Commit 605162d

Browse files
committed
Fix "New custom signal" feature following Sigima signal creation API changes
1 parent 2e7e811 commit 605162d

8 files changed

Lines changed: 30 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ NumPy 2.0 support has been added with this release.
531531

532532
| Menu | Submenu |Features |
533533
|-------------|--------------|---------------------------------------------------------|
534-
| New | New signal | Exponential, pulse, polynomial, experimental (manual input) |
534+
| New | New signal | Exponential, pulse, polynomial, custom (manual input) |
535535
| Operations | | Exponential, Square root, Power |
536536
| Operations | Operations with a constant | +, -, *, / |
537537
| Processing | Axis Transformation | Reverse X-axis |

datalab/gui/actionhandler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from qtpy import QtWidgets as QW
4848

4949
from datalab.config import Conf, _
50+
from datalab.gui import newobject
5051
from datalab.widgets import fitdialog
5152

5253
if TYPE_CHECKING:
@@ -778,7 +779,7 @@ def create_new_object_actions(self):
778779
(_("Exponential"), sio.ExponentialParam),
779780
(_("Pulse"), sio.PulseParam),
780781
(_("Polynomial"), sio.PolyParam),
781-
(_("Custom"), sio.ExperimentalSignalParam),
782+
(_("Custom"), newobject.CustomSignalParam),
782783
):
783784
self.new_action(
784785
label,

datalab/gui/newobject.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from plotpy.plot import PlotDialog
2222
from plotpy.tools import EditPointTool
2323
from qtpy import QtWidgets as QW
24-
from sigima.objects import ExperimentalSignalParam as OrigExperimentalSignalParam
24+
from sigima.objects import CustomSignalParam as OrigCustomSignalParam
2525
from sigima.objects import (
2626
Gauss2DParam,
2727
ImageDatatypes,
@@ -40,18 +40,18 @@
4040
from datalab.config import _
4141

4242

43-
class ExperimentalSignalParam(OrigExperimentalSignalParam):
44-
"""Parameters for experimental signal"""
43+
class CustomSignalParam(OrigCustomSignalParam):
44+
"""Parameters for custom signal (e.g. manually defined experimental data)"""
4545

4646
def edit_curve(self, *args) -> None: # pylint: disable=unused-argument
47-
"""Edit experimental curve"""
47+
"""Edit custom curve"""
4848
win: PlotDialog = make.dialog(
4949
wintitle=_("Select one point then press OK to accept"),
5050
edit=True,
5151
type="curve",
5252
)
5353
edit_tool = win.manager.add_tool(
54-
EditPointTool, title=_("Edit experimental curve")
54+
EditPointTool, title=_("Edit curve interactively")
5555
)
5656
edit_tool.activate()
5757
plot = win.manager.get_plot()
@@ -95,24 +95,27 @@ def create_signal_gui(
9595
Raises:
9696
ValueError: if base_param is None and edit is False
9797
"""
98-
if isinstance(param, ExperimentalSignalParam):
99-
param.setup_array(size=param.size, xmin=param.xmin, xmax=param.xmax)
100-
if edit and not param.edit(parent=parent):
101-
return None
102-
signal = create_signal(param.title)
103-
signal.xydata = param.xyarray.T
104-
if signal.title == SIGNAL_DEFAULT_TITLE:
105-
signal.title = f"experimental(npts={param.size})"
106-
return signal
107-
10898
if param is None:
10999
param = NewSignalParam()
110100
edit = True # Default to editing if no parameters provided
111101

102+
if isinstance(param, OrigCustomSignalParam) and edit:
103+
p_init = NewSignalParam(_("Custom signal"))
104+
if not p_init.edit(parent=parent):
105+
return None
106+
param.setup_array(size=p_init.size, xmin=p_init.xmin, xmax=p_init.xmax)
107+
112108
if edit:
113109
if not param.edit(parent=parent):
114110
return None
115111

112+
if isinstance(param, OrigCustomSignalParam):
113+
signal = create_signal(param.title)
114+
signal.xydata = param.xyarray.T
115+
if signal.title == SIGNAL_DEFAULT_TITLE:
116+
signal.title = f"custom(npts={param.size})"
117+
return signal
118+
116119
try:
117120
signal = create_signal_headless(param)
118121
except Exception as exc: # pylint: disable=broad-except

datalab/locale/fr/LC_MESSAGES/datalab.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ msgstr "Souhaitez-vous enregistrer tous les signaux et images dans un fichier HD
723723
msgid "Select one point then press OK to accept"
724724
msgstr "Sélectionnez un point puis appuyez sur OK pour valider"
725725

726-
msgid "Edit experimental curve"
727-
msgstr "Editer la courbe expérimentale"
726+
msgid "Edit curve interactively"
727+
msgstr "Modifier la courbe graphiquement"
728728

729729
msgid "Insert point"
730730
msgstr "Insérer un point"

doc/features/signal/menu_file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Create a new signal from various models:
6363
- :math:`y = y_{0}+A.\left\{\begin{array}{ll}1 & \text{if } x_{0} < x < x_{1} \\ 0 & \text{otherwise}\end{array}\right.`
6464
* - Polynomial
6565
- :math:`y = y_{0}+A_{0}+A_{1}.x+A_{2}.x^2+...+A_{n}.x^n`
66-
* - Experimental
66+
* - Custom
6767
- Manual input of X and Y values
6868

6969
.. _open_signal:

doc/locale/fr/LC_MESSAGES/api/objects.po

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,10 +941,10 @@ msgstr ""
941941
msgid "XY Values\\. Default: None."
942942
msgstr ""
943943

944-
msgid "Returns a new instance of :py:class:`ExperimentalSignalParam` with the fields set to the given values."
944+
msgid "Returns a new instance of :py:class:`CustomSignalParam` with the fields set to the given values."
945945
msgstr ""
946946

947-
msgid "New instance of :py:class:`ExperimentalSignalParam`."
947+
msgid "New instance of :py:class:`CustomSignalParam`."
948948
msgstr ""
949949

950950
msgid "Setup the xyarray from size, xmin and xmax (use the current values is not provided)"
@@ -1318,4 +1318,3 @@ msgstr ""
13181318

13191319
msgid "Float number stored with 64 bits"
13201320
msgstr ""
1321-

doc/locale/fr/LC_MESSAGES/contributing/changelog.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,8 @@ msgstr "Nouveau"
12051205
msgid "New signal"
12061206
msgstr "Nouveau signal"
12071207

1208-
msgid "Exponential, pulse, polynomial, experimental (manual input)"
1209-
msgstr "Exponentielle, impulsion, polynomiale, expérimentale (entrée manuelle)"
1208+
msgid "Exponential, pulse, polynomial, custom (manual input)"
1209+
msgstr "Exponentielle, impulsion, polynomiale, personnalisé (entrée manuelle)"
12101210

12111211
msgid "Operations"
12121212
msgstr "Opérations"

doc/locale/fr/LC_MESSAGES/features/signal/menu_file.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ msgstr "Polynomial"
160160
msgid ":math:`y = y_{0}+A_{0}+A_{1}.x+A_{2}.x^2+...+A_{n}.x^n`"
161161
msgstr ""
162162

163-
msgid "Experimental"
164-
msgstr "Expérimental"
163+
msgid "Custom"
164+
msgstr "Personnalisé"
165165

166166
msgid "Manual input of X and Y values"
167167
msgstr "Saisie manuelle des valeurs X et Y"

0 commit comments

Comments
 (0)