From 5c0953d676e900282e0e25cb2e4d93454d155d2c Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Fri, 27 Feb 2026 13:35:08 -0700 Subject: [PATCH] Add ExtensionArray to array_like --- gemd/__version__.py | 2 +- gemd/entity/util.py | 4 +++- pyproject.toml | 8 ++++---- tests/entity/bounds/test_categorical_bounds.py | 5 ++++- tests/entity/bounds/test_composition_bounds.py | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gemd/__version__.py b/gemd/__version__.py index f394e699..62fa04d7 100644 --- a/gemd/__version__.py +++ b/gemd/__version__.py @@ -1 +1 @@ -__version__ = "2.2.3" +__version__ = "2.2.4" diff --git a/gemd/entity/util.py b/gemd/entity/util.py index 4d445266..035a3e4c 100644 --- a/gemd/entity/util.py +++ b/gemd/entity/util.py @@ -88,7 +88,9 @@ def array_like(): import numpy as np try: import pandas as pd - _array_like = (list, tuple, np.ndarray, pd.core.base.PandasObject) + _array_like = (list, tuple, np.ndarray, + pd.core.base.PandasObject, + pd.api.extensions.ExtensionArray) except ImportError: # pragma: no cover _array_like = (list, tuple, np.ndarray) # pragma: no cover except ImportError: # pragma: no cover diff --git a/pyproject.toml b/pyproject.toml index f65cde0a..458a4fa9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,10 +47,10 @@ exclude = ["docs", "tests"] dev = [ "flake8==7.0.0", "flake8-docstrings==1.7.0", - "numpy==1.24.4; python_version<'3.10'", - "pandas==2.0.3; python_version<'3.10'", - "numpy>=2.0.2,<=2.1.0; python_version>='3.10'", - "pandas==2.3.0; python_version>='3.10'", + "numpy>=1.24.4; python_version<'3.10'", + "pandas>=2.0.3; python_version<'3.10'", + "numpy>=2.0.2,<3; python_version>='3.10'", + "pandas>=2.3.0,<4; python_version>='3.10'", "pytest==8.4.2", "pytest-cov==7.0.0", "derp==0.1.1", diff --git a/tests/entity/bounds/test_categorical_bounds.py b/tests/entity/bounds/test_categorical_bounds.py index 92b1830a..24c5987f 100644 --- a/tests/entity/bounds/test_categorical_bounds.py +++ b/tests/entity/bounds/test_categorical_bounds.py @@ -62,7 +62,7 @@ def test_json(): def test_numpy(): """Test that ndarrays, Series work as well.""" - assert len(array_like()) < 5 # In case we extend at some point + assert len(array_like()) < 6 # In case we extend at some point if len(array_like()) > 2: # Test numpy import numpy as np @@ -75,3 +75,6 @@ def test_numpy(): pd_bounds = CategoricalBounds(pd.Series(["spam", "eggs"])) pd_copy = loads(dumps(pd_bounds)) assert pd_copy == pd_bounds + + pd_unique = CategoricalBounds(pd.Series(["spam", "eggs"]).unique()) + assert pd_copy == pd_unique diff --git a/tests/entity/bounds/test_composition_bounds.py b/tests/entity/bounds/test_composition_bounds.py index c6391cdc..0f137e71 100644 --- a/tests/entity/bounds/test_composition_bounds.py +++ b/tests/entity/bounds/test_composition_bounds.py @@ -63,7 +63,7 @@ def test_json(): def test_numpy(): """Test that ndarrays, Series work as well.""" - assert len(array_like()) < 5 # In case we extend at some point + assert len(array_like()) < 6 # In case we extend at some point if len(array_like()) > 2: # Test numpy import numpy as np