Skip to content

Commit 71f3ef3

Browse files
committed
Tidying up the data prep work in hist.
1 parent a537aaa commit 71f3ef3

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6122,22 +6122,21 @@ def _normalize_input(inp, ename='input'):
61226122
binsgiven = (cbook.iterable(bins) or bin_range is not None)
61236123

61246124
# basic input validation
6125-
flat = np.ravel(x)
6125+
input_empty = len(np.ravel(x)) == 0
61266126

6127-
input_empty = len(flat) == 0
6128-
6129-
# Massage 'x' for processing.
6127+
# Massage shape of 'x' to be a list of arrays
61306128
if input_empty:
6131-
x = np.array([[]])
6129+
x = [np.array([[]])]
61326130
else:
61336131
x = _normalize_input(x, 'x')
61346132
nx = len(x) # number of datasets
61356133

6136-
# We need to do to 'weights' what was done to 'x'
6137-
if weights is not None:
6138-
w = _normalize_input(weights, 'weights')
6139-
else:
6134+
# Massage shape of 'weights' to be a list, where each element
6135+
# weights[i] is either None or an array with the same shape as x[i]
6136+
if weights is None:
61406137
w = [None]*nx
6138+
else:
6139+
w = _normalize_input(weights, 'weights')
61416140

61426141
if len(w) != nx:
61436142
raise ValueError('weights should have the same shape as x')

0 commit comments

Comments
 (0)