| 2927 | array.squeeze(axis=0, dim="dim_1") |
| 2928 | |
| 2929 | def test_drop_coordinates(self) -> None: |
| 2930 | expected = DataArray(np.random.randn(2, 3), dims=["x", "y"]) |
| 2931 | arr = expected.copy() |
| 2932 | arr.coords["z"] = 2 |
| 2933 | actual = arr.drop_vars("z") |
| 2934 | assert_identical(expected, actual) |
| 2935 | |
| 2936 | with pytest.raises(ValueError): |
| 2937 | arr.drop_vars("not found") |
| 2938 | |
| 2939 | actual = expected.drop_vars("not found", errors="ignore") |
| 2940 | assert_identical(actual, expected) |
| 2941 | |
| 2942 | with pytest.raises(ValueError, match=r"cannot be found"): |
| 2943 | arr.drop_vars("w") |
| 2944 | |
| 2945 | actual = expected.drop_vars("w", errors="ignore") |
| 2946 | assert_identical(actual, expected) |
| 2947 | |
| 2948 | renamed = arr.rename("foo") |
| 2949 | with pytest.raises(ValueError, match=r"cannot be found"): |
| 2950 | renamed.drop_vars("foo") |
| 2951 | |
| 2952 | actual = renamed.drop_vars("foo", errors="ignore") |
| 2953 | assert_identical(actual, renamed) |
| 2954 | |
| 2955 | def test_drop_vars_callable(self) -> None: |
| 2956 | A = DataArray( |