tomwer 1.3.5__py3-none-any.whl → 1.3.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. orangecontrib/tomwer/test/TestAcquisition.py +246 -0
  2. orangecontrib/tomwer/widgets/cluster/test/test_future_supervisorow.py +87 -0
  3. orangecontrib/tomwer/widgets/cluster/test/test_slurm_clusterow.py +67 -0
  4. orangecontrib/tomwer/widgets/control/test/test_advancement.py +51 -0
  5. orangecontrib/tomwer/widgets/control/test/test_data_validator.py +55 -0
  6. orangecontrib/tomwer/widgets/control/test/test_datadiscovery.py +131 -0
  7. orangecontrib/tomwer/widgets/control/test/test_datalist.py +70 -0
  8. orangecontrib/tomwer/widgets/control/test/test_datalistener.py +137 -0
  9. orangecontrib/tomwer/widgets/control/test/test_dataselector.py +95 -0
  10. orangecontrib/tomwer/widgets/control/test/test_datawatcher.py +436 -0
  11. orangecontrib/tomwer/widgets/control/test/test_emailow.py +29 -0
  12. orangecontrib/tomwer/widgets/control/test/test_notifier.py +51 -0
  13. orangecontrib/tomwer/widgets/control/test/test_nxtomo_concatenate_ow.py +64 -0
  14. orangecontrib/tomwer/widgets/control/test/test_nxtomomill.py +160 -0
  15. orangecontrib/tomwer/widgets/control/test/test_reduce_dark_flat_selector.py +40 -0
  16. orangecontrib/tomwer/widgets/control/test/test_singletomoobj.py +40 -0
  17. orangecontrib/tomwer/widgets/control/test/test_timerow.py +51 -0
  18. orangecontrib/tomwer/widgets/control/test/test_tomoobj_serie.py +96 -0
  19. orangecontrib/tomwer/widgets/control/test/test_volume_selector.py +69 -0
  20. orangecontrib/tomwer/widgets/control/test/test_volumesymlink.py +51 -0
  21. orangecontrib/tomwer/widgets/debugtools/test/test_dataset_generator.py +57 -0
  22. orangecontrib/tomwer/widgets/debugtools/test/test_object_inspector.py +62 -0
  23. orangecontrib/tomwer/widgets/other/test/test_pythonscript.py +31 -0
  24. orangecontrib/tomwer/widgets/reconstruction/test/test_axis.py +224 -0
  25. orangecontrib/tomwer/widgets/reconstruction/test/test_cast_volumeow.py +85 -0
  26. orangecontrib/tomwer/widgets/reconstruction/test/test_dark_refs_widget.py +136 -0
  27. orangecontrib/tomwer/widgets/reconstruction/test/test_delta_beta_selector.py +15 -0
  28. orangecontrib/tomwer/widgets/reconstruction/test/test_i_norm.py +226 -0
  29. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_helical_prepare_weights_double.py +20 -0
  30. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_volume.py +100 -0
  31. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_widget.py +107 -0
  32. orangecontrib/tomwer/widgets/reconstruction/test/test_sa_delta_beta.py +194 -0
  33. orangecontrib/tomwer/widgets/reconstruction/test/test_saaxis.py +220 -0
  34. orangecontrib/tomwer/widgets/stitching/test/test_zstitching.py +308 -0
  35. orangecontrib/tomwer/widgets/test/test_conditions.py +111 -0
  36. orangecontrib/tomwer/widgets/test/test_darkref.py +251 -0
  37. orangecontrib/tomwer/widgets/test/test_foldertransfert.py +131 -0
  38. orangecontrib/tomwer/widgets/visualization/test/test_dataviewerow.py +83 -0
  39. orangecontrib/tomwer/widgets/visualization/test/test_diffviewerow.py +65 -0
  40. orangecontrib/tomwer/widgets/visualization/test/test_live_sliceow.py +63 -0
  41. orangecontrib/tomwer/widgets/visualization/test/test_nxtomo_metadata_viewer.py +29 -0
  42. orangecontrib/tomwer/widgets/visualization/test/test_radio_stackow.py +56 -0
  43. orangecontrib/tomwer/widgets/visualization/test/test_sample_movedow.py +72 -0
  44. orangecontrib/tomwer/widgets/visualization/test/test_sinogram_viewerow.py +56 -0
  45. orangecontrib/tomwer/widgets/visualization/test/test_slice_stackow.py +57 -0
  46. orangecontrib/tomwer/widgets/visualization/test/test_volume_viewerow.py +57 -0
  47. tomwer/core/log/test/test_processlog.py +41 -0
  48. tomwer/core/process/control/datalistener/datalistener.py +11 -11
  49. tomwer/core/process/edit/test/test_darkflatpatch.py +269 -0
  50. tomwer/core/process/edit/test/test_imagekey_editor.py +125 -0
  51. tomwer/core/process/icat/test/test_create_screenshots.py +98 -0
  52. tomwer/core/process/icat/test/test_gallery.py +170 -0
  53. tomwer/core/process/reconstruction/axis/axis.py +3 -3
  54. tomwer/core/process/reconstruction/darkref/darkrefscopy.py +3 -2
  55. tomwer/core/process/reconstruction/nabu/nabucommon.py +3 -4
  56. tomwer/core/process/reconstruction/nabu/nabuslices.py +4 -4
  57. tomwer/core/process/reconstruction/nabu/nabuvolume.py +2 -5
  58. tomwer/core/process/reconstruction/nabu/test/test_castvolume.py +143 -0
  59. tomwer/core/process/reconstruction/nabu/test/test_nabu_utils.py +203 -0
  60. tomwer/core/process/reconstruction/nabu/test/test_nabunormalization.py +222 -0
  61. tomwer/core/process/script/test/test_script.py +68 -0
  62. tomwer/core/process/stitching/test/test_metadataholder.py +17 -0
  63. tomwer/core/process/task.py +3 -2
  64. tomwer/core/process/test/test_data_transfer.py +4 -3
  65. tomwer/core/process/visualization/test/test_data_viewer.py +39 -0
  66. tomwer/core/process/visualization/test/test_diff_viewer.py +39 -0
  67. tomwer/core/process/visualization/test/test_image_stack_viewer.py +41 -0
  68. tomwer/core/process/visualization/test/test_radio_stack.py +39 -0
  69. tomwer/core/process/visualization/test/test_sample_moved.py +41 -0
  70. tomwer/core/process/visualization/test/test_sinogram_viewer.py +39 -0
  71. tomwer/core/process/visualization/test/test_slice_stack.py +39 -0
  72. tomwer/core/process/visualization/test/test_volume_viewer.py +39 -0
  73. tomwer/core/scan/blissscan.py +3 -3
  74. tomwer/core/scan/nxtomoscan.py +2 -2
  75. tomwer/core/scan/scanbase.py +5 -6
  76. tomwer/core/utils/test/test_image.py +30 -0
  77. tomwer/core/utils/test/test_nxtomo.py +66 -0
  78. tomwer/core/utils/test/test_scan_utils.py +46 -0
  79. tomwer/core/utils/test/test_time.py +6 -0
  80. tomwer/core/volume/test/test_volumes.py +21 -0
  81. tomwer/gui/control/reducedarkflatselector.py +2 -2
  82. tomwer/gui/control/serie/test/test_creator.py +451 -0
  83. tomwer/gui/control/serie/test/test_nxtomo_concatenate.py +21 -0
  84. tomwer/gui/edit/dkrfpatch.py +4 -4
  85. tomwer/gui/edit/nxtomowarmer.py +3 -2
  86. tomwer/gui/icat/test/test_create_screenshots_gui.py +23 -0
  87. tomwer/gui/icat/test/test_gallery_gui.py +37 -0
  88. tomwer/gui/imagefromfile.py +2 -2
  89. tomwer/gui/reconstruction/nabu/test/test_check.py +92 -0
  90. tomwer/gui/reconstruction/nabu/test/test_ctf.py +46 -0
  91. tomwer/gui/reconstruction/nabu/test/test_helical.py +21 -0
  92. tomwer/gui/reconstruction/nabu/test/test_nabu_preprocessing.py +81 -0
  93. tomwer/gui/reconstruction/normalization/test/test_intensity.py +119 -0
  94. tomwer/gui/stitching/config/tests/test_axisparams.py +25 -0
  95. tomwer/gui/stitching/tests/test_axis_ordered_list.py +21 -0
  96. tomwer/gui/stitching/tests/test_normalization.py +27 -0
  97. tomwer/gui/stitching/tests/test_preview.py +85 -0
  98. tomwer/gui/stitching/tests/test_stitching_raw.py +110 -0
  99. tomwer/gui/stitching/tests/test_z_stitching.py +67 -0
  100. tomwer/gui/stitching/tests/utils.py +79 -0
  101. tomwer/gui/stitching/z_stitching/tests/test_fine_estimation.py +35 -0
  102. tomwer/gui/stitching/z_stitching/tests/test_raw_estimation.py +215 -0
  103. tomwer/gui/stitching/z_stitching/tests/test_stitching_window.py +51 -0
  104. tomwer/gui/utils/test/test_completer.py +67 -0
  105. tomwer/gui/utils/test/test_line_selector.py +21 -0
  106. tomwer/gui/utils/test/test_splashscreen.py +8 -0
  107. tomwer/gui/utils/test/test_vignettes.py +68 -0
  108. tomwer/io/utils/h5pyutils.py +3 -7
  109. tomwer/io/utils/test/test_raw_and_processed_data.py +10 -0
  110. tomwer/io/utils/test/test_utils.py +92 -0
  111. tomwer/io/utils/utils.py +3 -3
  112. tomwer/synctools/stacks/reconstruction/castvolume.py +20 -5
  113. tomwer/tests/test_ewoks/test_conversion.py +104 -0
  114. tomwer/tests/test_ewoks/test_single_node_execution.py +112 -0
  115. tomwer/tests/test_ewoks/test_workflows.py +160 -0
  116. tomwer/version.py +1 -1
  117. {tomwer-1.3.5.dist-info → tomwer-1.3.7.dist-info}/METADATA +1 -1
  118. {tomwer-1.3.5.dist-info → tomwer-1.3.7.dist-info}/RECORD +124 -27
  119. /tomwer-1.3.5-py3.11-nspkg.pth → /tomwer-1.3.7-py3.11-nspkg.pth +0 -0
  120. {tomwer-1.3.5.dist-info → tomwer-1.3.7.dist-info}/LICENSE +0 -0
  121. {tomwer-1.3.5.dist-info → tomwer-1.3.7.dist-info}/WHEEL +0 -0
  122. {tomwer-1.3.5.dist-info → tomwer-1.3.7.dist-info}/entry_points.txt +0 -0
  123. {tomwer-1.3.5.dist-info → tomwer-1.3.7.dist-info}/namespace_packages.txt +0 -0
  124. {tomwer-1.3.5.dist-info → tomwer-1.3.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,451 @@
1
+ # coding: utf-8
2
+ # /*##########################################################################
3
+ #
4
+ # Copyright (c) 2016-2017 European Synchrotron Radiation Facility
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ # THE SOFTWARE.
23
+ #
24
+ # ###########################################################################*/
25
+
26
+ __authors__ = ["H. Payno"]
27
+ __license__ = "MIT"
28
+ __date__ = "12/01/2022"
29
+
30
+
31
+ import os
32
+ import shutil
33
+ import tempfile
34
+
35
+ from silx.gui import qt
36
+ from silx.gui.utils.testutils import SignalListener, TestCaseQt
37
+ from tomoscan.serie import Serie
38
+
39
+ from tomwer.core.scan.nxtomoscan import NXtomoScan
40
+ from tomwer.core.utils.scanutils import MockEDF, MockNXtomo
41
+ from tomwer.core.volume.hdf5volume import HDF5Volume
42
+ from tomwer.gui.control.serie.seriecreator import (
43
+ SerieDefinition,
44
+ SerieHistoryDialog,
45
+ SerieManualControlDialog,
46
+ SerieManualFromTomoObj,
47
+ SerieTree,
48
+ SerieWidget,
49
+ )
50
+
51
+
52
+ class _MockScanBase:
53
+ def init(self):
54
+ n_hdf5_scan = 11
55
+ self._scans = []
56
+ self._root_dir = tempfile.mkdtemp()
57
+ for i_scan in range(n_hdf5_scan):
58
+ scan_path = os.path.join(self._root_dir, f"scan_{i_scan}")
59
+ scan = MockNXtomo(scan_path=scan_path, n_proj=10, n_ini_proj=0).scan
60
+ self._scans.append(scan)
61
+ n_edf_scan = 4
62
+ for i_scan in range(n_edf_scan):
63
+ scan_path = os.path.join(self._root_dir, f"scan_{i_scan}")
64
+ scan = MockEDF.mockScan(
65
+ scanID=scan_path,
66
+ nRadio=10,
67
+ dim=10,
68
+ )
69
+ self._scans.append(scan)
70
+
71
+ def close(self):
72
+ shutil.rmtree(self._root_dir)
73
+
74
+
75
+ class _MockSerieBase(_MockScanBase):
76
+ def init(self):
77
+ super().init()
78
+ self._series = [
79
+ Serie("serie1", self._scans[0:1], use_identifiers=True),
80
+ Serie("serie2", self._scans[1:5], use_identifiers=False),
81
+ Serie("serie3", self._scans[5:11], use_identifiers=True),
82
+ Serie("serie4", self._scans[8:11], use_identifiers=True),
83
+ Serie("serie5", self._scans[-2:-1], use_identifiers=False),
84
+ Serie("serie6", self._scans[-5:], use_identifiers=True),
85
+ ]
86
+
87
+ def close(self):
88
+ self._series.clear()
89
+ super().close()
90
+
91
+
92
+ class TestSerieTree(TestCaseQt, _MockSerieBase):
93
+ """Test the SerieTree widget"""
94
+
95
+ def setUp(self):
96
+ super().setUp()
97
+ super().init()
98
+ self._widget = SerieTree()
99
+
100
+ def tearDown(self):
101
+ self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
102
+ self._widget.close()
103
+ self._widget = None
104
+ super().close()
105
+ super().tearDown()
106
+
107
+ def test_add_remove(self):
108
+ """Test adding and removing serie"""
109
+ self._widget.show()
110
+ self.qWaitForWindowExposed(self._widget)
111
+ for serie in self._series:
112
+ self._widget.addSerie(serie)
113
+ assert self._widget.n_series == 6
114
+ self._widget.removeSerie(self._series[3])
115
+ assert self._widget.n_series == 5
116
+ self._widget.removeSerie(self._series[2])
117
+ self._widget.removeSerie(self._series[1])
118
+ self._widget.removeSerie(self._series[0])
119
+ # make sure no error is raised if we try to remove twine the same serie
120
+ self._widget.removeSerie(self._series[0])
121
+ assert self._widget.n_series == 2
122
+ self._widget.addSerie(self._series[1])
123
+ self._widget.addSerie(self._series[2])
124
+ assert self._widget.n_series == 4
125
+
126
+ def test_selection(self):
127
+ """Test selection of the SerieTree"""
128
+ self._widget.show()
129
+ self.qWaitForWindowExposed(self._widget)
130
+ for serie in self._series:
131
+ self._widget.addSerie(serie)
132
+
133
+ selection = (self._series[2], self._series[3])
134
+ self._widget.setSelectedSeries(selection)
135
+ assert self._widget.getSelectedSeries() == selection
136
+ self._widget.clearSelection()
137
+ assert self._widget.getSelectedSeries() == ()
138
+
139
+
140
+ class TestSerieHistoryDialog(TestCaseQt, _MockSerieBase):
141
+ """Test the SerieHistoryDialog"""
142
+
143
+ def setUp(self):
144
+ super().setUp()
145
+ super().init()
146
+ self._widget = SerieHistoryDialog()
147
+
148
+ # create listener for the nabu widget
149
+ self.signal_listener = SignalListener()
150
+
151
+ # connect signal / slot
152
+ self._widget.sigSerieSend.connect(self.signal_listener)
153
+
154
+ def tearDown(self):
155
+ self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
156
+ self._widget.close()
157
+ self._widget = None
158
+ super().close()
159
+ super().tearDown()
160
+
161
+ def test(self):
162
+ self._widget.show()
163
+ self.qWaitForWindowExposed(self._widget)
164
+ for serie in self._series:
165
+ self._widget.addSerie(serie)
166
+
167
+ selection = (self._series[0], self._series[4])
168
+ self._widget.setSelectedSeries(selection)
169
+ assert self._widget.getSelectedSeries() == selection
170
+ assert self.signal_listener.callCount() == 0
171
+ self._widget._sendButton.clicked.emit()
172
+ self.qapp.processEvents()
173
+ assert self.signal_listener.callCount() == 2
174
+ assert self._widget.getSelectedSeries() == selection
175
+ self.signal_listener.clear()
176
+ self._widget._clearButton.clicked.emit()
177
+ assert self._widget.getSelectedSeries() == ()
178
+ assert self.signal_listener.callCount() == 0
179
+ self._widget._sendButton.clicked.emit()
180
+ assert self.signal_listener.callCount() == 0
181
+
182
+
183
+ class TestSerieDefinition(TestCaseQt):
184
+ def setUp(self):
185
+ super().setUp()
186
+ self._widget = SerieDefinition()
187
+
188
+ def tearDown(self):
189
+ self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
190
+ self._widget.close()
191
+ self._widget = None
192
+ super().tearDown()
193
+
194
+ def test_manual_selection(self):
195
+ self._widget.setMode("manual")
196
+ self._widget.show()
197
+ self.qWaitForWindowExposed(self._widget)
198
+ assert not self._widget._automaticDefWidget.isVisible()
199
+ assert self._widget._manualDefWidget.isVisible()
200
+
201
+ def test_automatic_selection(self):
202
+ self._widget.setMode("auto")
203
+ self._widget.show()
204
+ self.qWaitForWindowExposed(self._widget)
205
+ assert self._widget._automaticDefWidget.isVisible()
206
+ assert not self._widget._manualDefWidget.isVisible()
207
+
208
+
209
+ class TestSerieManualDefinitionDialog(TestCaseQt, _MockScanBase):
210
+ """Test interaction with the serie manual definition"""
211
+
212
+ def setUp(self):
213
+ self._widget = SerieManualControlDialog()
214
+ super().setUp()
215
+ super().init()
216
+
217
+ def tearDown(self):
218
+ self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
219
+ self._widget.close()
220
+ self._widget = None
221
+ super().close()
222
+ super().tearDown()
223
+
224
+ def test(self):
225
+ self._widget.show()
226
+ self.qWaitForWindowExposed(self._widget)
227
+
228
+ self._widget.setSerieName("serie test")
229
+ self.qapp.processEvents()
230
+ assert self._widget.getSerieName() == "serie test"
231
+
232
+ self._widget._mainWidget._newSerieWidget._serieTree.rootItem.setText(
233
+ 0, "new serie"
234
+ )
235
+ self.qapp.processEvents()
236
+ assert self._widget.getSerieName() == "new serie"
237
+
238
+ for scan in self._scans[:5]:
239
+ self._widget.addScan(scan)
240
+
241
+ self.assertEqual(self._widget.n_tomo_objs, len(self._scans[:5]))
242
+ self._widget.removeScan(self._scans[0])
243
+ self.assertEqual(self._widget.n_tomo_objs, len(self._scans[:5]) - 1)
244
+
245
+ series_scan = tuple(self._scans[1:5])
246
+ assert isinstance(series_scan, tuple)
247
+
248
+ current_serie = self._widget.getSerie(use_identifiers=True)
249
+ assert isinstance(current_serie, Serie)
250
+ serie_test_1 = Serie(
251
+ name="new serie", iterable=series_scan, use_identifiers=True
252
+ )
253
+
254
+ self.assertEqual(serie_test_1, current_serie)
255
+ serie_test_2 = Serie(name="test", iterable=series_scan, use_identifiers=True)
256
+ assert serie_test_2.name == "test"
257
+ assert current_serie.name == "new serie"
258
+ self.assertNotEqual(serie_test_2, current_serie)
259
+
260
+ self._widget.setSelectedScans([self._scans[2]])
261
+ self._widget.getSelectedScans() == (self._scans[2],)
262
+ self._widget.removeSelectedScans()
263
+ self.assertEqual(self._widget.n_tomo_objs, len(self._scans[:5]) - 2)
264
+ self._widget.getSelectedScans() == tuple()
265
+
266
+ self._widget.clearSerie()
267
+ self.assertEqual(self._widget.n_tomo_objs, 0)
268
+ self.assertEqual(Serie(name="new serie"), self._widget.getSerie())
269
+
270
+ # test adding an nx file
271
+ hdf5_scan = self._scans[0]
272
+ assert isinstance(hdf5_scan, NXtomoScan)
273
+ self._widget.addScanFromNxFile(hdf5_scan.master_file)
274
+ self.assertEqual(self._widget.n_tomo_objs, 1)
275
+
276
+
277
+ class TestSerieWidget(TestCaseQt, _MockSerieBase):
278
+ """
279
+ Test the SerieWidget
280
+ """
281
+
282
+ def setUp(self):
283
+ super().setUp()
284
+ super().init()
285
+ self._widget = SerieWidget()
286
+ # create listeners
287
+ self.signal_send_serie_listener = SignalListener()
288
+ self.signal_serie_changed_listener = SignalListener()
289
+ self.signal_history_changed_listener = SignalListener()
290
+
291
+ # connect signal / slot
292
+ self._widget.sigSerieSend.connect(self.signal_send_serie_listener)
293
+ self._widget.sigCurrentSerieChanged.connect(self.signal_serie_changed_listener)
294
+ self._widget.sigHistoryChanged.connect(self.signal_history_changed_listener)
295
+
296
+ def tearDown(self):
297
+ self._widget.sigSerieSend.disconnect(self.signal_send_serie_listener)
298
+ self._widget.sigCurrentSerieChanged.disconnect(
299
+ self.signal_serie_changed_listener
300
+ )
301
+ self._widget.sigHistoryChanged.disconnect(self.signal_history_changed_listener)
302
+
303
+ self.signal_send_serie_listener = None
304
+ self.signal_serie_changed_listener = None
305
+ self.signal_history_changed_listener = None
306
+
307
+ self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
308
+ self._widget.close()
309
+ self._widget = None
310
+ super().close()
311
+ super().tearDown()
312
+
313
+ def test(self):
314
+ self._widget.show()
315
+ self.qWaitForWindowExposed(self._widget)
316
+ self._series[3].name = "toto serie"
317
+ for serie in self._series[2:5]:
318
+ self._widget.getHistoryWidget().addSerie(serie)
319
+ self._widget.setMode("history")
320
+ self._widget.setMode("serie definition", "manual")
321
+ self._widget.getDefinitionWidget().getManualDefinitionWidget().setSerieName(
322
+ "new serie"
323
+ )
324
+
325
+ self.assertEqual(
326
+ len(
327
+ self._widget.getDefinitionWidget()
328
+ .getManualDefinitionWidget()
329
+ .getSerie()
330
+ ),
331
+ 0,
332
+ )
333
+
334
+ self._widget.getHistoryWidget().setSelectedSeries(
335
+ [
336
+ self._series[3],
337
+ ]
338
+ )
339
+ assert len(self._widget.getHistoryWidget().getSelectedSeries()) == 1
340
+
341
+ self.signal_serie_changed_listener.clear()
342
+ self._widget.getHistoryWidget().editSelected()
343
+ self.qapp.processEvents()
344
+ assert self.signal_serie_changed_listener.callCount() == 1
345
+
346
+ self.assertEqual(
347
+ self._widget.getDefinitionWidget()
348
+ .getManualDefinitionWidget()
349
+ .getSerie()
350
+ .name,
351
+ "toto serie",
352
+ )
353
+
354
+ self.assertEqual(
355
+ self._widget.getDefinitionWidget()
356
+ .getManualDefinitionWidget()
357
+ .getSerie(use_identifiers=True),
358
+ self._series[3],
359
+ )
360
+
361
+ self.signal_serie_changed_listener.clear()
362
+ self._widget.getDefinitionWidget().getManualDefinitionWidget().addToCurrentSerie(
363
+ self._scans[0]
364
+ )
365
+ self.qapp.processEvents()
366
+ assert self.signal_serie_changed_listener.callCount() == 1
367
+
368
+ expected_scans = self._scans[8:11]
369
+ expected_scans.append(self._scans[0])
370
+ expected_serie = Serie("toto serie", expected_scans, use_identifiers=True)
371
+
372
+ self.assertEqual(
373
+ self._widget.getDefinitionWidget()
374
+ .getManualDefinitionWidget()
375
+ .getSerie(use_identifiers=True),
376
+ expected_serie,
377
+ )
378
+
379
+ # check send edited serie
380
+ self.signal_history_changed_listener.clear()
381
+ self.signal_send_serie_listener.clear()
382
+ self.qapp.processEvents()
383
+
384
+ # check send selected from the history
385
+ self.signal_send_serie_listener.clear()
386
+ self._widget.getHistoryWidget().setSelectedSeries(
387
+ [
388
+ self._series[4],
389
+ ]
390
+ )
391
+ assert len(self._widget.getHistoryWidget().getSelectedSeries()) == 1
392
+ self._widget.getHistoryWidget().sendSelected()
393
+ assert self.signal_send_serie_listener.callCount() == 1
394
+
395
+
396
+ class TestSerieManualFromTomoObj(TestCaseQt):
397
+ """
398
+ test the SerieManualFromTomoObj widget
399
+ """
400
+
401
+ def setUp(self):
402
+ super().setUp()
403
+ self._tmp_dir = tempfile.mkdtemp()
404
+ self._widget = SerieManualFromTomoObj()
405
+ self._volume_1 = HDF5Volume(
406
+ file_path=os.path.join(self._tmp_dir, "vol1.hdf5"),
407
+ data_path="data",
408
+ )
409
+ self._volume_2 = HDF5Volume(
410
+ file_path=os.path.join(self._tmp_dir, "vol2.hdf"),
411
+ data_path="data",
412
+ )
413
+ self._volume_3 = HDF5Volume(
414
+ file_path=os.path.join(self._tmp_dir, "vol3.nx"),
415
+ data_path="data",
416
+ )
417
+ self._scan_1 = MockNXtomo(
418
+ scan_path=os.path.join(self._tmp_dir, "scan_1"), n_proj=10, n_ini_proj=10
419
+ ).scan
420
+ self._scan_2 = MockNXtomo(
421
+ scan_path=os.path.join(self._tmp_dir, "scan_2"), n_proj=10, n_ini_proj=10
422
+ ).scan
423
+
424
+ def tearDown(self):
425
+ shutil.rmtree(self._tmp_dir)
426
+ self._widget.setAttribute(qt.Qt.WA_DeleteOnClose)
427
+ self._widget.close()
428
+ self._widget = None
429
+ return super().tearDown()
430
+
431
+ def test(self):
432
+ self._widget.show()
433
+ for tomo_obj in (
434
+ self._volume_1,
435
+ self._volume_2,
436
+ self._volume_3,
437
+ self._scan_1,
438
+ self._scan_2,
439
+ ):
440
+ self._widget.addTomoObj(tomo_obj)
441
+
442
+ current_serie = self._widget.getSerie()
443
+ assert isinstance(current_serie, Serie)
444
+ assert len(current_serie) == 0
445
+
446
+ for tomo_obj in (self._volume_1, self._volume_2):
447
+ self._widget.addToCurrentSerie(tomo_obj)
448
+
449
+ current_serie = self._widget.getSerie()
450
+ assert isinstance(current_serie, Serie)
451
+ assert len(current_serie) == 2
@@ -0,0 +1,21 @@
1
+ from tomwer.tests.conftest import qtapp # noqa F401
2
+ from tomwer.gui.control.serie.nxtomoconcatenate import NXtomoConcatenateWidget
3
+
4
+
5
+ def test_NXtomoConcatenateWidget(
6
+ qtapp, # noqa F811
7
+ ):
8
+ """simple test of the NXtomoConcatenateWidget"""
9
+ widget = NXtomoConcatenateWidget()
10
+ assert widget.getConfiguration() == {
11
+ "output_file": "{common_path}/concatenate.nx",
12
+ "output_entry": "entry0000",
13
+ "overwrite": False,
14
+ }
15
+ config = {
16
+ "output_file": "helical.hdf5",
17
+ "output_entry": "my_entry",
18
+ "overwrite": True,
19
+ }
20
+ widget.setConfiguration(config=config)
21
+ assert widget.getConfiguration() == config
@@ -36,8 +36,8 @@ from silx.gui import qt
36
36
  from silx.gui.dialog.DataFileDialog import DataFileDialog
37
37
  from silx.io.url import DataUrl
38
38
  from silx.io.utils import h5py_read_dataset
39
+ from silx.io.utils import open as open_hdf5
39
40
  from nxtomo.nxobject.nxdetector import ImageKey
40
- from tomoscan.io import HDF5File, get_swmr_mode
41
41
 
42
42
  import tomwer.core.utils.nxtomoutils as nxtomo_utils
43
43
  from tomwer.core.scan.nxtomoscan import NXtomoScan
@@ -83,7 +83,7 @@ class _DarkOrFlatUrl(qt.QWidget):
83
83
  url = self._redirectDataPath(url, logger=_logger)
84
84
 
85
85
  def dataset_invalid(url):
86
- with HDF5File(url.file_path(), mode="r", swmr=get_swmr_mode()) as h5s:
86
+ with open_hdf5(url.file_path()) as h5s:
87
87
  if not isinstance(h5s[url.data_path()], h5py.Dataset):
88
88
  return True
89
89
  return False
@@ -113,7 +113,7 @@ class _DarkOrFlatUrl(qt.QWidget):
113
113
 
114
114
  def _redirectDataPath(self, url, logger=None):
115
115
  try:
116
- with HDF5File(url.file_path(), mode="r", swmr=get_swmr_mode()) as h5s:
116
+ with open_hdf5(url.file_path()) as h5s:
117
117
  node = h5s[url.data_path()]
118
118
 
119
119
  if NXtomoScan.entry_is_nx_tomo(node):
@@ -188,7 +188,7 @@ class _DarkOrFlatUrl(qt.QWidget):
188
188
  def _getImageKey(self, url):
189
189
  # if we are on a 'detector / data dataset' then we can try to reach
190
190
  # image_key information
191
- with HDF5File(url.file_path(), mode="r", swmr=get_swmr_mode()) as h5s:
191
+ with open_hdf5(url.file_path()) as h5s:
192
192
  dataset = h5s[url.data_path()]
193
193
  grp_parent = dataset.parent
194
194
  if grp_parent is not None and NXtomoScan.is_nxdetector(grp_parent):
@@ -1,9 +1,10 @@
1
1
  from typing import Optional
2
2
  import h5py
3
3
  from silx.gui import qt
4
+ from silx.io.utils import open as open_hdf5
5
+
4
6
  from tomwer.core.scan.nxtomoscan import NXtomoScan
5
7
  from tomwer.gui import icons
6
- from tomoscan.io import HDF5File, get_swmr_mode
7
8
 
8
9
 
9
10
  class NXtomoProxyWarmer(qt.QWidget):
@@ -44,7 +45,7 @@ class NXtomoProxyWarmer(qt.QWidget):
44
45
  if scan is None:
45
46
  self._activateWarning(False)
46
47
  elif isinstance(scan, NXtomoScan):
47
- with HDF5File(scan.master_file, mode="r", swmr=get_swmr_mode()) as h5f:
48
+ with open_hdf5(scan.master_file) as h5f:
48
49
  entry = h5f.get(
49
50
  name=scan.entry, getclass=True, getlink=True, default=None
50
51
  )
@@ -0,0 +1,23 @@
1
+ from tomwer.tests.conftest import qtapp # noqa F401
2
+ from tomwer.gui.icat.createscreenshots import CreateRawDataScreenshotsWidget
3
+
4
+
5
+ def test_CreateRawDataScreenshotsWidget(qtapp): # noqa F811
6
+ widget = CreateRawDataScreenshotsWidget()
7
+
8
+ assert widget.getConfiguration() == {
9
+ "raw_projections_required": True,
10
+ "raw_projections_each": 90,
11
+ "raw_darks_required": True,
12
+ "raw_flats_required": True,
13
+ }
14
+
15
+ new_config = {
16
+ "raw_projections_required": True,
17
+ "raw_projections_each": 26,
18
+ "raw_darks_required": False,
19
+ "raw_flats_required": False,
20
+ }
21
+ widget.setConfiguration(new_config)
22
+
23
+ assert widget.getConfiguration() == new_config
@@ -0,0 +1,37 @@
1
+ from tomwer.tests.conftest import qtapp # noqa F401
2
+ from tomwer.gui.icat.gallery import GalleryWidget
3
+
4
+
5
+ def test_GalleryWidget(
6
+ qtapp, # noqa F811
7
+ ):
8
+ widget = GalleryWidget()
9
+ assert widget.getConfiguration() == {
10
+ "beamline": "bm05",
11
+ "beamline_auto_update": True,
12
+ "dataset": "",
13
+ "dataset_auto_update": True,
14
+ "proposal": "",
15
+ "proposal_auto_update": True,
16
+ "output_format": "png",
17
+ "output_location_mode": "dataset gallery",
18
+ "custom_output": "",
19
+ "overwrite": True,
20
+ "binning": "16x16",
21
+ }
22
+
23
+ new_config = {
24
+ "beamline": "id19",
25
+ "beamline_auto_update": False,
26
+ "dataset": "my_dataset",
27
+ "dataset_auto_update": False,
28
+ "proposal": "inh99",
29
+ "proposal_auto_update": False,
30
+ "output_location_mode": "custom",
31
+ "output_format": "jpg",
32
+ "custom_output": "",
33
+ "overwrite": False,
34
+ "binning": "4x4",
35
+ }
36
+ widget.setConfiguration(new_config)
37
+ assert widget.getConfiguration() == new_config
@@ -34,7 +34,7 @@ import logging
34
34
 
35
35
  from silx.gui import qt
36
36
  from silx.io.url import DataUrl
37
- from tomoscan.io import HDF5File, get_swmr_mode
37
+ from silx.io.utils import open as open_hdf5
38
38
 
39
39
  from tomwer.core.scan.scanbase import TomwerScanBase
40
40
  from tomwer.synctools.imageloaderthread import ImageLoaderThread
@@ -71,7 +71,7 @@ class ImageFromFile(_Image):
71
71
 
72
72
  def get_nabu_entry():
73
73
  try:
74
- with HDF5File(_file, mode="r", swmr=get_swmr_mode()) as h5s:
74
+ with open_hdf5(_file) as h5s:
75
75
  for node in h5s:
76
76
  if "reconstruction" in h5s[node]:
77
77
  return "/".join(