(self, tmpdir, simple_datatree)
| 250 | assert "x" not in subtree.to_dataset(inherit=False).coords |
| 251 | |
| 252 | def test_netcdf_encoding(self, tmpdir, simple_datatree) -> None: |
| 253 | filepath = tmpdir / "test.nc" |
| 254 | original_dt = simple_datatree |
| 255 | |
| 256 | # add compression |
| 257 | comp = dict(zlib=True, complevel=9) |
| 258 | enc = {"/set2": dict.fromkeys(original_dt["/set2"].dataset.data_vars, comp)} |
| 259 | |
| 260 | original_dt.to_netcdf(filepath, encoding=enc, engine=self.engine) |
| 261 | with open_datatree(filepath, engine=self.engine) as roundtrip_dt: |
| 262 | assert roundtrip_dt["/set2/a"].encoding["zlib"] == comp["zlib"] |
| 263 | assert roundtrip_dt["/set2/a"].encoding["complevel"] == comp["complevel"] |
| 264 | |
| 265 | enc["/not/a/group"] = {"foo": "bar"} # type: ignore[dict-item] |
| 266 | with pytest.raises(ValueError, match=r"unexpected encoding group.*"): |
| 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( |
nothing calls this directly
no test coverage detected