(self)
| 5223 | del data["level_1"] |
| 5224 | |
| 5225 | def test_squeeze(self) -> None: |
| 5226 | data = Dataset({"foo": (["x", "y", "z"], [[[1], [2]]])}) |
| 5227 | test_args: list[list] = [[], [["x"]], [["x", "z"]]] |
| 5228 | for args in test_args: |
| 5229 | |
| 5230 | def get_args(args, v): |
| 5231 | return [set(args[0]) & set(v.dims)] if args else [] |
| 5232 | |
| 5233 | expected = Dataset( |
| 5234 | {k: v.squeeze(*get_args(args, v)) for k, v in data.variables.items()} |
| 5235 | ) |
| 5236 | expected = expected.set_coords(data.coords) |
| 5237 | assert_identical(expected, data.squeeze(*args)) |
| 5238 | # invalid squeeze |
| 5239 | with pytest.raises(ValueError, match=r"cannot select a dimension"): |
| 5240 | data.squeeze("y") |
| 5241 | |
| 5242 | def test_squeeze_drop(self) -> None: |
| 5243 | data = Dataset({"foo": ("x", [1])}, {"x": [0]}) |
nothing calls this directly
no test coverage detected