Skip to content

Fix Grouper import #560

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

Merged
merged 6 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 24 additions & 29 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:

jobs:
build:
name: Build (${{ matrix.python-version }}, ${{ matrix.os }})
name: Build (${{ matrix.python-version }}, ${{ matrix.os }}), ${{ matrix.env }}
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -27,18 +27,38 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10", "3.12"]
python-version: ["3.10", "3.13"]
env: [""]
include:
- env: "all-min-deps"
python-version: "3.10"
os: ubuntu-latest
- env: "no-optional-deps"
python-version: "3.13"
os: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.
- name: Set environment variables
run: |
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
if [[ "${{ matrix.env }}" == "" ]] ;
then
echo "CONDA_ENV_FILE=ci/environment.yml" >> $GITHUB_ENV
fi
if [[ "${{ matrix.env }}" == "no-optional-deps" ]] ;
then
echo "CONDA_ENV_FILE=ci/environment-no-optional-deps.yml" >> $GITHUB_ENV
fi
if [[ "${{ matrix.env }}" == "all-min-deps" ]] ;
then
echo "CONDA_ENV_FILE=ci/environment-all-min-deps.yml" >> $GITHUB_ENV
fi
- name: Set up conda environment
uses: mamba-org/setup-micromamba@v2
with:
environment-file: ci/environment.yml
environment-file: ${{ env.CONDA_ENV_FILE }}
environment-name: cf_xarray_test
cache-environment: true
create-args: >-
Expand All @@ -58,31 +78,6 @@ jobs:
name: codecov-umbrella
fail_ci_if_error: false

no-optional-deps:
name: no-optional-deps
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
with:
# need to fetch all tags to get a correct version
fetch-depth: 0 # fetch all branches and tags
- name: Set up conda environment
uses: mamba-org/setup-micromamba@v2
with:
environment-file: ci/environment-no-optional-deps.yml
environment-name: cf_xarray_test
cache-environment: true
- name: Install cf_xarray
run: |
python -m pip install --no-deps -e .
- name: Run Tests
shell: bash -l {0}
run: |
pytest -n 2

mypy:
name: mypy
runs-on: "ubuntu-latest"
Expand All @@ -91,7 +86,7 @@ jobs:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.10", "3.12"]
python-version: ["3.10", "3.13"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upstream-dev-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
python-version: ["3.13"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
7 changes: 6 additions & 1 deletion cf_xarray/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import xarray
from packaging.version import Version

from . import geometry as geometry
from . import sgrid # noqa
from .accessor import CFAccessor # noqa
from .coding import ( # noqa
Expand All @@ -9,6 +13,7 @@
from .options import set_options # noqa
from .utils import _get_version

from . import geometry, groupers # noqa
if Version(xarray.__version__) >= Version("2024.07.0"):
from . import groupers as groupers

__version__ = _get_version()
2 changes: 2 additions & 0 deletions cf_xarray/tests/test_groupers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import xarray as xr
from xarray.testing import assert_identical

pytest.importorskip("xarray", "2024.07.0")

from cf_xarray.datasets import flag_excl
from cf_xarray.groupers import FlagGrouper

Expand Down
24 changes: 24 additions & 0 deletions ci/environment-all-min-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: cf_xarray_test
channels:
- conda-forge
dependencies:
- pytest-cov
- pytest
- pytest-xdist
- dask
- flox
- lxml
- matplotlib-base
- netcdf4
- pandas
- pint==0.19
- pooch
- regex
- rich
- pooch
- scipy
- shapely
- xarray==2023.09.0
- pip
- pip:
- pytest-pretty
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"xarray>=2022.03.0",
"xarray>=2023.09.0",
]
dynamic = ["version"]

Expand All @@ -32,7 +33,7 @@ changelog = "https://cf-xarray.readthedocs.io/en/latest/whats-new.html"
[build-system]
requires = [
# xarray is need for dynamic version string
"xarray>=2022.03.0",
"xarray>=2023.09.0",
"setuptools>=45",
"setuptools_scm[toml]>=6.2",
]
Expand Down
Loading