From 86df4a2effdfeb0306c9b220e0a4758df7d2df6b Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Sat, 22 May 2021 12:50:49 +0200 Subject: [PATCH 1/2] Fix plotinit --- bliss/flint/manager/manager.py | 2 +- tests/qt/flint/manager/test_manager.py | 45 ++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/bliss/flint/manager/manager.py b/bliss/flint/manager/manager.py index 1271fb9966..596e3cf7c5 100755 --- a/bliss/flint/manager/manager.py +++ b/bliss/flint/manager/manager.py @@ -559,7 +559,7 @@ class ManageMainBehaviours(qt.QObject): if isinstance(plotModel, plot_item_model.CurvePlot): previousPlotModel = widget.plotModel() - if previousPlotModel is None: + if useDefaultPlot or previousPlotModel is None: pass else: userEditTime = previousPlotModel.userEditTime() diff --git a/tests/qt/flint/manager/test_manager.py b/tests/qt/flint/manager/test_manager.py index a5b39848dc..973b91341b 100644 --- a/tests/qt/flint/manager/test_manager.py +++ b/tests/qt/flint/manager/test_manager.py @@ -170,7 +170,7 @@ def test_consecutive_scans__user_selection(local_flint): scan = scan_info_helper.create_scan_model(loopscan_info) plots = scan_info_helper.create_plot_model(loopscan_info, scan) plot = [p for p in plots if isinstance(p, plot_item_model.CurvePlot)][0] - manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=True) + manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=False) model = widget.plotModel() assert len(model.items()) == 1 @@ -189,7 +189,7 @@ def test_consecutive_scans__user_selection(local_flint): scan = scan_info_helper.create_scan_model(ascan_info) plots = scan_info_helper.create_plot_model(ascan_info, scan) plot = [p for p in plots if isinstance(p, plot_item_model.CurvePlot)][0] - manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=True) + manager.updateWidgetWithPlot(widget, scan, plot, useDefaultPlot=False) model = widget.plotModel() assert len(model.items()) == 2 @@ -230,6 +230,47 @@ def test_consecutive_scans__ascan_ascan(local_flint): assert item.xChannel().name() == "axis:sy" +def test_curve_plot__enforced_channel_from_scan_info(local_flint): + """ + Test a new plot with enforced channel (plotinit) + + We expect the channel from the scan_info to be used, + anyway the user selection was done on the previous plot + """ + flint = flint_model.FlintState() + workspace = flint_model.Workspace() + flint.setWorkspace(workspace) + widget = CurvePlotWidget() + workspace.addWidget(widget) + + manager = ManageMainBehaviours() + manager.setFlintModel(flint) + + ascan_info = _create_ascan_scan_info("axis:sx", "axis:sy") + scan = scan_info_helper.create_scan_model(ascan_info) + plots = scan_info_helper.create_plot_model(ascan_info, scan) + manager.updateScanAndPlots(scan, plots) + + enforced_channel = "axis:sy" + + # Enforce a user selection + plotModel = widget.plotModel() + plotModel.tagUserEditTime() + item = plotModel.items()[0] + # Make sure the following test have meaning + assert item.yChannel().name() != enforced_channel + + ascan_info = _create_ascan_scan_info("axis:sy", "axis:sx") + ascan_info["_display_extra"] = {"displayed_channels": [enforced_channel]} + scan = scan_info_helper.create_scan_model(ascan_info) + plots = scan_info_helper.create_plot_model(ascan_info, scan) + manager.updateScanAndPlots(scan, plots) + + plotModel = widget.plotModel() + item = plotModel.items()[0] + assert item.yChannel().name() == enforced_channel + + def test_plot_with_new_roi(local_flint): """Test the resulted image plot when a new ROI is part of the scan. -- GitLab From 217d24feffde326a68b1b85e2b8ad1c09029b454 Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Sat, 22 May 2021 12:57:33 +0200 Subject: [PATCH 2/2] Typo on test names --- tests/qt/flint/manager/test_manager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qt/flint/manager/test_manager.py b/tests/qt/flint/manager/test_manager.py index 973b91341b..c68f9b4212 100644 --- a/tests/qt/flint/manager/test_manager.py +++ b/tests/qt/flint/manager/test_manager.py @@ -120,7 +120,7 @@ def _create_lima_scan_info(include_roi2): return result -def test_consecutive_scans__loopscan_ascan(local_flint): +def test_curve_plot__from_loopscan_to_ascan(local_flint): """ Test plot state with consecutive scans @@ -151,7 +151,7 @@ def test_consecutive_scans__loopscan_ascan(local_flint): assert item.xChannel().name() == "axis:sx" -def test_consecutive_scans__user_selection(local_flint): +def test_curve_plot__user_selection(local_flint): """ Test plot state with consecutive scans and a user selection in between @@ -195,7 +195,7 @@ def test_consecutive_scans__user_selection(local_flint): assert len(model.items()) == 2 -def test_consecutive_scans__ascan_ascan(local_flint): +def test_curve_plot__ascan_axis_updated(local_flint): """ Test plot state with consecutive scans @@ -271,7 +271,7 @@ def test_curve_plot__enforced_channel_from_scan_info(local_flint): assert item.yChannel().name() == enforced_channel -def test_plot_with_new_roi(local_flint): +def test_image_plot_with_new_roi(local_flint): """Test the resulted image plot when a new ROI is part of the scan. We expect: -- GitLab