Deltares / xugrid

Xarray and unstructured grids
https://deltares.github.io/xugrid/
MIT License
58 stars 8 forks source link

Support older xarray versions or require minimal xarray version #167

Closed veenstrajelmer closed 10 months ago

veenstrajelmer commented 10 months ago

Due to some compatibility issues that were reported by users, I deep dove into dfm_tools minimal requirements. There was one where xugrid popped up. With xarray<=2022.10.0 I get this ImportError:

ImportError while importing test module 'c:\DATA\dfm_tools\tests\test_xugrid_helpers.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\lib\importlib\__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests\test_xugrid_helpers.py:10: in <module>
    import xugrid as xu
C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\lib\site-packages\xugrid\__init__.py:15: in <module>
    from xugrid.core.dataarray_accessor import UgridDataArrayAccessor
C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\lib\site-packages\xugrid\core\dataarray_accessor.py:11: in <module>
    from xugrid.plot.plot import _PlotMethods
C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\lib\site-packages\xugrid\plot\__init__.py:1: in <module>
    from xugrid.plot.plot import (
C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\lib\site-packages\xugrid\plot\plot.py:9: in <module>
    from xugrid.plot.utils import (
C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\lib\site-packages\xugrid\plot\utils.py:31: in <module>
    from xarray.core.utils import is_scalar, module_available
E   ImportError: cannot import name 'module_available' from 'xarray.core.utils' (C:\Users\veenstra\Anaconda3\envs\dfm_tools_env\lib\site-packages\xarray\core\utils.py)

It is fine to not support these older versions (xarray>=2022.11.0 work), but in that case it should be documented in the xugrid package requirements so it automatically updates xarray if needed.

veenstrajelmer commented 10 months ago

This is already solved in the main branch, so I will close this issue again. I have now tested with xarray 2022.6.0, so over a year old, and it works fine.