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

Documentation examples fail on cf_xarray 0.8. #73

Closed
juseg opened this issue Mar 21, 2023 · 1 comment · Fixed by #78
Closed

Documentation examples fail on cf_xarray 0.8. #73

juseg opened this issue Mar 21, 2023 · 1 comment · Fixed by #78
Assignees
Labels
bug Something isn't working
Milestone

Comments

@juseg
Copy link
Owner

juseg commented Mar 21, 2023

Documentation examples fail on cf_xarray==0.8.0. Assigning new variables on the example data raises a MergeError:

Traceback (most recent call last):
  File "/home/julien/git/code/hyoga/examples/datasets/./plot_bedrock_isostasy.py", line 25, in <module>
    ds = ds.hyoga.assign_isostasy(hyoga.open.example('pism.alps.in.boot.nc'))
  File "/home/julien/git/code/hyoga/hyoga/core/accessor.py", line 240, in assign_isostasy
    return self.assign(
  File "/home/julien/git/code/hyoga/hyoga/core/accessor.py", line 186, in assign
    return self._ds.assign(variables)
  File "/usr/lib/python3.10/site-packages/xarray/core/dataset.py", line 6080, in assign
    data.update(results)
  File "/usr/lib/python3.10/site-packages/xarray/core/dataset.py", line 4946, in update
    merge_result = dataset_update_method(self, other)
  File "/usr/lib/python3.10/site-packages/xarray/core/merge.py", line 1104, in dataset_update_method
    return merge_core(
  File "/usr/lib/python3.10/site-packages/xarray/core/merge.py", line 772, in merge_core
    raise MergeError(
xarray.core.merge.MergeError: unable to determine if these variables should be coordinates or not in the merged result: {'mapping'}

This issue can be worked around by downgrading to cf_xarray<0.8.0.

@juseg juseg added the bug Something isn't working label Mar 21, 2023
@juseg juseg added this to the v0.3.1 milestone Mar 21, 2023
@juseg juseg self-assigned this Mar 21, 2023
@juseg
Copy link
Owner Author

juseg commented May 31, 2024

The bug remains on later versions of cf-xarray and is caused by code such as:

with hyoga.open.example('pism.alps.out.2d.nc') as ds:
    with hyoga.open.example('pism.alps.in.boot.nc') as boot:
        ds = ds.hyoga.assign_isostasy(boot)

Internally ds.hyoga.getvar() uses the cf dataset accessor. Since cf_xarray == 0.8.0 this adds any grid mapping data-variable as a new coordinate, raising the MergeError in subsequent calls to ds.assign(). More at xarray-contrib/cf-xarray#513.

juseg added a commit that referenced this issue Jun 3, 2024
juseg added a commit that referenced this issue Jun 3, 2024
* Test Python 3.11 and 3.12 on GitHub.

* Require cf_xarray<0.8.0 for now (see #73).

* Document changes in whatsnew.

The requirement for cf_xarray<0.8.0 is a very temporary fix.
@juseg juseg closed this as completed in #78 Jun 5, 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 a pull request may close this issue.

1 participant