Repository: juseg/hyoga (language: python)

Issue:
Documentation examples fail on cf_xarray 0.8.
Documentation examples fail on `cf_xarray==0.8.0`. Assigning new variables on the example data raises a `MergeError`:

```python
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`. 


Discussion / hints:
The bug remains on later versions of cf-xarray and is caused by code such as:

```python
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 https://github.com/xarray-contrib/cf-xarray/issues/513.

Fix patch:
diff --git a/doc/whatsnew.rst b/doc/whatsnew.rst
index d702564..5db5cb5 100644
--- a/doc/whatsnew.rst
+++ b/doc/whatsnew.rst
@@ -1,4 +1,4 @@
-.. Copyright (c) 2021-2023, Julien Seguinot (juseg.github.io)
+.. Copyright (c) 2021-2024, Julien Seguinot (juseg.dev)
 .. GNU General Public License v3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
 
 .. currentmodule:: hyoga
@@ -21,6 +21,16 @@
 What's new
 ==========
 
+.. _v0.3.1:
+
+v0.3.1 (unreleased)
+-------------------
+
+Internal changes
+~~~~~~~~~~~~~~~~
+
+- Test (and support) Python 3.11 and 3.12 (:pull:`77`).
+
 .. _v0.3.0:
 
 v0.3.0 Cocuy (16 Jan. 2023)
diff --git a/setup.cfg b/setup.cfg
index c749e33..aa37a98 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,4 +1,4 @@
-# Copyright (c) 2019-2023, Julien Seguinot (juseg.github.io)
+# Copyright (c) 2019-2024, Julien Seguinot (juseg.dev)
 # GNU General Public License v3.0+ (https://www.gnu.org/licenses/gpl-3.0.txt)
 
 # Build config for hyoga
@@ -22,7 +22,7 @@ classifiers =
 [options]
 packages = find:
 install_requires =
-    cf_xarray
+    cf_xarray<0.8.0
     geopandas
     matplotlib
     requests


Test patch:
diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index e51562c..d3c5231 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -14,7 +14,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python-version: ["3.8", "3.9", "3.10"]
+        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
 
     steps:
       - uses: actions/checkout@v3