@@ -6091,13 +6091,24 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6091
6091
"Please only use 'density', since 'normed'"
6092
6092
"will be deprecated." )
6093
6093
6094
+ # basic input validation
6095
+ input_empty = np .size (x ) == 0
6096
+ # Massage 'x' for processing.
6097
+ if input_empty :
6098
+ x = np .array ([[]])
6099
+ else :
6100
+ x = cbook ._reshape_2D (x , 'x' )
6101
+ nx = len (x ) # number of datasets
6102
+
6094
6103
# Process unit information
6095
6104
# If doing a stacked histogram, the input is a list of datasets, so
6096
6105
# we need to do the unit conversion individually on eaach dataset
6097
6106
if stacked :
6098
6107
self ._process_unit_info (xdata = x [0 ], kwargs = kwargs )
6099
- for i , xi in enumerate (x ):
6100
- x [i ] = self .convert_xunits (xi )
6108
+ newx = []
6109
+ for xi in x :
6110
+ newx .append (self .convert_xunits (xi ))
6111
+ x = newx
6101
6112
else :
6102
6113
self ._process_unit_info (xdata = x , kwargs = kwargs )
6103
6114
x = self .convert_xunits (x )
@@ -6108,15 +6119,6 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6108
6119
# Check whether bins or range are given explicitly.
6109
6120
binsgiven = (cbook .iterable (bins ) or bin_range is not None )
6110
6121
6111
- # basic input validation
6112
- input_empty = np .size (x ) == 0
6113
-
6114
- # Massage 'x' for processing.
6115
- if input_empty :
6116
- x = np .array ([[]])
6117
- else :
6118
- x = cbook ._reshape_2D (x , 'x' )
6119
- nx = len (x ) # number of datasets
6120
6122
6121
6123
# We need to do to 'weights' what was done to 'x'
6122
6124
if weights is not None :
0 commit comments