Skip to content

Commit ee9b027

Browse files
committed
DeprecationWarning -> FutureWarning
The `DeprecationWarning` is ignored by default for `.assign_coords` due to the stacklevel (pydata#6798 (comment)) Use `FutureWarning` instead to show the warning for both `.assign` and `.assign_coords`.
1 parent 914a1a1 commit ee9b027

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

xarray/core/coordinates.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def drop_coords(
442442
f"other variables: {list(maybe_midx.index.names)!r}. "
443443
f"This will raise an error in the future. Use `.drop_vars({idx_coord_names!r})` before "
444444
"assigning new coordinate values.",
445-
DeprecationWarning,
445+
FutureWarning,
446446
stacklevel=4,
447447
)
448448
for k in idx_coord_names:

xarray/tests/test_dataarray.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1501,9 +1501,7 @@ def test_assign_coords(self) -> None:
15011501

15021502
def test_assign_coords_existing_multiindex(self) -> None:
15031503
data = self.mda
1504-
with pytest.warns(
1505-
DeprecationWarning, match=r"Updating MultiIndexed coordinate"
1506-
):
1504+
with pytest.warns(FutureWarning, match=r"Updating MultiIndexed coordinate"):
15071505
data.assign_coords(x=range(4))
15081506

15091507
def test_coords_alignment(self) -> None:

xarray/tests/test_dataset.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -4136,14 +4136,10 @@ def test_assign_multiindex_level(self) -> None:
41364136

41374137
def test_assign_coords_existing_multiindex(self) -> None:
41384138
data = create_test_multiindex()
4139-
with pytest.warns(
4140-
DeprecationWarning, match=r"Updating MultiIndexed coordinate"
4141-
):
4139+
with pytest.warns(FutureWarning, match=r"Updating MultiIndexed coordinate"):
41424140
data.assign_coords(x=range(4))
41434141

4144-
with pytest.warns(
4145-
DeprecationWarning, match=r"Updating MultiIndexed coordinate"
4146-
):
4142+
with pytest.warns(FutureWarning, match=r"Updating MultiIndexed coordinate"):
41474143
data.assign(x=range(4))
41484144

41494145
# https://github.com/pydata/xarray/issues/7097 (coord names updated)

0 commit comments

Comments
 (0)