Skip to content

Commit 6da3a6b

Browse files
committed
Add test signal/image loading functions in PluginTestData
1 parent 50d57a9 commit 6da3a6b

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

datalab/locale/fr/LC_MESSAGES/datalab.po

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: datalab\n"
88
"Report-Msgid-Bugs-To: p.raybaut@codra.fr\n"
9-
"POT-Creation-Date: 2025-10-15 18:23+0200\n"
9+
"POT-Creation-Date: 2025-10-15 18:34+0200\n"
1010
"PO-Revision-Date: 2025-05-22 15:46+0200\n"
1111
"Last-Translator: Christophe Debonnel <c.debonnel@codra.fr>\n"
1212
"Language: fr\n"
@@ -2234,6 +2234,9 @@ msgstr "Grille d'images gaussiennes"
22342234
msgid "Load spectrum of paracetamol"
22352235
msgstr "Charger le spectre du paracétamol"
22362236

2237+
msgid "Load all test signals"
2238+
msgstr "Charger tous les signaux de test"
2239+
22372240
msgid "Create image with peaks"
22382241
msgstr "Créer une image avec des pics"
22392242

@@ -2258,6 +2261,9 @@ msgstr "Créer une image avec un anneau"
22582261
msgid "Create image with a grid of gaussian spots"
22592262
msgstr "Créer une image avec une grille de spots gaussiens"
22602263

2264+
msgid "Load all test images"
2265+
msgstr "Charger toutes les images de test"
2266+
22612267
msgid "Host application"
22622268
msgstr "Application hôte"
22632269

datalab/plugins/datalab_testdata.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88
and some actions to test DataLab functionalities.
99
"""
1010

11+
from __future__ import annotations
12+
1113
import sigima.tests.data as test_data
14+
from sigima.io.image import ImageIORegistry
15+
from sigima.io.signal import SignalIORegistry
16+
from sigima.tests import helpers
1217

1318
from datalab.config import _
1419
from datalab.plugins import PluginBase, PluginInfo
20+
from datalab.utils.qthelpers import create_progress_bar
1521

1622
# ------------------------------------------------------------------------------
1723
# All computation functions must be defined as global functions, otherwise
@@ -28,6 +34,27 @@ class PluginTestData(PluginBase):
2834
description=_("Testing DataLab functionalities"),
2935
)
3036

37+
def load_test_objs(
38+
self, registry_class: type[SignalIORegistry | ImageIORegistry], title: str
39+
) -> None:
40+
"""Load all test objects from a given registry class
41+
42+
Args:
43+
registry_class: Registry class (SignalIORegistry or ImageIORegistry)
44+
title: Progress bar title
45+
46+
Returns:
47+
List of (filename, object) tuples
48+
"""
49+
test_objs = list(helpers.read_test_objects(registry_class))
50+
with create_progress_bar(self.signalpanel, title, max_=len(test_objs)) as prog:
51+
for i_obj, (_fname, obj) in enumerate(test_objs):
52+
prog.setValue(i_obj + 1)
53+
if prog.wasCanceled():
54+
break
55+
if obj is not None:
56+
self.proxy.add_object(obj)
57+
3158
# Signal processing features ------------------------------------------------
3259
def create_paracetamol_signal(self) -> None:
3360
"""Create paracetamol signal"""
@@ -102,6 +129,12 @@ def create_actions(self) -> None:
102129
_("Load spectrum of paracetamol"),
103130
triggered=self.create_paracetamol_signal,
104131
select_condition="always",
132+
)
133+
sah.new_action(
134+
_("Load all test signals"),
135+
triggered=lambda regclass=SignalIORegistry,
136+
title=_("Load all test signals"): self.load_test_objs(regclass, title),
137+
select_condition="always",
105138
separator=True,
106139
)
107140
# Image Panel -----------------------------------------------------------
@@ -148,3 +181,10 @@ def create_actions(self) -> None:
148181
triggered=self.create_grid_gaussian_image,
149182
select_condition="always",
150183
)
184+
iah.new_action(
185+
_("Load all test images"),
186+
triggered=lambda regclass=ImageIORegistry,
187+
title=_("Load all test images"): self.load_test_objs(regclass, title),
188+
select_condition="always",
189+
separator=True,
190+
)

0 commit comments

Comments
 (0)