Skip to content

Commit d0c5321

Browse files
committed
replace collections.Sized check with np.size to better handle masked elements in errorbar
1 parent 91f9670 commit d0c5321

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import six
55
from six.moves import xrange, zip, zip_longest
66

7-
from collections import Sized
87
import functools
98
import itertools
109
import math
@@ -3020,8 +3019,7 @@ def extract_err(err, data):
30203019
# special case for empty lists
30213020
if len(err) > 1:
30223021
fe = safe_first_element(err)
3023-
if (len(err) != len(data)
3024-
or isinstance(fe, Sized) and len(fe) > 1):
3022+
if (len(err) != len(data) or np.size(fe) > 1):
30253023
raise ValueError("err must be [ scalar | N, Nx1 "
30263024
"or 2xN array-like ]")
30273025
# using list comps rather than arrays to preserve units

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,7 @@ def safe_first_element(obj):
23112311
pass
23122312
raise RuntimeError("matplotlib does not support generators "
23132313
"as input")
2314-
return next(filter(lambda e: not np.ma.is_masked(e), iter(obj)))
2314+
return next(iter(obj))
23152315

23162316

23172317
def sanitize_sequence(data):

0 commit comments

Comments
 (0)