Test `open_groups` with a netCDF4/HDF5 file with an unaligned group hierarchy.
(self, url=unaligned_datatree_url)
| 596 | open_datatree(url, engine=self.engine) |
| 597 | |
| 598 | def test_open_groups(self, url=unaligned_datatree_url) -> None: |
| 599 | """Test `open_groups` with a netCDF4/HDF5 file with an unaligned group hierarchy.""" |
| 600 | unaligned_dict_of_datasets = open_groups(url, engine=self.engine) |
| 601 | |
| 602 | # Check that group names are keys in the dictionary of `xr.Datasets` |
| 603 | assert "/" in unaligned_dict_of_datasets.keys() |
| 604 | assert "/Group1" in unaligned_dict_of_datasets.keys() |
| 605 | assert "/Group1/subgroup1" in unaligned_dict_of_datasets.keys() |
| 606 | # Check that group name returns the correct datasets |
| 607 | with xr.open_dataset(url, engine=self.engine, group="/") as expected: |
| 608 | assert_identical(unaligned_dict_of_datasets["/"], expected) |
| 609 | with xr.open_dataset(url, group="Group1", engine=self.engine) as expected: |
| 610 | assert_identical(unaligned_dict_of_datasets["/Group1"], expected) |
| 611 | with xr.open_dataset( |
| 612 | url, |
| 613 | group="/Group1/subgroup1", |
| 614 | engine=self.engine, |
| 615 | ) as expected: |
| 616 | assert_identical(unaligned_dict_of_datasets["/Group1/subgroup1"], expected) |
| 617 | |
| 618 | def test_inherited_coords(self, tmpdir, url=simplegroup_datatree_url) -> None: |
| 619 | """Test that `open_datatree` inherits coordinates from root tree. |
nothing calls this directly
no test coverage detected