Skip to content

Commit d9fb6b9

Browse files
committed
Add test
1 parent d644607 commit d9fb6b9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

xarray/tests/test_variable.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,6 +2722,19 @@ def __init__(self, array):
27222722
orig = Variable(dims=(), data=array)
27232723
assert isinstance(orig._data.item(), CustomWithValuesAttr)
27242724

2725+
def test_duck_array_with_chunks(self):
2726+
# Non indexable type
2727+
class CustomArray(NDArrayMixin, indexing.ExplicitlyIndexed):
2728+
def __init__(self, array):
2729+
self.array = array
2730+
2731+
@property
2732+
def chunks(self):
2733+
return self.shape
2734+
2735+
array = CustomArray(np.arange(3))
2736+
orig = Variable(dims=("x"), data=array, attrs={"foo": "bar"})
2737+
assert isinstance(orig._data, np.ndarray) # should not be CustomArray
27252738

27262739
def test_raise_no_warning_for_nan_in_binary_ops():
27272740
with assert_no_warnings():

0 commit comments

Comments
 (0)