Skip to content

Commit

Permalink
Merge pull request #35497 from mantidproject/35495_error_bars_from_sc…
Browse files Browse the repository at this point in the history
…ript

Fix for bug error bars plot options crash
  • Loading branch information
thomashampson authored May 4, 2023
2 parents 37aa327 + 6b1786d commit 61cf57d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/source/release/v6.7.0/Workbench/Bugfixes/35495.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed bug where opening the plot options for a script-created plot with error bars, would crash Workbench.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def _get_errorbars_props_from_curve(curve, props):
try:
barlines = curve[2][0]
props["errorevery"] = int(barlines.axes.creation_args[len(barlines.axes.creation_args) - 1]["errorevery"])
except (IndexError, TypeError, KeyError):
except (IndexError, TypeError, KeyError, AttributeError):
props["errorevery"] = 1
try:
caps = curve[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# This file is part of the mantid workbench.

import unittest
import numpy as np
from matplotlib import use as mpl_use

mpl_use("Agg") # noqa
Expand Down Expand Up @@ -120,3 +121,17 @@ def test_curve_hidden_on_errorbar_container(self):
# Now hide connecting line
container[0].set_visible(False)
self.assertTrue(funcs.curve_hidden(container))

def test_error_bars_with_no_creation_args_are_handled(self):
fig = figure()
x = np.arange(10)
y = 2.5 * np.sin(x / 20 * np.pi)
yerr = np.linspace(0.05, 0.2, 10)
ax = fig.add_subplot()
ax.errorbar(x, y, yerr=yerr)

try:
CurveProperties.from_curve(ax.get_lines()[0])
CurveProperties.from_curve(ax.containers[0])
except RuntimeError:
self.fail()

0 comments on commit 61cf57d

Please sign in to comment.