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

Method test_open_mfdataset

xarray/tests/test_backends.py:5973–5993  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5971 assert not actual.foo.variable._in_memory
5972
5973 def test_open_mfdataset(self) -> None:
5974 original = Dataset({"foo": ("x", np.random.randn(10))})
5975 with create_tmp_file() as tmp1:
5976 with create_tmp_file() as tmp2:
5977 original.isel(x=slice(5)).to_netcdf(tmp1)
5978 original.isel(x=slice(5, 10)).to_netcdf(tmp2)
5979 with open_mfdataset(
5980 [tmp1, tmp2], concat_dim="x", combine="nested"
5981 ) as actual:
5982 assert isinstance(actual.foo.variable.data, da.Array)
5983 assert actual.foo.variable.data.chunks == ((5, 5),)
5984 assert_identical(original, actual)
5985 with open_mfdataset(
5986 [tmp1, tmp2], concat_dim="x", combine="nested", chunks={"x": 3}
5987 ) as actual:
5988 assert actual.foo.variable.data.chunks == ((3, 2, 3, 2),)
5989
5990 with pytest.raises(OSError, match=r"no files to open"):
5991 open_mfdataset("foo-bar-baz-*.nc")
5992 with pytest.raises(ValueError, match=r"wild-card"):
5993 open_mfdataset("http://some/remote/uri")
5994
5995 @requires_fsspec
5996 def test_open_mfdataset_no_files(self) -> None:

Callers

nothing calls this directly

Calls 6

iselMethod · 0.95
DatasetClass · 0.90
open_mfdatasetFunction · 0.90
assert_identicalFunction · 0.90
create_tmp_fileFunction · 0.85
to_netcdfMethod · 0.45

Tested by

no test coverage detected