Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass back2 to RLData object #112

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading