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

Skip to content

Commit d0c86a3

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 00ce0e0 commit d0c86a3

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
@@ -3778,7 +3778,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
37783778
stats['med'] = med
37793779

37803780
if conf_intervals is not None:
3781-
if np.shape(conf_intervals)[0] != len(bxpstats):
3781+
if len(conf_intervals) != len(bxpstats):
37823782
raise ValueError(
37833783
"'conf_intervals' and 'x' have different lengths")
37843784
else:
@@ -6555,11 +6555,11 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
65556555
if histtype == 'barstacked' and not stacked:
65566556
stacked = True
65576557

6558-
# basic input validation
6559-
input_empty = np.size(x) == 0
65606558
# Massage 'x' for processing.
65616559
x = cbook._reshape_2D(x, 'x')
65626560
nx = len(x) # number of datasets
6561+
# basic input validation
6562+
input_empty = np.size(x) == 0
65636563

65646564
# Process unit information
65656565
# 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)