8000 And some more broadcasting. · matplotlib/matplotlib@6385ccf · GitHub
[go: up one dir, main page]

Skip to content

Commit 6385ccf

Browse files
committed
And some more broadcasting.
1 parent 8c7fab7 commit 6385ccf

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,16 +3175,10 @@ def errorbar(self, x, y, yerr=None, xerr=None,
31753175
caplines = []
31763176

31773177
# arrays fine here, they are booleans and hence not units
3178-
def _bool_asarray_helper(d, expected):
3179-
if not iterable(d):
3180-
return np.asarray([d] * expected, bool)
3181-
else:
3182-
return np.asarray(d, bool)
3183-
3184-
lolims = _bool_asarray_helper(lolims, len(x))
3185-
uplims = _bool_asarray_helper(uplims, len(x))
3186-
xlolims = _bool_asarray_helper(xlolims, len(x))
3187-
xuplims = _bool_asarray_helper(xuplims, len(x))
3178+
lolims = np.broadcast_to(lolims, len(x)).astype(bool)
3179+
uplims = np.broadcast_to(uplims, len(x)).astype(bool)
3180+
xlolims = np.broadcast_to(xlolims, len(x)).astype(bool)
3181+
xuplims = np.broadcast_to(xuplims, len(x)).astype(bool)
31883182

31893183
everymask = np.arange(len(x)) % errorevery == 0
31903184

@@ -3216,9 +3210,9 @@ def extract_err(err, data):
32163210
else:
32173211
if iterable(a) and iterable(b):
32183212
# using list comps rather than arrays to preserve units
3219-
low = [thisx - thiserr for (thisx, thiserr)
3213+
low = [thisx - thiserr for thisx, thiserr
32203214
in cbook.safezip(data, a)]
3221-
high = [thisx + thiserr for (thisx, thiserr)
3215+
high = [thisx + thiserr for thisx, thiserr
32223216
in cbook.safezip(data, b)]
32233217
return low, high
32243218
# Check if xerr is scalar or symmetric. Asymmetric is handled
@@ -3227,13 +3221,13 @@ def extract_err(err, data):
32273221
# special case for empty lists
32283222
if len(err) > 1:
32293223
fe = safe_first_element(err)
3230-
if (len(err) != len(data) or np.size(fe) > 1):
3224+
if len(err) != len(data) or np.size(fe) > 1:
32313225
raise ValueError("err must be [ scalar | N, Nx1 "
32323226
"or 2xN array-like ]")
32333227
# using list comps rather than arrays to preserve units
3234-
low = [thisx - thiserr for (thisx, thiserr)
3228+
low = [thisx - thiserr for thisx, thiserr
32353229
in cbook.safezip(data, err)]
3236-
high = [thisx + thiserr for (thisx, thiserr)
3230+
high = [thisx + thiserr for thisx, thiserr
32373231
in cbook.safezip(data, err)]
32383232
return low, high
32393233

0 commit comments

Comments
 (0)
0