Skip to content

Commit

Permalink
Fix boolean ndarray conversion bug (fixes #411)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukelbd committed Mar 26, 2023
1 parent 0b590bb commit 9b2834c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions proplot/internals/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,17 @@ def _to_numpy_array(data, strip_units=False):
data = data.data # support pint quantities that get unit-stripped later
elif isinstance(data, (DataFrame, Series, Index)):
data = data.values
if data.dtype == bool:
data = data.view(np.uint8)
if Quantity is not ndarray and isinstance(data, Quantity):
if strip_units:
return np.atleast_1d(data.magnitude)
else:
return np.atleast_1d(data.magnitude) * data.units
units = None if strip_units else data.units
data = data.magnitude
else:
return np.atleast_1d(data) # natively preserves masked arrays
units = None
data = np.atleast_1d(data) # natively preserves masked arrays
if np.issubdtype(data.dtype, bool):
data = data.view(np.uint8)
if units is not None:
data = data * units
return data


def _to_masked_array(data, *, copy=False):
Expand Down

0 comments on commit 9b2834c

Please sign in to comment.