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

Method test_lazy_load_duck_array

xarray/tests/test_dataset.py:5748–5769  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5746 ds.isel(time=slice(10), dim1=[0]).isel(dim1=0, dim2=-1)
5747
5748 def test_lazy_load_duck_array(self) -> None:
5749 store = AccessibleAsDuckArrayDataStore()
5750 create_test_data().dump_to_store(store)
5751
5752 for decode_cf in [True, False]:
5753 ds = open_dataset(store, decode_cf=decode_cf)
5754 with pytest.raises(UnexpectedDataAccess):
5755 _ = ds["var1"].values
5756
5757 # these should not raise UnexpectedDataAccess:
5758 _ = ds.var1.data
5759 ds.isel(time=10)
5760 ds.isel(time=slice(10), dim1=[0]).isel(dim1=0, dim2=-1)
5761 repr(ds)
5762
5763 # preserve the duck array type and don't cast to array
5764 assert isinstance(ds["var1"].load().data, DuckArrayWrapper)
5765 assert isinstance(
5766 ds["var1"].isel(dim2=0, dim1=0).load().data, DuckArrayWrapper
5767 )
5768
5769 ds.close()
5770
5771 def test_dropna(self) -> None:
5772 x = np.random.randn(4, 4)

Callers

nothing calls this directly

Calls 7

create_test_dataFunction · 0.90
open_datasetFunction · 0.90
dump_to_storeMethod · 0.80
iselMethod · 0.45
loadMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected