Skip to content
Snippets Groups Projects
Commit 23dee235 authored by Harry Saunders's avatar Harry Saunders
Browse files

Make changes re review comments

Make sure __future__ imports are in every file
Use existing context manager to block QSignals
Rename artist_has_errorbars -> artists_workspace_has_errors
parent 1595c166
No related branches found
No related tags found
No related merge requests found
Showing
with 28 additions and 24 deletions
...@@ -311,8 +311,11 @@ class MantidAxes(Axes): ...@@ -311,8 +311,11 @@ class MantidAxes(Axes):
logger.warning("You are overlaying distribution and " logger.warning("You are overlaying distribution and "
"non-distribution data!") "non-distribution data!")
def artist_has_errorbars(self, artist): def artists_workspace_has_errors(self, artist):
"""Check if the given artist's workspace has errors""" """Check if the given artist's workspace has errors"""
if artist not in self.get_tracked_artists():
raise ValueError("Artist '{}' is not tracked and so does not have "
"an associated workspace.".format(artist))
workspace, spec_num = self.get_artists_workspace_and_spec_num(artist) workspace, spec_num = self.get_artists_workspace_and_spec_num(artist)
workspace_index = workspace.getIndexFromSpectrumNumber(spec_num) workspace_index = workspace.getIndexFromSpectrumNumber(spec_num)
if any(workspace.readE(workspace_index) != 0): if any(workspace.readE(workspace_index) != 0):
......
...@@ -23,15 +23,3 @@ class AddedToSysPath: ...@@ -23,15 +23,3 @@ class AddedToSysPath:
def __exit__(self, exc_type, exc_val, exc_tb): def __exit__(self, exc_type, exc_val, exc_tb):
sys.path = self.original_sys_path sys.path = self.original_sys_path
class BlockQSignals:
"""Context manager to block QSignals from a QObject"""
def __init__(self, qobject):
self.qobject = qobject
def __enter__(self):
self.qobject.blockSignals(True)
def __exit__(self, exc_type, exc_val, exc_tb):
self.qobject.blockSignals(False)
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
from matplotlib.axes import ErrorbarContainer from matplotlib.axes import ErrorbarContainer
from matplotlib.collections import QuadMesh from matplotlib.collections import QuadMesh
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
class AxProperties(dict): class AxProperties(dict):
""" """
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
from matplotlib import rcParams from matplotlib import rcParams
from matplotlib.axes import ErrorbarContainer from matplotlib.axes import ErrorbarContainer
from matplotlib.lines import Line2D from matplotlib.lines import Line2D
...@@ -118,12 +120,7 @@ def curve_has_errors(curve): ...@@ -118,12 +120,7 @@ def curve_has_errors(curve):
ax = get_ax_from_curve(curve) ax = get_ax_from_curve(curve)
if isinstance(ax, MantidAxes): if isinstance(ax, MantidAxes):
try: try:
workspace, spec_num = ax.get_artists_workspace_and_spec_num(curve) return ax.artists_workspace_has_errors(curve)
workspace_index = workspace.getIndexFromSpectrumNumber(spec_num)
if any(workspace.readE(workspace_index) != 0):
return True
else:
return False
except ValueError: # Value error raised if artist has no associated workspace except ValueError: # Value error raised if artist has no associated workspace
return False return False
if isinstance(curve, Line2D): if isinstance(curve, Line2D):
......
...@@ -5,3 +5,5 @@ ...@@ -5,3 +5,5 @@
# & Institut Laue - Langevin # & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
...@@ -5,3 +5,5 @@ ...@@ -5,3 +5,5 @@
# & Institut Laue - Langevin # & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
...@@ -5,3 +5,5 @@ ...@@ -5,3 +5,5 @@
# & Institut Laue - Langevin # & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
...@@ -13,7 +13,7 @@ from matplotlib.lines import Line2D ...@@ -13,7 +13,7 @@ from matplotlib.lines import Line2D
from mantid.plots import MantidAxes from mantid.plots import MantidAxes
from mantid.plots.helperfunctions import get_data_from_errorbar_container from mantid.plots.helperfunctions import get_data_from_errorbar_container
from mantidqt.utils import BlockQSignals from mantidqt.utils.qt import block_signals
from mantidqt.widgets.plotconfigdialog import get_axes_names_dict, curve_in_ax from mantidqt.widgets.plotconfigdialog import get_axes_names_dict, curve_in_ax
from mantidqt.widgets.plotconfigdialog.curvestabwidget import ( from mantidqt.widgets.plotconfigdialog.curvestabwidget import (
CurveProperties, set_curve_hidden, set_errorbars_hidden, curve_has_errors, CurveProperties, set_curve_hidden, set_errorbars_hidden, curve_has_errors,
...@@ -172,7 +172,7 @@ class CurvesTabWidgetPresenter: ...@@ -172,7 +172,7 @@ class CurvesTabWidgetPresenter:
on the axes remove the axes entry from the 'select_axes_combo_box'. If on the axes remove the axes entry from the 'select_axes_combo_box'. If
no axes with curves remain close the tab and return True no axes with curves remain close the tab and return True
""" """
with BlockQSignals(self.view.select_curve_combo_box): with block_signals(self.view.select_curve_combo_box):
self.view.remove_select_curve_combo_box_selected_item() self.view.remove_select_curve_combo_box_selected_item()
if self.view.select_curve_combo_box.count() == 0: if self.view.select_curve_combo_box.count() == 0:
self.view.remove_select_axes_combo_box_selected_item() self.view.remove_select_axes_combo_box_selected_item()
...@@ -230,7 +230,7 @@ class CurvesTabWidgetPresenter: ...@@ -230,7 +230,7 @@ class CurvesTabWidgetPresenter:
Return False if there are no lines on the axes (this can occur Return False if there are no lines on the axes (this can occur
when a user uses the "Remove Curve" button), else return True. when a user uses the "Remove Curve" button), else return True.
""" """
with BlockQSignals(self.view.select_curve_combo_box): with block_signals(self.view.select_curve_combo_box):
self.view.select_curve_combo_box.clear() self.view.select_curve_combo_box.clear()
selected_ax = self.get_selected_ax() selected_ax = self.get_selected_ax()
if not selected_ax: if not selected_ax:
......
...@@ -5,3 +5,5 @@ ...@@ -5,3 +5,5 @@
# & Institut Laue - Langevin # & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
import unittest import unittest
from matplotlib import use as mpl_use from matplotlib import use as mpl_use
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
from __future__ import (absolute_import, unicode_literals) from __future__ import (absolute_import, unicode_literals)
from mantidqt.utils import BlockQSignals from mantidqt.utils.qt import block_signals
from mantidqt.widgets.plotconfigdialog import generate_ax_name, get_images_from_fig from mantidqt.widgets.plotconfigdialog import generate_ax_name, get_images_from_fig
from mantidqt.widgets.plotconfigdialog.imagestabwidget import ImageProperties from mantidqt.widgets.plotconfigdialog.imagestabwidget import ImageProperties
from mantidqt.widgets.plotconfigdialog.imagestabwidget.view import ImagesTabWidgetView, SCALES from mantidqt.widgets.plotconfigdialog.imagestabwidget.view import ImagesTabWidgetView, SCALES
...@@ -45,7 +45,7 @@ class ImagesTabWidgetPresenter: ...@@ -45,7 +45,7 @@ class ImagesTabWidgetPresenter:
return self.image_names_dict[self.view.get_selected_image_name()] return self.image_names_dict[self.view.get_selected_image_name()]
def populate_select_image_combo_box_and_update_view(self): def populate_select_image_combo_box_and_update_view(self):
with BlockQSignals(self.view.select_image_combo_box): with block_signals(self.view.select_image_combo_box):
self._populate_select_image_combo_box() self._populate_select_image_combo_box()
self.update_view() self.update_view()
......
...@@ -5,3 +5,5 @@ ...@@ -5,3 +5,5 @@
# & Institut Laue - Langevin # & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 + # SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
from __future__ import (absolute_import, unicode_literals)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment