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

Method test_write_subgroup

xarray/tests/test_backends_datatree.py:269–285  ·  view source on GitHub ↗
(self, tmpdir)

Source from the content-addressed store, hash-verified

267 original_dt.to_netcdf(filepath, encoding=enc, engine=self.engine)
268
269 def test_write_subgroup(self, tmpdir) -> None:
270 original_dt = DataTree.from_dict(
271 {
272 "/": xr.Dataset(coords={"x": [1, 2, 3]}),
273 "/child": xr.Dataset({"foo": ("x", [4, 5, 6])}),
274 }
275 ).children["child"]
276
277 expected_dt = original_dt.copy()
278 expected_dt.name = None
279
280 filepath = tmpdir / "test.zarr"
281 original_dt.to_netcdf(filepath, engine=self.engine)
282
283 with open_datatree(filepath, engine=self.engine) as roundtrip_dt:
284 assert_equal(original_dt, roundtrip_dt)
285 assert_identical(expected_dt, roundtrip_dt)
286
287 @requires_netCDF4
288 def test_no_redundant_dimensions(self, tmpdir) -> None:

Callers

nothing calls this directly

Calls 6

open_datatreeFunction · 0.90
assert_equalFunction · 0.90
assert_identicalFunction · 0.90
from_dictMethod · 0.45
copyMethod · 0.45
to_netcdfMethod · 0.45

Tested by

no test coverage detected