File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -130,15 +130,17 @@ def _to_numpy_array(data, strip_units=False):
130
130
data = data .data # support pint quantities that get unit-stripped later
131
131
elif isinstance (data , (DataFrame , Series , Index )):
132
132
data = data .values
133
- if data .dtype == bool :
134
- data = data .view (np .uint8 )
135
133
if Quantity is not ndarray and isinstance (data , Quantity ):
136
- if strip_units :
137
- return np .atleast_1d (data .magnitude )
138
- else :
139
- return np .atleast_1d (data .magnitude ) * data .units
134
+ units = None if strip_units else data .units
135
+ data = data .magnitude
140
136
else :
141
- return np .atleast_1d (data ) # natively preserves masked arrays
137
+ units = None
138
+ data = np .atleast_1d (data ) # natively preserves masked arrays
139
+ if np .issubdtype (data .dtype , bool ):
140
+ data = data .view (np .uint8 )
141
+ if units is not None :
142
+ data = data * units
143
+ return data
142
144
143
145
144
146
def _to_masked_array (data , * , copy = False ):
You can’t perform that action at this time.
0 commit comments