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

Method test_phony_dims_warning

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

Source from the content-addressed store, hash-verified

5154 assert_equal(expected, actual)
5155
5156 def test_phony_dims_warning(self) -> None:
5157 import h5py
5158
5159 foo_data = np.arange(125).reshape(5, 5, 5)
5160 bar_data = np.arange(625).reshape(25, 5, 5)
5161 var = {"foo1": foo_data, "foo2": bar_data, "foo3": foo_data, "foo4": bar_data}
5162 with create_tmp_file() as tmp_file:
5163 with h5py.File(tmp_file, "w") as f:
5164 grps = ["bar", "baz"]
5165 for grp in grps:
5166 fx = f.create_group(grp)
5167 for k, v in var.items():
5168 fx.create_dataset(k, data=v)
5169 with pytest.warns(UserWarning, match="The 'phony_dims' kwarg"):
5170 with xr.open_dataset(tmp_file, engine="h5netcdf", group="bar") as ds:
5171 assert ds.sizes == {
5172 "phony_dim_0": 5,
5173 "phony_dim_1": 5,
5174 "phony_dim_2": 5,
5175 "phony_dim_3": 25,
5176 }
5177
5178
5179@requires_h5netcdf

Callers

nothing calls this directly

Calls 5

create_tmp_fileFunction · 0.85
arangeMethod · 0.80
itemsMethod · 0.80
create_datasetMethod · 0.80
open_datasetMethod · 0.45

Tested by

no test coverage detected