|
29 | 29 | from xarray.core.types import T_DuckArray
|
30 | 30 | from xarray.core.utils import NDArrayMixin
|
31 | 31 | from xarray.core.variable import as_compatible_data, as_variable
|
32 |
| -from xarray.namedarray.pycompat import array_type |
| 32 | +from xarray.namedarray.pycompat import array_type, is_chunked_array |
33 | 33 | from xarray.tests import (
|
34 | 34 | assert_allclose,
|
35 | 35 | assert_array_equal,
|
@@ -2724,17 +2724,25 @@ def __init__(self, array):
|
2724 | 2724 |
|
2725 | 2725 | def test_duck_array_with_chunks(self):
|
2726 | 2726 | # Non indexable type
|
2727 |
| - class CustomArray(NDArrayMixin, indexing.ExplicitlyIndexed): |
| 2727 | + class CustomArray(NDArrayMixin): |
2728 | 2728 | def __init__(self, array):
|
2729 | 2729 | self.array = array
|
2730 | 2730 |
|
2731 | 2731 | @property
|
2732 | 2732 | def chunks(self):
|
2733 | 2733 | return self.shape
|
2734 | 2734 |
|
| 2735 | + def __array_function__(self, *args, **kwargs): |
| 2736 | + return NotImplemented |
| 2737 | + |
| 2738 | + def __array_ufunc__(self, *args, **kwargs): |
| 2739 | + return NotImplemented |
| 2740 | + |
| 2741 | + |
2735 | 2742 | 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 |
| 2743 | + assert is_chunked_array(array) |
| 2744 | + var = Variable(dims=("x"), data=array) |
| 2745 | + var.load() |
2738 | 2746 |
|
2739 | 2747 | def test_raise_no_warning_for_nan_in_binary_ops():
|
2740 | 2748 | with assert_no_warnings():
|
|
0 commit comments