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

Method test_open_subgroup

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

Source from the content-addressed store, hash-verified

1773 open_dataset(tmp_file, group=(1, 2, 3))
1774
1775 def test_open_subgroup(self) -> None:
1776 # Create a netCDF file with a dataset stored within a group within a
1777 # group
1778 with create_tmp_file() as tmp_file:
1779 rootgrp = nc4.Dataset(tmp_file, "w")
1780 foogrp = rootgrp.createGroup("foo")
1781 bargrp = foogrp.createGroup("bar")
1782 ds = bargrp
1783 ds.createDimension("time", size=10)
1784 x = np.arange(10)
1785 ds.createVariable("x", np.int32, dimensions=("time",))
1786 ds.variables["x"][:] = x
1787 rootgrp.close()
1788
1789 expected = Dataset()
1790 expected["x"] = ("time", x)
1791
1792 # check equivalent ways to specify group
1793 for group in "foo/bar", "/foo/bar", "foo/bar/", "/foo/bar/":
1794 with self.open(tmp_file, group=group) as actual:
1795 assert_equal(actual["x"], expected["x"])
1796
1797 def test_write_groups(self) -> None:
1798 data1 = create_test_data()

Callers

nothing calls this directly

Calls 6

DatasetClass · 0.90
assert_equalFunction · 0.90
create_tmp_fileFunction · 0.85
arangeMethod · 0.80
closeMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected