Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c06ba77

Browse files
committed
Avoid unnecessary conversions to arrays.
These inputs may be ragged, but we only just need to know the length of the items. There's no need to make an array to check that.
1 parent a31a7e0 commit c06ba77

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,7 +3765,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
37653765
stats['med'] = med
37663766

37673767
if conf_intervals is not None:
3768-
if np.shape(conf_intervals)[0] != len(bxpstats):
3768+
if len(conf_intervals) != len(bxpstats):
37693769
raise ValueError(
37703770
"'conf_intervals' and 'x' have different lengths")
37713771
else:
@@ -6541,11 +6541,11 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
65416541
if histtype == 'barstacked' and not stacked:
65426542
stacked = True
65436543

6544-
# basic input validation
6545-
input_empty = np.size(x) == 0
65466544
# Massage 'x' for processing.
65476545
x = cbook._reshape_2D(x, 'x')
65486546
nx = len(x) # number of datasets
6547+
# basic input validation
6548+
input_empty = np.size(x) == 0
65496549

65506550
# Process unit information
65516551
# Unit conversion is done individually on each dataset

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ def include(gid, obj):
191191
elif obj.axes is None:
192192
return False
193193
if isinstance(obj, plt.Line2D):
194-
if np.array(obj.get_data()).shape == (2, 1):
194+
xdata, ydata = obj.get_data()
195+
if len(xdata) == len(ydata) == 1:
195196
return False
196197
elif not hasattr(obj, "axes") or obj.axes is None:
197198
return False

0 commit comments

Comments
 (0)