10000 MNT: slightly simplify conditional in errorbar · matplotlib/matplotlib@e67b42b · GitHub
[go: up one dir, main page]

Skip to content

Commit e67b42b

Browse files
committed
MNT: slightly simplify conditional in errorbar
This slightly simplifies the special casing of empty list in the handling of xerr and yerr in errorbar
1 parent a4e3694 commit e67b42b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,10 +2890,8 @@ def xywhere(xs, ys, mask):
28902890
# above. This prevents Nx2 arrays from accidentally
28912891
# being accepted, when the user meant the 2xN transpose.
28922892
# special case for empty lists
2893-
if len(xerr) and not (len(xerr) == 1 or
2894-
(len(xerr) == len(x) and not (
2895-
iterable(xerr[0]) and
2896-
len(xerr[0]) > 1))):
2893+
if len(xerr) > 1 and not ((len(xerr) == len(x) and not (
2894+
iterable(xerr[0]) and len(xerr[0]) > 1))):
28972895
raise ValueError("xerr must be a scalar, the same "
28982896
"dimensions as x, or 2xN.")
28992897
# using list comps rather than arrays to preserve units
@@ -2955,10 +2953,8 @@ def xywhere(xs, ys, mask):
29552953
in cbook.safezip(y, yerr[1])]
29562954
else:
29572955
# Check for scalar or symmetric, as in xerr.
2958-
if len(yerr) and not (len(yerr) == 1 or
2959-
(len(yerr) == len(y) and not (
2960-
iterable(yerr[0]) and
2961-
len(yerr[0]) > 1))):
2956+
if len(yerr) > 1 and not ((len(yerr) == len(y) and not (
2957+
iterable(yerr[0]) and len(yerr[0]) > 1))):
29622958
raise ValueError("yerr must be a scalar, the same "
29632959
"dimensions as y, or 2xN.")
29642960
# using list comps rather than arrays to preserve units

lib/matplotlib/tests/test_axes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4106,8 +4106,10 @@ def test_errorbar_inputs_shotgun():
41064106
[1, 1, 1, 1, 1],
41074107
[[1, 1, 1, 1, 1],
41084108
[1, 1, 1, 1, 1]],
4109+
[[1]] * 5,
41094110
np.ones(5),
41104111
np.ones((2, 5)),
4112+
np.ones((5, 1)),
41114113
None
41124114
])
41134115
xerr_cy = cycler('xerr', err_cycler)

0 commit comments

Comments
 (0)
0