Skip to content

Commit

Permalink
Fix registration check
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujun98 committed Jul 20, 2020
1 parent 776b777 commit 44731cf
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 35 deletions.
2 changes: 1 addition & 1 deletion extra_foam/gui/ctrl_widgets/bin_ctrl_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def updateMetaData(self):
def loadMetaData(self):
"""Override."""
cfg = self._meta.hget_all(mt.BINNING_PROC)
if not cfg:
if "analysis_type" not in cfg:
# not initialized
return

Expand Down
2 changes: 1 addition & 1 deletion extra_foam/gui/ctrl_widgets/correlation_ctrl_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def updateMetaData(self):
def loadMetaData(self):
"""Override."""
cfg = self._meta.hget_all(mt.CORRELATION_PROC)
if not cfg:
if "analysis_type" not in cfg:
# not initialized
return

Expand Down
2 changes: 1 addition & 1 deletion extra_foam/gui/ctrl_widgets/histogram_ctrl_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def updateMetaData(self):
def loadMetaData(self):
"""Override."""
cfg = self._meta.hget_all(mt.HISTOGRAM_PROC)
if not cfg:
if "analysis_type" not in cfg:
# not initialized
return

Expand Down
2 changes: 1 addition & 1 deletion extra_foam/gui/ctrl_widgets/pump_probe_ctrl_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def updateMetaData(self):
def loadMetaData(self):
"""Override."""
cfg = self._meta.hget_all(mt.PUMP_PROBE_PROC)
if not cfg:
if "analysis_type" not in cfg:
# not initialized
return

Expand Down
49 changes: 22 additions & 27 deletions extra_foam/gui/tests/test_main_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,41 +71,36 @@ def testAnalysisCtrlWidget(self):
roi_proc = train_worker._image_roi
ai_proc = train_worker._ai_proc

# test various reset buttons
# test various reset_ma buttons

# tests of other reset buttons go to the respective unittest

meta = xgm_proc._meta # any meta is OK

with patch.object(roi_proc, "_reset_ma") as patched_reset_roi:
with patch.object(ai_proc, "_reset_ma") as patched_reset_ai:
with patch.object(xgm_proc, "_reset_ma") as patched_reset_xgm:
with patch.object(digitizer_proc, "_reset_ma") as patched_reset_digitizer:

def _check_reset_ma():
roi_proc.update()
patched_reset_roi.assert_called_once()
patched_reset_roi.reset_mock()
ai_proc.update()
patched_reset_ai.assert_called_once()
patched_reset_ai.reset_mock()
xgm_proc.update()
patched_reset_xgm.assert_called_once()
patched_reset_xgm.reset_mock()
digitizer_proc.update()
patched_reset_digitizer.assert_called_once()
patched_reset_digitizer.reset_mock()

widget._reset_ma_btn.clicked.emit()
roi_proc.update()
patched_reset_roi.assert_called_once()
ai_proc.update()
patched_reset_ai.assert_called_once()
xgm_proc.update()
patched_reset_xgm.assert_called_once()
digitizer_proc.update()
patched_reset_digitizer.assert_called_once()

# tests of reset button of pump-probe, correlation, binning and histogram
# go to the respective unittest

meta.hdel(mt.GLOBAL_PROC, 'reset_ma')
widget._reset_all_btn.clicked.emit()
self.assertEqual('1', meta.hget(mt.GLOBAL_PROC, 'reset_ma'))
self.assertEqual('1', meta.hget(mt.PUMP_PROBE_PROC, 'reset'))
self.assertEqual('1', meta.hget(mt.CORRELATION_PROC, 'reset1'))
self.assertEqual('1', meta.hget(mt.CORRELATION_PROC, 'reset2'))
self.assertEqual('1', meta.hget(mt.HISTOGRAM_PROC, 'reset'))
self.assertEqual('1', meta.hget(mt.BINNING_PROC, 'reset'))
meta.pipeline().execute_command(
'HDEL', mt.GLOBAL_PROC, 'reset_ma').execute_command(
'DEL', mt.PUMP_PROBE_PROC).execute_command(
'DEL', mt.CORRELATION_PROC).execute_command(
'DEL', mt.HISTOGRAM_PROC).execute_command(
'DEL', mt.BINNING_PROC).execute()
_check_reset_ma()

widget._reset_all_btn.clicked.emit()
_check_reset_ma()

# ----------------
# Test POI indices
Expand Down
15 changes: 15 additions & 0 deletions extra_foam/gui/windows/tests/test_plot_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ def _checkPumpProbeCtrlWidget(self, win):
pp_proc.update()
self.assertTrue(pp_proc._reset)
pp_proc._reset = False
self.gui.analysis_ctrl_widget._reset_all_btn.clicked.emit()
pp_proc.update()
self.assertTrue(pp_proc._reset)

# test loading meta data
mediator = widget._mediator
Expand Down Expand Up @@ -498,6 +501,10 @@ def _checkCorrelationCtrlWidget(self, win):
self.gui.analysis_ctrl_widget._reset_correlation_btn.clicked.emit()
proc.update()
self.assertTrue(proc._reset)
proc._reset = False
self.gui.analysis_ctrl_widget._reset_all_btn.clicked.emit()
proc.update()
self.assertTrue(proc._reset)

# test loading meta data
mediator = widget._mediator
Expand Down Expand Up @@ -656,6 +663,10 @@ def _checkBinCtrlWidget(self, win):
self.gui.analysis_ctrl_widget._reset_binning_btn.clicked.emit()
proc.update()
self.assertTrue(proc._reset)
proc._reset = False
self.gui.analysis_ctrl_widget._reset_all_btn.clicked.emit()
proc.update()
self.assertTrue(proc._reset)

# test "Auto level" button
win._bin1d_vfom._auto_level = False
Expand Down Expand Up @@ -741,6 +752,10 @@ def _checkHistogramCtrlWidget(self, win):
self.gui.analysis_ctrl_widget._reset_histogram_btn.clicked.emit()
proc.update()
self.assertTrue(proc._reset)
proc._reset = False
self.gui.analysis_ctrl_widget._reset_all_btn.clicked.emit()
proc.update()
self.assertTrue(proc._reset)

# test loading meta data
mediator = widget._mediator
Expand Down
2 changes: 1 addition & 1 deletion extra_foam/pipeline/processors/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def __init__(self):
def update(self):
"""Override."""
cfg = self._meta.hget_all(mt.BINNING_PROC)
if not cfg:
if 'analysis_type' not in cfg:
# BinningWindow not initialized
return

Expand Down
2 changes: 1 addition & 1 deletion extra_foam/pipeline/processors/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def update(self):
"""Override."""
g_cfg, cfg = self._meta.hget_all_multi(
[mt.GLOBAL_PROC, mt.CORRELATION_PROC])
if not cfg:
if 'analysis_type' not in cfg:
# CorrelationWindow not initialized
return

Expand Down
2 changes: 1 addition & 1 deletion extra_foam/pipeline/processors/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self):
def update(self):
"""Override."""
cfg = self._meta.hget_all(mt.HISTOGRAM_PROC)
if not cfg:
if 'analysis_type' not in cfg:
# HistogramWindow not initialized
return

Expand Down
2 changes: 1 addition & 1 deletion extra_foam/pipeline/processors/pump_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self):
def update(self):
"""Override."""
cfg = self._meta.hget_all(mt.PUMP_PROBE_PROC)
if not cfg:
if 'analysis_type' not in cfg:
# PumpProbeWindow not initialized
return

Expand Down

0 comments on commit 44731cf

Please sign in to comment.