-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
coordinates not removed for variable encoding during reset_coords #7245
Comments
And if you want to have a clean encoding dictionary, you may want to do the following: names = set(names)
for _, variable in obj._variables.items():
if 'coordinates' in variable.encoding:
coords_in_encoding = set(variable.encoding.get('coordinates').split(' '))
remaining_coords = coords_in_encoding - names
if len(remaining_coords) == 0:
del variable.encoding['coordinates']
else:
variable.encoding['coordinates'] = ' '.join(remaining_coords) |
While the above "fix" addresses the issues with renaming coordinates, I think there are plenty of usecases where we would still end up with strange, or unexpected results. For example.
We could apply the "fix" to the I think a more "generic", albeit breaking" fix would be to remove the " |
Kind bump |
This is another motivating reason for #5082. It's too hard to keep Since |
Thank you for your explination. Do you think it is safe to "strip" encoding after "loading" the data? or is it still used after the initial call to |
What happened?
When calling
reset_coords
on a dataset that is loaded from disk, the coordinates are not removed from the encoding of the variable.This means, that at save time they will be resaved as coordinates... annoying. (and erroneous)
What did you expect to happen?
No response
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
suggested fix in
dataset.py, reset_coords
xarray/xarray/core/dataset.py
Line 1734 in 513ee34
Environment
The text was updated successfully, but these errors were encountered: