From 7f63452ddf2821af42c6242c115d925f022a9c52 Mon Sep 17 00:00:00 2001 From: Scott Staniewicz Date: Sat, 25 Mar 2023 16:57:02 -0700 Subject: [PATCH 1/2] fix: dont check bool dtype until after ndarray conversion This appears to fix #411 --- proplot/internals/inputs.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/proplot/internals/inputs.py b/proplot/internals/inputs.py index a55d6e266..d369270a0 100644 --- a/proplot/internals/inputs.py +++ b/proplot/internals/inputs.py @@ -130,15 +130,16 @@ 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 else: - return np.atleast_1d(data) # natively preserves masked arrays + d = np.atleast_1d(data) # natively preserves masked arrays + if d.dtype == bool: + d = d.view(np.uint8) + return d def _to_masked_array(data, *, copy=False): From 7037decfade66cf8c1ee41ef7179203e1575ba78 Mon Sep 17 00:00:00 2001 From: Scott Staniewicz Date: Sat, 25 Mar 2023 17:02:56 -0700 Subject: [PATCH 2/2] add supporting unit test for fix #412 --- proplot/tests/test_axes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 proplot/tests/test_axes.py diff --git a/proplot/tests/test_axes.py b/proplot/tests/test_axes.py new file mode 100644 index 000000000..84c128af7 --- /dev/null +++ b/proplot/tests/test_axes.py @@ -0,0 +1,14 @@ +import pytest + +import numpy as np +import proplot as pplt + + +def test_axes_plot(): + """Test axes plots work with lists or arrays""" + x = np.arange(10) + fig, ax = pplt.subplots() + ax.plot(x) + ax.plot(x, x) + + ax.plot([1, 2, 3], [4, 5, 6])