88and some actions to test DataLab functionalities.
99"""
1010
11+ from __future__ import annotations
12+
1113import 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
1318from datalab .config import _
1419from 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