Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding DeprecationWarning: xr.Dataset.drop() -> xr.Dataset.drop_vars() #740

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

xaviernogueira
Copy link
Contributor

Very simple PR. I was getting deprecation warnings from rioxarray that originated in xarray. Here is an example of the warning:

  /home/xavier/.pyenv/versions/3.9.7/envs/vetl_s2/lib/python3.9/site-packages/rioxarray/_io.py:870: DeprecationWarning: dropping variables using `drop` is deprecated; use drop_vars.
    open_rasterio(  # type: ignore

So I simply went in and changed it. I don't have time to recreate the full dev environment, but it should work. That said, maybe someone should probably re-run you're test suite before merging. I can do it, but most likely a few days from now.

@@ -881,7 +881,7 @@ def _load_bands_as_variables(
**open_kwargs,
)
.squeeze() # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.squeeze() # type: ignore
.squeeze(dim="band", drop=True) # type: ignore

@@ -881,7 +881,7 @@ def _load_bands_as_variables(
**open_kwargs,
)
.squeeze() # type: ignore
.drop("band") # type: ignore
.drop_vars("band") # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.drop_vars("band") # type: ignore

@snowman2
Copy link
Member

snowman2 commented Feb 7, 2024

Thank you @xaviernogueira! I suggested a different approach that could prevent squeezing out dimensions we don't intend while also resolving this issue. Mind testing it out and seeing if it solves the issue?

@snowman2 snowman2 added the bug Something isn't working label Feb 15, 2024
@snowman2 snowman2 added this to the 0.15.1 milestone Feb 15, 2024
@snowman2 snowman2 merged commit e33616e into corteva:master Feb 15, 2024
18 of 19 checks passed
@snowman2 snowman2 modified the milestones: 0.15.1, 0.15.2 Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants