Skip to content

Commit 360483e

Browse files
authored
Fix Grouper import (#560)
* Fix import * redo CI * fix name * fix min deps * bump min xarray * importorskip
1 parent ad28d6a commit 360483e

File tree

6 files changed

+60
-33
lines changed

6 files changed

+60
-33
lines changed

.github/workflows/ci.yaml

+24-29
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818

1919
jobs:
2020
build:
21-
name: Build (${{ matrix.python-version }}, ${{ matrix.os }})
21+
name: Build (${{ matrix.python-version }}, ${{ matrix.os }}), ${{ matrix.env }}
2222
runs-on: ${{ matrix.os }}
2323
defaults:
2424
run:
@@ -27,18 +27,38 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
os: ["ubuntu-latest"]
30-
python-version: ["3.10", "3.12"]
30+
python-version: ["3.10", "3.13"]
31+
env: [""]
32+
include:
33+
- env: "all-min-deps"
34+
python-version: "3.10"
35+
os: ubuntu-latest
36+
- env: "no-optional-deps"
37+
python-version: "3.13"
38+
os: ubuntu-latest
3139
steps:
3240
- uses: actions/checkout@v4
3341
with:
3442
fetch-depth: 0 # Fetch all history for all branches and tags.
3543
- name: Set environment variables
3644
run: |
3745
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
46+
if [[ "${{ matrix.env }}" == "" ]] ;
47+
then
48+
echo "CONDA_ENV_FILE=ci/environment.yml" >> $GITHUB_ENV
49+
fi
50+
if [[ "${{ matrix.env }}" == "no-optional-deps" ]] ;
51+
then
52+
echo "CONDA_ENV_FILE=ci/environment-no-optional-deps.yml" >> $GITHUB_ENV
53+
fi
54+
if [[ "${{ matrix.env }}" == "all-min-deps" ]] ;
55+
then
56+
echo "CONDA_ENV_FILE=ci/environment-all-min-deps.yml" >> $GITHUB_ENV
57+
fi
3858
- name: Set up conda environment
3959
uses: mamba-org/setup-micromamba@v2
4060
with:
41-
environment-file: ci/environment.yml
61+
environment-file: ${{ env.CONDA_ENV_FILE }}
4262
environment-name: cf_xarray_test
4363
cache-environment: true
4464
create-args: >-
@@ -58,31 +78,6 @@ jobs:
5878
name: codecov-umbrella
5979
fail_ci_if_error: false
6080

61-
no-optional-deps:
62-
name: no-optional-deps
63-
runs-on: ubuntu-latest
64-
defaults:
65-
run:
66-
shell: bash -l {0}
67-
steps:
68-
- uses: actions/checkout@v4
69-
with:
70-
# need to fetch all tags to get a correct version
71-
fetch-depth: 0 # fetch all branches and tags
72-
- name: Set up conda environment
73-
uses: mamba-org/setup-micromamba@v2
74-
with:
75-
environment-file: ci/environment-no-optional-deps.yml
76-
environment-name: cf_xarray_test
77-
cache-environment: true
78-
- name: Install cf_xarray
79-
run: |
80-
python -m pip install --no-deps -e .
81-
- name: Run Tests
82-
shell: bash -l {0}
83-
run: |
84-
pytest -n 2
85-
8681
mypy:
8782
name: mypy
8883
runs-on: "ubuntu-latest"
@@ -91,7 +86,7 @@ jobs:
9186
shell: bash -l {0}
9287
strategy:
9388
matrix:
94-
python-version: ["3.10", "3.12"]
89+
python-version: ["3.10", "3.13"]
9590
steps:
9691
- uses: actions/checkout@v4
9792
with:

.github/workflows/upstream-dev-ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
strategy:
3030
fail-fast: false
3131
matrix:
32-
python-version: ["3.12"]
32+
python-version: ["3.13"]
3333
steps:
3434
- uses: actions/checkout@v4
3535
with:

cf_xarray/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import xarray
2+
from packaging.version import Version
3+
4+
from . import geometry as geometry
15
from . import sgrid # noqa
26
from .accessor import CFAccessor # noqa
37
from .coding import ( # noqa
@@ -9,6 +13,7 @@
913
from .options import set_options # noqa
1014
from .utils import _get_version
1115

12-
from . import geometry, groupers # noqa
16+
if Version(xarray.__version__) >= Version("2024.07.0"):
17+
from . import groupers as groupers
1318

1419
__version__ = _get_version()

cf_xarray/tests/test_groupers.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import xarray as xr
44
from xarray.testing import assert_identical
55

6+
pytest.importorskip("xarray", "2024.07.0")
7+
68
from cf_xarray.datasets import flag_excl
79
from cf_xarray.groupers import FlagGrouper
810

ci/environment-all-min-deps.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: cf_xarray_test
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- pytest-cov
6+
- pytest
7+
- pytest-xdist
8+
- dask
9+
- flox
10+
- lxml
11+
- matplotlib-base
12+
- netcdf4
13+
- pandas
14+
- pint==0.19
15+
- pooch
16+
- regex
17+
- rich
18+
- pooch
19+
- scipy
20+
- shapely
21+
- xarray==2023.09.0
22+
- pip
23+
- pip:
24+
- pytest-pretty

pyproject.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ classifiers = [
1414
"Programming Language :: Python :: 3.10",
1515
"Programming Language :: Python :: 3.11",
1616
"Programming Language :: Python :: 3.12",
17+
"Programming Language :: Python :: 3.13",
1718
]
1819
dependencies = [
19-
"xarray>=2022.03.0",
20+
"xarray>=2023.09.0",
2021
]
2122
dynamic = ["version"]
2223

@@ -32,7 +33,7 @@ changelog = "https://cf-xarray.readthedocs.io/en/latest/whats-new.html"
3233
[build-system]
3334
requires = [
3435
# xarray is need for dynamic version string
35-
"xarray>=2022.03.0",
36+
"xarray>=2023.09.0",
3637
"setuptools>=45",
3738
"setuptools_scm[toml]>=6.2",
3839
]

0 commit comments

Comments
 (0)