diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index c72cf8e..30dbb54 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -16,13 +16,13 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.10', '3.11', '3.12'] + python-version: ['3.12', '3.13', '3.14', '3.15'] env: MPLBACKEND: Agg # https://github.com/orgs/community/discussions/26434 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: Python info diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f864736..b9f4811 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,11 +15,11 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 + - uses: actions/checkout@v7 + - name: Set up Python 3.12 + uses: actions/setup-python@v7 with: - python-version: "3.10" + python-version: "3.12" - name: Python info shell: bash -l {0} run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index faa315d..2aa35fd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,11 +21,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Set up Python - uses: actions/setup-python@v3 + uses: actions/setup-python@v7 with: - python-version: '3.10' + python-version: '3.12' - name: Install dependencies run: | python -m pip install --upgrade pip @@ -33,7 +33,7 @@ jobs: - name: Build package run: python -m build - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 149c3a2..4aa36f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/). +## Unreleased + +Changed: + - Supported Python versions are now 3.12, 3.13, 3.14 and 3.15. Python 3.10 and 3.11 are no longer supported. + - Updated GitHub Actions to their latest versions. + ## 0.4.2 (2026-01-28) New contributors: diff --git a/docs/.readthedocs.yaml b/docs/.readthedocs.yaml index 26768c7..962b5e9 100644 --- a/docs/.readthedocs.yaml +++ b/docs/.readthedocs.yaml @@ -3,7 +3,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3.12" sphinx: configuration: docs/conf.py diff --git a/pyproject.toml b/pyproject.toml index 50ecd81..ed297fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "xarray-regrid" dynamic = ["version"] description = 'Regridding tools using xarray and flox.' readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.12" license = "Apache-2.0" keywords = [] authors = [ @@ -16,8 +16,10 @@ authors = [ classifiers = [ "Development Status :: 4 - Beta", "Programming Language :: Python", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ] @@ -95,7 +97,7 @@ features = ["docs"] build = ["(cd docs && make html)"] [tool.ruff] -target-version = "py310" +target-version = "py312" line-length = 88 exclude = [ "docs", @@ -134,7 +136,7 @@ ignore = [ # Ignore checks for possible passwords "S105", "S106", "S107", # Ignore complexity - "C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", + "C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", "PLR0917", # Ignore magic values (false positives) "PLR2004", # Causes conflicts with formatter @@ -175,7 +177,7 @@ exclude_lines = [ ] [tool.mypy] -python_version = "3.10" +python_version = "3.12" plugins = "numpy.typing.mypy_plugin" disallow_untyped_defs = true disallow_any_unimported = true diff --git a/src/xarray_regrid/methods/conservative.py b/src/xarray_regrid/methods/conservative.py index 2ab67d9..15b3fe5 100644 --- a/src/xarray_regrid/methods/conservative.py +++ b/src/xarray_regrid/methods/conservative.py @@ -257,7 +257,7 @@ def lat_weight(latitude: np.ndarray, latitude_res: float) -> np.ndarray: dlat: float = np.radians(latitude_res) lat = np.radians(latitude) h = np.sin(lat + dlat / 2) - np.sin(lat - dlat / 2) - return h * dlat / (np.pi * 4) # type: ignore + return h * dlat / (np.pi * 4) def format_weights( diff --git a/src/xarray_regrid/methods/flox_reduce.py b/src/xarray_regrid/methods/flox_reduce.py index 6045306..c3b5668 100644 --- a/src/xarray_regrid/methods/flox_reduce.py +++ b/src/xarray_regrid/methods/flox_reduce.py @@ -22,7 +22,7 @@ def statistic_reduce( time_dim: str | None, method: str, skipna: bool = False, - fill_value: None | Any = None, + fill_value: Any | None = None, ) -> xr.DataArray: ... @@ -33,7 +33,7 @@ def statistic_reduce( time_dim: str | None, method: str, skipna: bool = False, - fill_value: None | Any = None, + fill_value: Any | None = None, ) -> xr.Dataset: ... @@ -43,7 +43,7 @@ def statistic_reduce( time_dim: str | None, method: str, skipna: bool = False, - fill_value: None | Any = None, + fill_value: Any | None = None, ) -> xr.DataArray | xr.Dataset: """Upsampling of data using statistical methods (e.g. the mean or variance). @@ -124,7 +124,7 @@ def compute_mode( target_ds: xr.Dataset, values: np.ndarray, time_dim: str | None, - fill_value: None | Any = None, + fill_value: Any | None = None, anti_mode: bool = False, ) -> xr.DataArray: """Upsample the input data using a "most common label" (mode) approach. diff --git a/src/xarray_regrid/regrid.py b/src/xarray_regrid/regrid.py index b2ed389..ab4d53e 100644 --- a/src/xarray_regrid/regrid.py +++ b/src/xarray_regrid/regrid.py @@ -135,7 +135,7 @@ def most_common( ds_target_grid: xr.Dataset, values: np.ndarray, time_dim: str | None = "time", - fill_value: None | Any = None, + fill_value: Any | None = None, ) -> xr.DataArray: """Regrid by taking the most common value within the new grid cells. @@ -165,8 +165,8 @@ def most_common( if isinstance(self._obj, xr.Dataset): msg = ( "The 'most common value' regridder is not implemented for\n", - "xarray.Dataset, as it requires specifying the expected labels.\n" - "Please select only a single variable (as DataArray),\n" + "xarray.Dataset, as it requires specifying the expected labels.\n", + "Please select only a single variable (as DataArray),\n", " and regrid it separately.", ) raise ValueError(msg) @@ -187,7 +187,7 @@ def least_common( ds_target_grid: xr.Dataset, values: np.ndarray, time_dim: str | None = "time", - fill_value: None | Any = None, + fill_value: Any | None = None, ) -> xr.DataArray: """Regrid by taking the least common value within the new grid cells. @@ -217,8 +217,8 @@ def least_common( if isinstance(self._obj, xr.Dataset): msg = ( "The 'least common value' regridder is not implemented for\n", - "xarray.Dataset, as it requires specifying the expected labels.\n" - "Please select only a single variable (as DataArray),\n" + "xarray.Dataset, as it requires specifying the expected labels.\n", + "Please select only a single variable (as DataArray),\n", " and regrid it separately.", ) raise ValueError(msg) @@ -240,7 +240,7 @@ def stat( method: str, time_dim: str | None = "time", skipna: bool = False, - fill_value: None | Any = None, + fill_value: Any | None = None, ) -> xr.DataArray | xr.Dataset: """Upsampling of data using statistical methods (e.g. the mean or variance). diff --git a/tests/test_regrid.py b/tests/test_regrid.py index a966057..08c6736 100644 --- a/tests/test_regrid.py +++ b/tests/test_regrid.py @@ -185,6 +185,12 @@ def test_conservative_nan_aggregation_over_dims(): np.testing.assert_allclose(result[0].mean().item(), data[0].mean().item()) +@pytest.mark.xfail( + xr.__version__ == "2026.9.0", + reason="Bug in xarray 2026.9.0: coarsen reductions reject `skipna`.", + raises=TypeError, + strict=True, +) @pytest.mark.parametrize("nan_threshold", [0, 1]) def test_conservative_nan_thresholds_against_coarsen(nan_threshold): """Compare nan_threshold regridding to behavior of xarray coarsen, where coarsen