MCPcopy Index your code
hub / github.com/pydata/xarray / test_lazy_array_wont_compute

Function test_lazy_array_wont_compute

xarray/tests/test_formatting.py:971–989  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

969
970
971def 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))

Callers

nothing calls this directly

Calls 3

__repr__Method · 0.45
_repr_html_Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…