Skip to content

Commit

Permalink
pass back2 to RLData object (#112)
Browse files Browse the repository at this point in the history
* pass back2 to RLData object
  • Loading branch information
jmborr authored Mar 4, 2024
1 parent e3d7476 commit 550454c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
15 changes: 10 additions & 5 deletions RefRed/configuration/load_reduction_table_from_lconfigdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ def update_lrdata(self, lrdata=None, lconfig=None, type='data', row=0):
if type == 'data':
peak1 = int(lconfig.data_peak[0])
peak2 = int(lconfig.data_peak[1])
back1 = int(lconfig.data_back[0])
back2 = int(lconfig.data_back[1])
back1_1 = int(lconfig.data_back[0])
back1_2 = int(lconfig.data_back[1])
back2_1 = int(lconfig.data_back2[0])
back2_2 = int(lconfig.data_back2[1])
back_flag = lconfig.data_back_flag
functional_background = lconfig.data_functional_background
two_backgrounds = lconfig.data_two_backgrounds
Expand All @@ -108,8 +110,10 @@ def update_lrdata(self, lrdata=None, lconfig=None, type='data', row=0):
else:
peak1 = int(lconfig.norm_peak[0])
peak2 = int(lconfig.norm_peak[1])
back1 = int(lconfig.norm_back[0])
back2 = int(lconfig.norm_back[1])
back1_1 = int(lconfig.norm_back[0])
back1_2 = int(lconfig.norm_back[1])
back2_1 = int(lconfig.norm_back2[0])
back2_2 = int(lconfig.norm_back2[1])
back_flag = lconfig.norm_back_flag
functional_background = lconfig.norm_functional_background
two_backgrounds = lconfig.norm_two_backgrounds
Expand All @@ -123,7 +127,8 @@ def update_lrdata(self, lrdata=None, lconfig=None, type='data', row=0):

# using lconfig values
lrdata.peak = [peak1, peak2]
lrdata.back = [back1, back2]
lrdata.back = [back1_1, back1_2]
lrdata.back2 = [back2_1, back2_2]
lrdata.back_flag = back_flag
lrdata.functional_background = functional_background
lrdata.two_backgrounds = two_backgrounds
Expand Down
38 changes: 9 additions & 29 deletions test/ui/test_reduce_and_export_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# RefRed imports
from RefRed.main import MainGui
from RefRed.configuration.loading_configuration import LoadingConfiguration


wait = 200
Expand Down Expand Up @@ -74,23 +75,10 @@ def test_reduce_and_export_data(qtbot, tmp_path, data_server, case):

window = MainGui()
qtbot.addWidget(window)
window.show() # Only for human inspection. This line should be commented once the test passes

# Open file menu, move down two and select Load
action_rect = window.ui.menubar.actionGeometry(window.ui.menuFile.menuAction())
qtbot.mouseClick(window.ui.menubar, QtCore.Qt.LeftButton, pos=action_rect.center())
qtbot.wait(wait)
qtbot.keyClick(window.ui.menuFile, QtCore.Qt.Key_Down)
qtbot.wait(wait)
qtbot.keyClick(window.ui.menuFile, QtCore.Qt.Key_Down)
qtbot.wait(wait)
with mock.patch("RefRed.configuration.loading_configuration.QFileDialog.exec_") as mock_exec:
mock_exec.return_value = True
with mock.patch("RefRed.configuration.loading_configuration.QFileDialog.selectedFiles") as mock_selectedFiles:
mock_selectedFiles.return_value = data_server.path_to(case["conf"])
qtbot.keyClick(window.ui.menuFile, QtCore.Qt.Key_Enter) # trigger execution of LoadingConfiguration.run()
qtbot.waitUntil(lambda: window.ui.statusbar.currentMessage() == "Done!")
qtbot.wait(wait)
# window.show() # Only for human inspection. This line should be commented once the test passes
loader = LoadingConfiguration(parent=window)
loader.check_config_file(data_server.path_to(case["conf"]))
loader.loading()

# Press button to plot first row of data
qtbot.mouseClick(window.ui.reductionTable.cellWidget(0, 0), QtCore.Qt.LeftButton, pos=QtCore.QPoint(10, 9))
Expand All @@ -103,9 +91,9 @@ def test_reduce_and_export_data(qtbot, tmp_path, data_server, case):
except AttributeError: # example, key=="conf"
pass

# Push Reduce button
qtbot.mouseClick(window.ui.reduceButton, QtCore.Qt.LeftButton)
qtbot.waitUntil(lambda: window.ui.statusbar.currentMessage() == "Done!")
# Push Reduce button, wait 10000 miliseconds for reduction to finish
window.ui.reduceButton.click()
qtbot.waitUntil(lambda: window.ui.statusbar.currentMessage() == "Done!", timeout=10000) # wait for one minute

# check that we have moved to the "Data Stitching" tab
assert window.ui.plotTab.currentIndex() == 1
Expand All @@ -132,17 +120,9 @@ def test_reduce_and_export_data(qtbot, tmp_path, data_server, case):
# export the reduction script
(tmp_path / "output.txt").unlink()

# In the Menu bar of the main window, click on "Reduction", then in "Export Script"
action_rect = window.ui.menubar.actionGeometry(window.ui.menuReduction.menuAction())
qtbot.mouseClick(window.ui.menubar, QtCore.Qt.LeftButton, pos=action_rect.center())
qtbot.wait(wait)
qtbot.keyClick(window.ui.menuReduction, QtCore.Qt.Key_Down)
qtbot.wait(wait)
qtbot.keyClick(window.ui.menuReduction, QtCore.Qt.Key_Down)
qtbot.wait(wait)
with mock.patch("RefRed.export.export_plot_ascii.QFileDialog.getSaveFileName") as mock_getSaveFileName:
mock_getSaveFileName.return_value = (str(tmp_path / "output.txt"), "")
qtbot.keyClick(window.ui.menuReduction, QtCore.Qt.Key_Enter)
window.export_reduction_script_button()
qtbot.wait(wait)

reduction_script = open(tmp_path / "output.txt").readlines()
Expand Down

2 comments on commit 550454c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for refred-dev has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/533522"

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for refred-qa has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/533609"

Please sign in to comment.