tomwer 1.3.7__py3-none-any.whl → 1.3.9__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 (109) hide show
  1. tomwer/core/process/reconstruction/nabu/nabuslices.py +0 -48
  2. tomwer/core/process/reconstruction/nabu/utils.py +2 -0
  3. tomwer/gui/control/datawatcher/datawatcher.py +1 -24
  4. tomwer/version.py +1 -1
  5. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/METADATA +1 -1
  6. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/RECORD +12 -109
  7. orangecontrib/tomwer/test/TestAcquisition.py +0 -246
  8. orangecontrib/tomwer/widgets/cluster/test/test_future_supervisorow.py +0 -87
  9. orangecontrib/tomwer/widgets/cluster/test/test_slurm_clusterow.py +0 -67
  10. orangecontrib/tomwer/widgets/control/test/test_advancement.py +0 -51
  11. orangecontrib/tomwer/widgets/control/test/test_data_validator.py +0 -55
  12. orangecontrib/tomwer/widgets/control/test/test_datadiscovery.py +0 -131
  13. orangecontrib/tomwer/widgets/control/test/test_datalist.py +0 -70
  14. orangecontrib/tomwer/widgets/control/test/test_datalistener.py +0 -137
  15. orangecontrib/tomwer/widgets/control/test/test_dataselector.py +0 -95
  16. orangecontrib/tomwer/widgets/control/test/test_datawatcher.py +0 -436
  17. orangecontrib/tomwer/widgets/control/test/test_emailow.py +0 -29
  18. orangecontrib/tomwer/widgets/control/test/test_notifier.py +0 -51
  19. orangecontrib/tomwer/widgets/control/test/test_nxtomo_concatenate_ow.py +0 -64
  20. orangecontrib/tomwer/widgets/control/test/test_nxtomomill.py +0 -160
  21. orangecontrib/tomwer/widgets/control/test/test_reduce_dark_flat_selector.py +0 -40
  22. orangecontrib/tomwer/widgets/control/test/test_singletomoobj.py +0 -40
  23. orangecontrib/tomwer/widgets/control/test/test_timerow.py +0 -51
  24. orangecontrib/tomwer/widgets/control/test/test_tomoobj_serie.py +0 -96
  25. orangecontrib/tomwer/widgets/control/test/test_volume_selector.py +0 -69
  26. orangecontrib/tomwer/widgets/control/test/test_volumesymlink.py +0 -51
  27. orangecontrib/tomwer/widgets/debugtools/test/test_dataset_generator.py +0 -57
  28. orangecontrib/tomwer/widgets/debugtools/test/test_object_inspector.py +0 -62
  29. orangecontrib/tomwer/widgets/other/test/test_pythonscript.py +0 -31
  30. orangecontrib/tomwer/widgets/reconstruction/test/test_axis.py +0 -224
  31. orangecontrib/tomwer/widgets/reconstruction/test/test_cast_volumeow.py +0 -85
  32. orangecontrib/tomwer/widgets/reconstruction/test/test_dark_refs_widget.py +0 -136
  33. orangecontrib/tomwer/widgets/reconstruction/test/test_delta_beta_selector.py +0 -15
  34. orangecontrib/tomwer/widgets/reconstruction/test/test_i_norm.py +0 -226
  35. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_helical_prepare_weights_double.py +0 -20
  36. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_volume.py +0 -100
  37. orangecontrib/tomwer/widgets/reconstruction/test/test_nabu_widget.py +0 -107
  38. orangecontrib/tomwer/widgets/reconstruction/test/test_sa_delta_beta.py +0 -194
  39. orangecontrib/tomwer/widgets/reconstruction/test/test_saaxis.py +0 -220
  40. orangecontrib/tomwer/widgets/stitching/test/test_zstitching.py +0 -308
  41. orangecontrib/tomwer/widgets/test/test_conditions.py +0 -111
  42. orangecontrib/tomwer/widgets/test/test_darkref.py +0 -251
  43. orangecontrib/tomwer/widgets/test/test_foldertransfert.py +0 -131
  44. orangecontrib/tomwer/widgets/visualization/test/test_dataviewerow.py +0 -83
  45. orangecontrib/tomwer/widgets/visualization/test/test_diffviewerow.py +0 -65
  46. orangecontrib/tomwer/widgets/visualization/test/test_live_sliceow.py +0 -63
  47. orangecontrib/tomwer/widgets/visualization/test/test_nxtomo_metadata_viewer.py +0 -29
  48. orangecontrib/tomwer/widgets/visualization/test/test_radio_stackow.py +0 -56
  49. orangecontrib/tomwer/widgets/visualization/test/test_sample_movedow.py +0 -72
  50. orangecontrib/tomwer/widgets/visualization/test/test_sinogram_viewerow.py +0 -56
  51. orangecontrib/tomwer/widgets/visualization/test/test_slice_stackow.py +0 -57
  52. orangecontrib/tomwer/widgets/visualization/test/test_volume_viewerow.py +0 -57
  53. tomwer/core/log/test/test_processlog.py +0 -41
  54. tomwer/core/process/edit/test/test_darkflatpatch.py +0 -269
  55. tomwer/core/process/edit/test/test_imagekey_editor.py +0 -125
  56. tomwer/core/process/icat/test/test_create_screenshots.py +0 -98
  57. tomwer/core/process/icat/test/test_gallery.py +0 -170
  58. tomwer/core/process/reconstruction/nabu/test/test_castvolume.py +0 -143
  59. tomwer/core/process/reconstruction/nabu/test/test_nabu_utils.py +0 -203
  60. tomwer/core/process/reconstruction/nabu/test/test_nabunormalization.py +0 -222
  61. tomwer/core/process/script/test/test_script.py +0 -68
  62. tomwer/core/process/stitching/test/test_metadataholder.py +0 -17
  63. tomwer/core/process/visualization/test/test_data_viewer.py +0 -39
  64. tomwer/core/process/visualization/test/test_diff_viewer.py +0 -39
  65. tomwer/core/process/visualization/test/test_image_stack_viewer.py +0 -41
  66. tomwer/core/process/visualization/test/test_radio_stack.py +0 -39
  67. tomwer/core/process/visualization/test/test_sample_moved.py +0 -41
  68. tomwer/core/process/visualization/test/test_sinogram_viewer.py +0 -39
  69. tomwer/core/process/visualization/test/test_slice_stack.py +0 -39
  70. tomwer/core/process/visualization/test/test_volume_viewer.py +0 -39
  71. tomwer/core/utils/test/test_image.py +0 -30
  72. tomwer/core/utils/test/test_nxtomo.py +0 -66
  73. tomwer/core/utils/test/test_scan_utils.py +0 -46
  74. tomwer/core/utils/test/test_time.py +0 -6
  75. tomwer/core/volume/test/test_volumes.py +0 -21
  76. tomwer/gui/control/serie/test/test_creator.py +0 -451
  77. tomwer/gui/control/serie/test/test_nxtomo_concatenate.py +0 -21
  78. tomwer/gui/icat/test/test_create_screenshots_gui.py +0 -23
  79. tomwer/gui/icat/test/test_gallery_gui.py +0 -37
  80. tomwer/gui/reconstruction/nabu/test/test_check.py +0 -92
  81. tomwer/gui/reconstruction/nabu/test/test_ctf.py +0 -46
  82. tomwer/gui/reconstruction/nabu/test/test_helical.py +0 -21
  83. tomwer/gui/reconstruction/nabu/test/test_nabu_preprocessing.py +0 -81
  84. tomwer/gui/reconstruction/normalization/test/test_intensity.py +0 -119
  85. tomwer/gui/stitching/config/tests/test_axisparams.py +0 -25
  86. tomwer/gui/stitching/tests/test_axis_ordered_list.py +0 -21
  87. tomwer/gui/stitching/tests/test_normalization.py +0 -27
  88. tomwer/gui/stitching/tests/test_preview.py +0 -85
  89. tomwer/gui/stitching/tests/test_stitching_raw.py +0 -110
  90. tomwer/gui/stitching/tests/test_z_stitching.py +0 -67
  91. tomwer/gui/stitching/tests/utils.py +0 -79
  92. tomwer/gui/stitching/z_stitching/tests/test_fine_estimation.py +0 -35
  93. tomwer/gui/stitching/z_stitching/tests/test_raw_estimation.py +0 -215
  94. tomwer/gui/stitching/z_stitching/tests/test_stitching_window.py +0 -51
  95. tomwer/gui/utils/test/test_completer.py +0 -67
  96. tomwer/gui/utils/test/test_line_selector.py +0 -21
  97. tomwer/gui/utils/test/test_splashscreen.py +0 -8
  98. tomwer/gui/utils/test/test_vignettes.py +0 -68
  99. tomwer/io/utils/test/test_raw_and_processed_data.py +0 -10
  100. tomwer/io/utils/test/test_utils.py +0 -92
  101. tomwer/tests/test_ewoks/test_conversion.py +0 -104
  102. tomwer/tests/test_ewoks/test_single_node_execution.py +0 -112
  103. tomwer/tests/test_ewoks/test_workflows.py +0 -160
  104. /tomwer-1.3.7-py3.11-nspkg.pth → /tomwer-1.3.9-py3.11-nspkg.pth +0 -0
  105. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/LICENSE +0 -0
  106. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/WHEEL +0 -0
  107. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/entry_points.txt +0 -0
  108. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/namespace_packages.txt +0 -0
  109. {tomwer-1.3.7.dist-info → tomwer-1.3.9.dist-info}/top_level.txt +0 -0
