Skip to content

Commit a4c629b

Browse files
committed
don't fail on test_units.py
1 parent 47cb972 commit a4c629b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,13 +3284,20 @@ def errorbar(self, x, y, yerr=None, xerr=None,
32843284
if len(x) != len(y):
32853285
raise ValueError("'x' and 'y' must have the same size")
32863286

3287-
if xerr is not None and np.any(xerr < 0):
3288-
if yerr is not None and np.any(yerr < 0):
3287+
def check_if_negative(array):
3288+
try:
3289+
if np.any(array < 0):
3290+
return True
3291+
except:
3292+
pass
3293+
3294+
if xerr is not None and check_if_negative(xerr):
3295+
if yerr is not None and check_if_negative(yerr):
32893296
raise ValueError(
32903297
"'xerr' and 'yerr' must have positive numbers")
32913298
else:
32923299
raise ValueError("'xerr' must have positive numbers")
3293-
if yerr is not None and np.any(yerr < 0):
3300+
if check_if_negative(yerr):
32943301
raise ValueError("'yerr' must have positive numbers")
32953302

32963303
if isinstance(errorevery, Integral):

0 commit comments

Comments
 (0)