Skip to content

Commit c0dc71b

Browse files
authored
(fix): remove PandasExtensionArray from repr (#10291)
1 parent b8e3be8 commit c0dc71b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

xarray/core/variable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ def _new(
392392
@property
393393
def _in_memory(self):
394394
return isinstance(
395-
self._data, np.ndarray | np.number | PandasIndexingAdapter
395+
self._data,
396+
np.ndarray | np.number | PandasIndexingAdapter | PandasExtensionArray,
396397
) or (
397398
isinstance(self._data, indexing.MemoryCachedArray)
398399
and isinstance(self._data.array, indexing.NumpyIndexingAdapter)

xarray/tests/test_dataset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def lazy_accessible(k, v) -> xr.Variable:
280280

281281
class TestDataset:
282282
def test_repr(self) -> None:
283-
data = create_test_data(seed=123)
283+
data = create_test_data(seed=123, use_extension_array=True)
284284
data.attrs["foo"] = "bar"
285285
# need to insert str dtype at runtime to handle different endianness
286286
expected = dedent(
@@ -297,6 +297,7 @@ def test_repr(self) -> None:
297297
var1 (dim1, dim2) float64 576B -0.9891 -0.3678 1.288 ... -0.2116 0.364
298298
var2 (dim1, dim2) float64 576B 0.953 1.52 1.704 ... 0.1347 -0.6423
299299
var3 (dim3, dim1) float64 640B 0.4107 0.9941 0.1665 ... 0.716 1.555
300+
var4 (dim1) category 64B 'b' 'c' 'b' 'a' 'c' 'a' 'c' 'a'
300301
Attributes:
301302
foo: bar""".format(
302303
data["dim3"].dtype,
@@ -1814,7 +1815,7 @@ def test_categorical_index(self) -> None:
18141815
actual3 = ds.unstack("index")
18151816
assert actual3["var"].shape == (2, 2)
18161817

1817-
def test_categorical_reindex(self) -> None:
1818+
def test_categorical_index_reindex(self) -> None:
18181819
cat = pd.CategoricalIndex(
18191820
["foo", "bar", "baz"],
18201821
categories=["foo", "bar", "baz", "qux", "quux", "corge"],

0 commit comments

Comments
 (0)