MCPcopy
hub / github.com/pydata/xarray / test_extension_array_attr

Function test_extension_array_attr

xarray/tests/test_duck_array_ops.py:1180–1194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1178
1179
1180def test_extension_array_attr():
1181 array = pd.Categorical(["cat2", "cat1", "cat2", "cat3", "cat1"])
1182 wrapped = PandasExtensionArray(array)
1183 assert_array_equal(array.categories, wrapped.categories)
1184 assert array.nbytes == wrapped.nbytes
1185
1186 roundtripped = pickle.loads(pickle.dumps(wrapped))
1187 assert isinstance(roundtripped, PandasExtensionArray)
1188 assert (roundtripped == wrapped).all()
1189
1190 interval_array = pd.arrays.IntervalArray.from_breaks([0, 1, 2, 3], closed="right")
1191 # pandas-stubs types PandasExtensionArray too narrowly; IntervalArray is valid
1192 wrapped = PandasExtensionArray(interval_array) # type: ignore[arg-type]
1193 assert_array_equal(wrapped.left, interval_array.left, strict=True)
1194 assert wrapped.closed == interval_array.closed

Callers

nothing calls this directly

Calls 2

allMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…