| 123 | assert mary.children["Sue"].name == "Sue" |
| 124 | |
| 125 | def test_dataset_containing_slashes(self) -> None: |
| 126 | xda: xr.DataArray = xr.DataArray( |
| 127 | [[1, 2]], |
| 128 | coords={"label": ["a"], "R30m/y": [30, 60]}, |
| 129 | ) |
| 130 | xds: xr.Dataset = xr.Dataset({"group/subgroup/my_variable": xda}) |
| 131 | with pytest.raises( |
| 132 | ValueError, |
| 133 | match=re.escape( |
| 134 | "Given variables have names containing the '/' character: " |
| 135 | "['R30m/y', 'group/subgroup/my_variable']. " |
| 136 | "Variables stored in DataTree objects cannot have names containing '/' characters, " |
| 137 | "as this would make path-like access to variables ambiguous." |
| 138 | ), |
| 139 | ): |
| 140 | DataTree(xds) |
| 141 | |
| 142 | |
| 143 | class TestPaths: |