()
| 969 | |
| 970 | |
| 971 | def test_lazy_array_wont_compute() -> None: |
| 972 | from xarray.core.indexing import LazilyIndexedArray |
| 973 | |
| 974 | class LazilyIndexedArrayNotComputable(LazilyIndexedArray): |
| 975 | def __array__( |
| 976 | self, |
| 977 | dtype: np.typing.DTypeLike | None = None, |
| 978 | /, |
| 979 | *, |
| 980 | copy: bool | None = None, |
| 981 | ) -> np.ndarray: |
| 982 | raise NotImplementedError("Computing this array is not possible.") |
| 983 | |
| 984 | arr = LazilyIndexedArrayNotComputable(np.array([1, 2])) |
| 985 | var = xr.DataArray(arr) |
| 986 | |
| 987 | # These will crash if var.data are converted to numpy arrays: |
| 988 | var.__repr__() |
| 989 | var._repr_html_() |
| 990 | |
| 991 | |
| 992 | @pytest.mark.parametrize("as_dataset", (False, True)) |
nothing calls this directly
no test coverage detected
searching dependent graphs…