@@ -1,20 +0,0 @@
1
- import pickle
2
-
3
- from orangecanvas.scheme.readwrite import literal_dumps
4
-
5
- from tomwer.tests.conftest import qtapp # noqa F401
6
-
7
- from orangecontrib.tomwer.widgets.reconstruction.NabuHelicalPrepareWeightsDoubleOW import (
8
- NabuHelicalPrepareWeightsDoubleOW,
9
- )
10
-
11
-
12
- def test_NabuHelicalPrepareWeightsDoubleOW(
13
- qtapp, # noqa F811
14
- ):
15
- """simple test of the _DeltaBetaSelectorDialog"""
16
- widget = NabuHelicalPrepareWeightsDoubleOW()
17
- widget._loadSettings()
18
- # test settings serialization
19
- pickle.dumps(widget._ewoks_default_inputs)
20
- literal_dumps(widget._ewoks_default_inputs)
@@ -1,100 +0,0 @@
1
- # coding: utf-8
2
- # /*##########################################################################
3
- #
4
- # Copyright (c) 2017-2021 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__ = "21/06/2021"
29
-
30
-
31
- import gc
32
- import os
33
- import pickle
34
- import shutil
35
- import tempfile
36
- from time import sleep
37
-
38
- from nabu.pipeline.config import get_default_nabu_config
39
- from nabu.pipeline.fullfield.nabu_config import (
40
- nabu_config as nabu_fullfield_default_config,
41
- )
42
- from orangecanvas.scheme.readwrite import literal_dumps
43
- from silx.gui import qt
44
- from silx.gui.utils.testutils import TestCaseQt
45
-
46
- from orangecontrib.tomwer.widgets.reconstruction.NabuVolumeOW import NabuVolumeOW
47
- from tomwer.core.utils.scanutils import MockNXtomo
48
-
49
-
50
- class TestNabuVolumeOW(TestCaseQt):
51
- def setUp(self):
52
- super().setUp()
53
- self.tmp_dir = tempfile.mkdtemp()
54
- self.scan = MockNXtomo(
55
- scan_path=os.path.join(self.tmp_dir, "myscan"),
56
- n_proj=20,
57
- n_ini_proj=20,
58
- dim=10,
59
- ).scan
60
- self.widget = NabuVolumeOW()
61
- self.widget._processingStack.setDryRun(True)
62
-
63
- def tearDown(self):
64
- self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
65
- self.widget.close()
66
- self.widget = None
67
- shutil.rmtree(self.tmp_dir)
68
- self.qapp.processEvents()
69
- gc.collect()
70
-
71
- def test_serializing(self):
72
- pickle.dumps(self.widget.getConfiguration())
73
-
74
- def test_literal_dumps(self):
75
- literal_dumps(self.widget.getConfiguration())
76
-
77
- def test_scan_as_None(self):
78
- "test if scan is None"
79
- self.widget.process(None)
80
-
81
- def test_scan_un_preprocessed(self):
82
- "test when scan is unconfigured (No nabu_recons_params defined)"
83
- assert self.scan.nabu_recons_params is None
84
- self.widget.process(self.scan)
85
-
86
- def test_scan_ready_to_be_processed(self):
87
- "test if scan has valid reconstruction parameters to be runned"
88
- self.scan.nabu_recons_params = get_default_nabu_config(
89
- nabu_fullfield_default_config
90
- )
91
- self.widget.process(self.scan)
92
- timeout = 3
93
- loop_sleep_time = 0.05
94
- while not self.widget._processingStack.can_process_next():
95
- self.qapp.processEvents()
96
- timeout -= loop_sleep_time
97
- if timeout <= 0.0:
98
- raise TimeoutError("volume not process within expected time")
99
- else:
100
- sleep(loop_sleep_time)
@@ -1,107 +0,0 @@
1
- import gc
2
- import logging
3
- import os
4
- import pickle
5
- import shutil
6
- import tempfile
7
- import time
8
- from glob import glob
9
-
10
- import h5py
11
- from orangecanvas.scheme.readwrite import literal_dumps
12
- from silx.gui import qt
13
- from silx.gui.utils.testutils import SignalListener, TestCaseQt
14
- from nxtomo.nxobject.nxdetector import FOV
15
-
16
- from orangecontrib.tomwer.widgets.reconstruction.NabuOW import NabuOW
17
- from tomwer.core.process.reconstruction.nabu.utils import _NabuMode
18
- from tomwer.core.scan.nxtomoscan import NXtomoScan
19
- from tomwer.core.settings import mock_lsbram
20
- from tomwer.core.utils.lbsram import mock_low_memory
21
- from tomwer.synctools.darkref import QDKRFRP
22
- from tomwer.tests.datasets import TomwerCIDatasets
23
-
24
- logging.disable(logging.INFO)
25
-
26
-
27
- class TestNabuWidget(TestCaseQt):
28
- """class testing the NabuOW"""
29
-
30
- def setUp(self):
31
- TestCaseQt.setUp(self)
32
- self._recons_params = QDKRFRP()
33
- self.widget = NabuOW(parent=None)
34
- self.scan_dir = tempfile.mkdtemp()
35
- # create dataset
36
- self.master_file = os.path.join(self.scan_dir, "frm_edftomomill_twoentries.nx")
37
- shutil.copyfile(
38
- TomwerCIDatasets.get_dataset(
39
- "h5_datasets/frm_edftomomill_twoentries.nx",
40
- ),
41
- self.master_file,
42
- )
43
- self.scan = NXtomoScan(scan=self.master_file, entry="entry0000")
44
- # create listener for the nabu widget
45
- self.signal_listener = SignalListener()
46
-
47
- # connect signal / slot
48
- self.widget.sigScanReady.connect(self.signal_listener)
49
-
50
- # set up
51
- mock_low_memory(True)
52
- mock_lsbram(True)
53
- self.widget.setDryRun(dry_run=True)
54
-
55
- def tearDown(self):
56
- mock_low_memory(False)
57
- mock_lsbram(False)
58
- self.widget.sigScanReady.disconnect(self.signal_listener)
59
- self._recons_params = None
60
- self.scan = None
61
- self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
62
- self.widget.close()
63
- self.widget = None
64
- gc.collect()
65
-
66
- def test_serializing(self):
67
- pickle.dumps(self.widget.getConfiguration())
68
-
69
- def test_literal_dumps(self):
70
- literal_dumps(self.widget.getConfiguration())
71
-
72
- def testLowMemory(self):
73
- """Make sure no reconstruction is started if we are low in memory in
74
- lbsram"""
75
- self.assertEqual(len(glob(os.path.join(self.scan_dir, "*.cfg"))), 0)
76
- self.widget.process(self.scan)
77
- self.wait_processing()
78
- self.assertEqual(len(glob(os.path.join(self.scan_dir, "*.cfg"))), 0)
79
-
80
- def wait_processing(self):
81
- timeout = 10
82
- while timeout >= 0 and self.signal_listener.callCount() == 0:
83
- timeout -= 0.1
84
- time.sleep(0.1)
85
- if timeout <= 0.0:
86
- raise TimeoutError("nabu widget never end processing")
87
-
88
- def patch_fov(self, value: str):
89
- with h5py.File(self.scan.master_file, mode="a") as h5s:
90
- for entry in ("entry0000", "entry0001"):
91
- entry_node = h5s[entry]
92
- if "instrument/detector/field_of_view" in entry_node:
93
- del entry_node["instrument/detector/field_of_view"]
94
- entry_node["instrument/detector/field_of_view"] = value
95
-
96
- def testSetConfiguration(self):
97
- """Make sure the configuration evolve from scan information"""
98
- self.assertEqual(self.widget.getMode(), _NabuMode.FULL_FIELD)
99
- self.patch_fov(value=FOV.HALF.value)
100
- self.widget.process(self.scan)
101
- self.wait_processing()
102
- self.assertEqual(self.widget.getMode(), _NabuMode.HALF_ACQ)
103
- self.patch_fov(value=FOV.FULL.value)
104
- self.scan.clear_caches()
105
- self.widget.process(self.scan)
106
- self.wait_processing()
107
- self.assertEqual(self.widget.getMode(), _NabuMode.FULL_FIELD)
@@ -1,194 +0,0 @@
1
- import gc
2
- import logging
3
- import os
4
- import pickle
5
- import shutil
6
- import tempfile
7
- import uuid
8
-
9
- import h5py
10
- import numpy
11
- from orangecanvas.scheme.readwrite import literal_dumps
12
- from processview.core.manager import DatasetState, ProcessManager
13
- from silx.gui import qt
14
- from silx.gui.utils.testutils import TestCaseQt
15
- from silx.io.url import DataUrl
16
-
17
- from orangecontrib.tomwer.widgets.reconstruction.SADeltaBetaOW import (
18
- SADeltaBetaOW as _SADeltaBetaOW,
19
- )
20
- from tomwer.core import settings
21
- from tomwer.core.utils.lbsram import mock_low_memory
22
- from tomwer.core.process.reconstruction.scores import ComputedScore
23
- from tomwer.core.utils.scanutils import MockNXtomo
24
-
25
- logger = logging.getLogger(__name__)
26
-
27
-
28
- class SADeltaBetaOW(_SADeltaBetaOW):
29
- def __init__(self, parent=None):
30
- self._scans_finished = []
31
- super().__init__(parent)
32
-
33
- def processing_finished(self, scan):
34
- # TODO: add message processing finished
35
- self._scans_finished.append(scan)
36
-
37
- @property
38
- def scans_finished(self):
39
- return self._scans_finished
40
-
41
- def close(self):
42
- self._scans_finished = {}
43
- super().close()
44
-
45
-
46
- class TestProcessing(TestCaseQt):
47
- DIM = 100
48
-
49
- def setUp(self):
50
- super().setUp()
51
- self._source_dir = tempfile.mkdtemp()
52
-
53
- def create_scan(folder_name):
54
- _dir = os.path.join(self._source_dir, folder_name)
55
- return MockNXtomo(
56
- scan_path=_dir,
57
- n_ini_proj=20,
58
- n_proj=20,
59
- n_alignement_proj=2,
60
- create_final_flat=False,
61
- create_ini_dark=True,
62
- create_ini_flat=True,
63
- n_refs=1,
64
- dim=self.DIM,
65
- ).scan
66
-
67
- # create scans
68
- self.scan_1 = create_scan("scan_1")
69
- self.scan_2 = create_scan("scan_2")
70
- self.scan_3 = create_scan("scan_3")
71
- self._process_manager = ProcessManager()
72
-
73
- self.widget = SADeltaBetaOW()
74
- self.widget.show()
75
-
76
- def patch_score(cor):
77
- data = numpy.random.random(TestProcessing.DIM * TestProcessing.DIM)
78
- data = data.reshape(TestProcessing.DIM, TestProcessing.DIM)
79
- slice_file_path = os.path.join(
80
- self._source_dir, str(uuid.uuid1()) + ".hdf5"
81
- )
82
- data_url = DataUrl(
83
- file_path=slice_file_path, data_path="data", scheme="silx"
84
- )
85
- with h5py.File(slice_file_path, mode="a") as h5f:
86
- h5f["data"] = data
87
- return data_url, ComputedScore(
88
- tv=numpy.random.random(),
89
- std=numpy.random.random(),
90
- )
91
-
92
- self.widget._widget._processing_stack.patch_processing(patch_score)
93
-
94
- def tearDown(self):
95
- mock_low_memory(False)
96
- settings.mock_lsbram(False)
97
- self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
98
- self.widget.close()
99
- self.widget = None
100
- self.qapp.processEvents()
101
- shutil.rmtree(self._source_dir)
102
- gc.collect()
103
-
104
- def test_serializing(self):
105
- pickle.dumps(self.widget.getConfiguration())
106
-
107
- def test_literal_dumps(self):
108
- literal_dumps(self.widget.getConfiguration())
109
-
110
- def testAutoFocusUnlock(self):
111
- self.widget.lockAutofocus(False)
112
-
113
- def manual_processing():
114
- self.widget.compute()
115
- self.qapp.processEvents()
116
- self.widget.wait_processing(5000)
117
- self.qapp.processEvents()
118
-
119
- self.widget.process(self.scan_1)
120
- manual_processing()
121
- self.assertEqual(
122
- self._process_manager.get_dataset_state(
123
- dataset_id=self.scan_1.get_identifier(),
124
- process=self.widget,
125
- ),
126
- DatasetState.WAIT_USER_VALIDATION,
127
- )
128
-
129
- self.widget.process(self.scan_2)
130
- manual_processing()
131
- self.assertEqual(len(self.widget.scans_finished), 0)
132
- self.assertEqual(
133
- self._process_manager.get_dataset_state(
134
- dataset_id=self.scan_1.get_identifier(),
135
- process=self.widget,
136
- ),
137
- DatasetState.SKIPPED,
138
- )
139
- self.assertEqual(
140
- self._process_manager.get_dataset_state(
141
- dataset_id=self.scan_2.get_identifier(),
142
- process=self.widget,
143
- ),
144
- DatasetState.WAIT_USER_VALIDATION,
145
- )
146
- self.widget.process(self.scan_3)
147
- manual_processing()
148
- self.widget.validateCurrentScan()
149
- self.assertEqual(
150
- self._process_manager.get_dataset_state(
151
- dataset_id=self.scan_3.get_identifier(),
152
- process=self.widget,
153
- ),
154
- DatasetState.SUCCEED,
155
- )
156
- # insure a cor has been registered
157
- self.assertNotEqual(
158
- self.scan_3.sa_delta_beta_params.selected_delta_beta_value, None
159
- )
160
-
161
- def testTestLbsram(self):
162
- mock_low_memory(True)
163
- settings.mock_lsbram(True)
164
- for scan in (self.scan_1, self.scan_2, self.scan_3):
165
- self.widget.process(scan)
166
- self.widget.wait_processing(5000)
167
- self.qapp.processEvents()
168
-
169
- for scan in (self.scan_1, self.scan_2, self.scan_3):
170
- with self.subTest(scan=str(scan)):
171
- self.assertEqual(
172
- self._process_manager.get_dataset_state(
173
- dataset_id=scan.get_identifier(),
174
- process=self.widget,
175
- ),
176
- DatasetState.SKIPPED,
177
- )
178
-
179
- def testAutoFocusLock(self):
180
- self.widget.lockAutofocus(True)
181
- for scan in (self.scan_1, self.scan_2, self.scan_3):
182
- self.widget.process(scan)
183
- self.widget.wait_processing(5000)
184
- self.qapp.processEvents()
185
-
186
- for scan in (self.scan_1, self.scan_2, self.scan_3):
187
- with self.subTest(scan=str(scan)):
188
- self.assertEqual(
189
- self._process_manager.get_dataset_state(
190
- dataset_id=scan.get_identifier(),
191
- process=self.widget,
192
- ),
193
- DatasetState.SUCCEED,
194
- )
@@ -1,220 +0,0 @@
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/04/2021"
29
-
30
- import gc
31
- import logging
32
- import os
33
- import pickle
34
- import shutil
35
- import tempfile
36
- import time
37
- import uuid
38
-
39
- import h5py
40
- import numpy
41
- from orangecanvas.scheme.readwrite import literal_dumps
42
- from processview.core.manager import DatasetState, ProcessManager
43
- from silx.gui import qt
44
- from silx.gui.utils.testutils import TestCaseQt
45
- from silx.io.url import DataUrl
46
-
47
- from orangecontrib.tomwer.widgets.reconstruction.SAAxisOW import SAAxisOW as _SAAxisOW
48
- from tomwer.core import settings
49
- from tomwer.core.utils.lbsram import mock_low_memory
50
- from tomwer.core.process.reconstruction.scores import ComputedScore
51
- from tomwer.core.utils.scanutils import MockNXtomo
52
-
53
- logger = logging.getLogger(__name__)
54
-
55
-
56
- class SAAxisOW(_SAAxisOW):
57
- def __init__(self, parent=None):
58
- self._scans_finished = []
59
- super().__init__(parent)
60
-
61
- def processing_finished(self, scan):
62
- # TODO: add message processing finished
63
- self._scans_finished.append(scan)
64
-
65
- @property
66
- def scans_finished(self):
67
- return self._scans_finished
68
-
69
- def close(self):
70
- self._scans_finished = {}
71
- super().close()
72
-
73
-
74
- class TestProcessing(TestCaseQt):
75
- DIM = 100
76
-
77
- def setUp(self):
78
- super().setUp()
79
- self._source_dir = tempfile.mkdtemp()
80
-
81
- def create_scan(folder_name):
82
- _dir = os.path.join(self._source_dir, folder_name)
83
- return MockNXtomo(
84
- scan_path=_dir,
85
- n_ini_proj=20,
86
- n_proj=20,
87
- n_alignement_proj=2,
88
- create_final_flat=False,
89
- create_ini_dark=True,
90
- create_ini_flat=True,
91
- n_refs=1,
92
- dim=self.DIM,
93
- ).scan
94
-
95
- # create scans
96
- self.scan_1 = create_scan("scan_1")
97
- self.scan_2 = create_scan("scan_2")
98
- self.scan_3 = create_scan("scan_3")
99
- self._process_manager = ProcessManager()
100
-
101
- self.widget = SAAxisOW()
102
- self.widget.show()
103
-
104
- def patch_score(*args, **kwargs):
105
- data = numpy.random.random(TestProcessing.DIM * TestProcessing.DIM)
106
- data = data.reshape(TestProcessing.DIM, TestProcessing.DIM)
107
- slice_file_path = os.path.join(
108
- self._source_dir, str(uuid.uuid1()) + ".hdf5"
109
- )
110
- data_url = DataUrl(
111
- file_path=slice_file_path, data_path="data", scheme="silx"
112
- )
113
- with h5py.File(slice_file_path, mode="a") as h5f:
114
- h5f["data"] = data
115
- return data_url, ComputedScore(
116
- tv=numpy.random.random(),
117
- std=numpy.random.random(),
118
- )
119
-
120
- self.widget._widget._processing_stack.patch_processing(patch_score)
121
-
122
- def tearDown(self):
123
- mock_low_memory(False)
124
- settings.mock_lsbram(False)
125
- self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
126
- self.widget.close()
127
- self.widget = None
128
- self.qapp.processEvents()
129
- shutil.rmtree(self._source_dir)
130
- gc.collect()
131
-
132
- def test_serializing(self):
133
- pickle.dumps(self.widget.getConfiguration())
134
-
135
- def test_literal_dumps(self):
136
- literal_dumps(self.widget.getConfiguration())
137
-
138
- def testAutoFocusUnlock(self):
139
- self.widget.lockAutofocus(False)
140
-
141
- def manual_processing():
142
- self.widget.load_sinogram()
143
- self.widget.compute()
144
- self.qapp.processEvents()
145
- self.widget.wait_processing(5000)
146
- self.qapp.processEvents()
147
-
148
- self.widget.process(self.scan_1)
149
- manual_processing()
150
- self.assertEqual(
151
- self._process_manager.get_dataset_state(
152
- dataset_id=self.scan_1.get_identifier(),
153
- process=self.widget,
154
- ),
155
- DatasetState.WAIT_USER_VALIDATION,
156
- )
157
-
158
- self.widget.process(self.scan_2)
159
- manual_processing()
160
- self.assertEqual(len(self.widget.scans_finished), 0)
161
- self.assertEqual(
162
- self._process_manager.get_dataset_state(
163
- dataset_id=self.scan_1.get_identifier(),
164
- process=self.widget,
165
- ),
166
- DatasetState.SKIPPED,
167
- )
168
- self.assertEqual(
169
- self._process_manager.get_dataset_state(
170
- dataset_id=self.scan_2.get_identifier(),
171
- process=self.widget,
172
- ),
173
- DatasetState.WAIT_USER_VALIDATION,
174
- )
175
- self.widget.process(self.scan_3)
176
- manual_processing()
177
- self.widget.validateCurrentScan()
178
- self.assertEqual(
179
- self._process_manager.get_dataset_state(
180
- dataset_id=self.scan_3.get_identifier(),
181
- process=self.widget,
182
- ),
183
- DatasetState.SUCCEED,
184
- )
185
- # insure a cor has been registered
186
- self.assertNotEqual(self.scan_3.axis_params.relative_cor_value, None)
187
-
188
- def testTestLbsram(self):
189
- mock_low_memory(True)
190
- settings.mock_lsbram(True)
191
- for scan in (self.scan_1, self.scan_2, self.scan_3):
192
- self.widget.process(scan)
193
- self.widget.wait_processing(5000)
194
- self.qapp.processEvents()
195
-
196
- for scan in (self.scan_1, self.scan_2, self.scan_3):
197
- with self.subTest(scan=str(scan)):
198
- self.assertEqual(
199
- self._process_manager.get_dataset_state(
200
- dataset_id=scan.get_identifier(),
201
- process=self.widget,
202
- ),
203
- DatasetState.SKIPPED,
204
- )
205
-
206
- def testAutoFocusLock(self):
207
- self.widget.lockAutofocus(True)
208
- for scan in (self.scan_1, self.scan_2, self.scan_3):
209
- self.widget.process(scan)
210
- self.widget.wait_processing(10000)
211
- self.qapp.processEvents()
212
- time.sleep(0.1)
213
- self.qapp.processEvents()
214
- self.assertEqual(
215
- self._process_manager.get_dataset_state(
216
- dataset_id=scan.get_identifier(),
217
- process=self.widget,
218
- ),
219
- DatasetState.SUCCEED,
220
- )