From 310491d133bf98e39d221afaaac21e45ebfb0b1a Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Tue, 24 Mar 2026 14:26:32 +0100 Subject: [PATCH 1/9] chore: pyinterp version 2026.2.0 --- .github/workflows/doc.yaml | 2 +- .github/workflows/tests.yaml | 4 ++-- pyproject.toml | 8 ++++++-- src/fcollections/geometry/_box.py | 19 +++++++++---------- src/fcollections/geometry/_distances.py | 17 ++++++++++++++--- .../geometry/_track_orientation.py | 2 +- tests/geometry/test_box.py | 6 +++--- tests/geometry/test_distances.py | 2 +- 8 files changed, 37 insertions(+), 23 deletions(-) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 30e566f..5d3fb48 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -52,7 +52,7 @@ jobs: beautifulsoup4 shapely geopandas - pyinterp + pyinterp>=2026.2.0 dask - name: Install package (for autodoc) shell: bash -l {0} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f660ba8..d25924d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -40,7 +40,7 @@ jobs: pyftpdlib shapely geopandas - pyinterp + pyinterp>=2026.2.0 dask - name: Install python dependencies shell: bash -el {0} @@ -94,7 +94,7 @@ jobs: pyftpdlib shapely geopandas - pyinterp + pyinterp>=2026.2.0 dask - name: Install python dependencies shell: bash -el {0} diff --git a/pyproject.toml b/pyproject.toml index 77343cb..d9e03e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ Repository='https://github.com/robin-cls/fcollections' [project.optional-dependencies] testing = ["pytest", "pytest-cov", "sympy", "beautifulsoup4", "pyftpdlib", "pyasynchat"] -geo = ["shapely", "geopandas", "pyinterp", "dask", "numba"] +geo = ["shapely", "geopandas", "pyinterp>=2026.2.0", "dask", "numba"] doc = ["cartopy", "matplotlib", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx-book-theme", "myst-nb"] @@ -68,5 +68,9 @@ filterwarnings = [ "error", # Can be safely ignored according to # https://github.com/Unidata/netcdf4-python/issues/1354 - "ignore:numpy\\.ndarray size changed" + "ignore:numpy\\.ndarray size changed", + # Can be safely ignored according to + # https://github.com/giampaolo/pyftpdlib/issues/560 + "ignore:The asyncore module is deprecated:DeprecationWarning", + "ignore:The asynchat module is deprecated:DeprecationWarning", ] diff --git a/src/fcollections/geometry/_box.py b/src/fcollections/geometry/_box.py index 03ed482..31f08d5 100644 --- a/src/fcollections/geometry/_box.py +++ b/src/fcollections/geometry/_box.py @@ -1,9 +1,10 @@ +import numpy as np import pyinterp as pyi -import pyinterp.geodetic as pyi_geod import pyinterp.geohash as pyi_geoh +import pyinterp.geometry.geographic as pyi_geom -def expand_box(box: pyi_geod.Box, precision: int) -> pyi_geod.Box: +def expand_box(box: pyi_geom.Box, precision: int) -> pyi_geom.Box: """Expand a geohash box with a given precision. The method looks for the geohashes of the input box's corners with a given @@ -12,24 +13,24 @@ def expand_box(box: pyi_geod.Box, precision: int) -> pyi_geod.Box: Parameters ---------- - box: pyinterp.geodetic.Box + box: geographic.Box the box to expand precision: int the precision to expand the box to Returns ------- - a pyinterp.geodetic.Box expanded to a lower precision + a geographic.Box expanded to a lower precision """ geohashes = pyi_geoh.encode( - [box.min_corner.lon, box.max_corner.lon], - [box.min_corner.lat, box.max_corner.lat], + np.array([box.min_corner.lon, box.max_corner.lon]), + np.array([box.min_corner.lat, box.max_corner.lat]), precision=precision, ) min_lon, min_lat, max_lon, max_lat = (None,) * 4 for g in geohashes: - box = pyi.GeoHash.from_string(g).bounding_box() + box = pyi_geoh.GeoHash.from_string(g.decode()).bounding_box() min_lon = ( min(box.min_corner.lon, min_lon) if min_lon is not None @@ -50,6 +51,4 @@ def expand_box(box: pyi_geod.Box, precision: int) -> pyi_geod.Box: if max_lat is not None else box.max_corner.lat ) - return pyi_geod.Box( - pyi_geod.Point(min_lon, min_lat), pyi_geod.Point(max_lon, max_lat) - ) + return pyi_geom.Box(min_corner=(min_lon, min_lat), max_corner=(max_lon, max_lat)) diff --git a/src/fcollections/geometry/_distances.py b/src/fcollections/geometry/_distances.py index af6dde3..8df50de 100644 --- a/src/fcollections/geometry/_distances.py +++ b/src/fcollections/geometry/_distances.py @@ -1,7 +1,8 @@ """Adapts the distance computation to multiple data shapes.""" import numpy as np -from pyinterp.geodetic import Spheroid, coordinate_distances +from pyinterp.geometry.geographic import Point, Spheroid +from pyinterp.geometry.geographic.algorithms import distance from fcollections.utilities.reshape import slice_along_axis @@ -81,6 +82,16 @@ def distances_along_axis( return distances_along_axis +def _coordinate_distances(lon1, lat1, lon2, lat2, spheroid: Spheroid = Spheroid()): + distances = np.array( + [ + distance(Point(lo1, la1), Point(lo2, la2), spheroid=spheroid) + for lo1, la1, lo2, la2 in zip(lon1, lat1, lon2, lat2) + ] + ) + return distances + + def _spheroid_distances_along_axis( longitudes: np.ndarray, latitudes: np.ndarray, @@ -94,8 +105,8 @@ def _spheroid_distances_along_axis( lat1 = slice_along_axis(latitudes, axis, slice(1, None)) # Compute distance on ellipsoid - return coordinate_distances( - lon0.ravel(), lat0.ravel(), lon1.ravel(), lat1.ravel(), wgs=wgs + return _coordinate_distances( + lon0.ravel(), lat0.ravel(), lon1.ravel(), lat1.ravel(), spheroid=wgs ).reshape(lon0.shape) diff --git a/src/fcollections/geometry/_track_orientation.py b/src/fcollections/geometry/_track_orientation.py index e52f1ff..102f877 100644 --- a/src/fcollections/geometry/_track_orientation.py +++ b/src/fcollections/geometry/_track_orientation.py @@ -3,7 +3,7 @@ import typing as tp import numpy as np -from pyinterp.geodetic import Spheroid +from pyinterp.geometry.geographic import Spheroid from fcollections.utilities.reshape import slice_along_axis diff --git a/tests/geometry/test_box.py b/tests/geometry/test_box.py index d5b7909..4c0a7ee 100644 --- a/tests/geometry/test_box.py +++ b/tests/geometry/test_box.py @@ -1,4 +1,4 @@ -import pyinterp.geodetic as pyi_geod +import pyinterp.geometry.geographic as pyi_geom import pytest from fcollections.geometry import expand_box @@ -18,8 +18,8 @@ def test_expand_box( expected: tuple[tuple[float, float], tuple[float, float]], ): """Test box expansion with a given precision.""" - box = pyi_geod.Box(pyi_geod.Point(*box[0]), pyi_geod.Point(*box[1])) - expected = pyi_geod.Box(pyi_geod.Point(*expected[0]), pyi_geod.Point(*expected[1])) + box = pyi_geom.Box(min_corner=box[0], max_corner=box[1]) + expected = pyi_geom.Box(min_corner=expected[0], max_corner=expected[1]) actual = expand_box(box, precision=3) assert ( diff --git a/tests/geometry/test_distances.py b/tests/geometry/test_distances.py index e005dff..8f2406c 100644 --- a/tests/geometry/test_distances.py +++ b/tests/geometry/test_distances.py @@ -94,7 +94,7 @@ def test_great_circle_distances_axis( assert np.array_equal(computedT.T, computed) -def test_spheroid_distances_along_axis_axis( +def test_spheroid_distances_along_axis( longitudes: np_t.NDArray[np.float64], latitudes: np_t.NDArray[np.float64], ): From b0756d3b0bc1f44fd67e146fd013bf205d26b076 Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Tue, 24 Mar 2026 15:25:31 +0100 Subject: [PATCH 2/9] ci: renew cache at workflow modification --- .github/workflows/doc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 5d3fb48..15d6fe6 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -21,6 +21,7 @@ jobs: with: environment-name: docs cache-environment: true + cache-environment-key: docs-${{ hashFiles('.github/workflows/doc.yaml') }} post-cleanup: 'all' init-shell: bash create-args: > From f3dc678858ffe3604b5f57d3c38e990bf5530a9c Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Tue, 24 Mar 2026 15:40:02 +0100 Subject: [PATCH 3/9] ci: renew cache at workflow modification --- .github/workflows/doc.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 15d6fe6..4d8165c 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -20,8 +20,7 @@ jobs: - uses: mamba-org/setup-micromamba@v2 with: environment-name: docs - cache-environment: true - cache-environment-key: docs-${{ hashFiles('.github/workflows/doc.yaml') }} + cache-environment: false post-cleanup: 'all' init-shell: bash create-args: > From f9644c56d4cd43beb2c8422d9d0530c0d9109c46 Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Tue, 24 Mar 2026 15:55:38 +0100 Subject: [PATCH 4/9] ci: renew cache at workflow modification --- .github/workflows/doc.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 4d8165c..eb83b43 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -85,6 +85,12 @@ jobs: with: path: docs/implementations/data key: samples-${{ hashFiles('docs/implementations/scripts/pull_data*.py') }} + - name: Check pyinterp version + shell: bash -l {0} + run: | + python -c "import pyinterp; print(pyinterp.__version__)" + python -c "import fcollections.geometry" + python -c "import fcollections.implementations.optional" - name: Build Sphinx HTML shell: bash -l {0} run: | From 9dc6e18da16bfc6a160c2073d4008b8a2bdb135e Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Tue, 24 Mar 2026 15:59:57 +0100 Subject: [PATCH 5/9] ci: renew cache at workflow modification --- .github/workflows/doc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index eb83b43..75a8141 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -57,7 +57,7 @@ jobs: - name: Install package (for autodoc) shell: bash -l {0} run: | - pip install -e . + pip install --force-reinstall --no-deps -e . - name: Install AVISO Client shell: bash -l {0} run: | From 6ac73ff6bb051312766c5062a039b519fe0725b0 Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Tue, 24 Mar 2026 16:00:48 +0100 Subject: [PATCH 6/9] ci: force reinstall files-collections from pip --- .github/workflows/doc.yaml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 75a8141..1a29e05 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -20,7 +20,7 @@ jobs: - uses: mamba-org/setup-micromamba@v2 with: environment-name: docs - cache-environment: false + cache-environment: true post-cleanup: 'all' init-shell: bash create-args: > @@ -85,12 +85,6 @@ jobs: with: path: docs/implementations/data key: samples-${{ hashFiles('docs/implementations/scripts/pull_data*.py') }} - - name: Check pyinterp version - shell: bash -l {0} - run: | - python -c "import pyinterp; print(pyinterp.__version__)" - python -c "import fcollections.geometry" - python -c "import fcollections.implementations.optional" - name: Build Sphinx HTML shell: bash -l {0} run: | From 1ddc9041c28507001eb2eaa355df5ed831d66dc6 Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Tue, 24 Mar 2026 16:05:18 +0100 Subject: [PATCH 7/9] ci: force reinstall files-collections from pip --- .github/workflows/doc.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 1a29e05..1f64d6c 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -54,14 +54,19 @@ jobs: geopandas pyinterp>=2026.2.0 dask + - name: Install AVISO Client + shell: bash -l {0} + run: | + pip install altimetry-downloader-aviso - name: Install package (for autodoc) shell: bash -l {0} run: | pip install --force-reinstall --no-deps -e . - - name: Install AVISO Client + - name: Check fcollections source shell: bash -l {0} run: | - pip install altimetry-downloader-aviso + pip show fcollections + pip show altimetry-downloader-aviso - name: Restore cached sample data uses: actions/cache@v4 id: restore_samples From 1ff2a9e1a3ad5f0813d155d0be87fe97aa278451 Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Wed, 25 Mar 2026 12:23:14 +0100 Subject: [PATCH 8/9] ci: restored doc conf --- .github/workflows/doc.yaml | 11 +++-------- tests/geometry/test_distances.py | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 1f64d6c..5d3fb48 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -54,19 +54,14 @@ jobs: geopandas pyinterp>=2026.2.0 dask - - name: Install AVISO Client - shell: bash -l {0} - run: | - pip install altimetry-downloader-aviso - name: Install package (for autodoc) shell: bash -l {0} run: | - pip install --force-reinstall --no-deps -e . - - name: Check fcollections source + pip install -e . + - name: Install AVISO Client shell: bash -l {0} run: | - pip show fcollections - pip show altimetry-downloader-aviso + pip install altimetry-downloader-aviso - name: Restore cached sample data uses: actions/cache@v4 id: restore_samples diff --git a/tests/geometry/test_distances.py b/tests/geometry/test_distances.py index 8f2406c..e005dff 100644 --- a/tests/geometry/test_distances.py +++ b/tests/geometry/test_distances.py @@ -94,7 +94,7 @@ def test_great_circle_distances_axis( assert np.array_equal(computedT.T, computed) -def test_spheroid_distances_along_axis( +def test_spheroid_distances_along_axis_axis( longitudes: np_t.NDArray[np.float64], latitudes: np_t.NDArray[np.float64], ): From 71fd627cf4709293762103aba613747e72c48253 Mon Sep 17 00:00:00 2001 From: "Tonneau Anne-Sophie (CELAD)" Date: Wed, 25 Mar 2026 12:28:02 +0100 Subject: [PATCH 9/9] ci: install altimetry downloader first --- .github/workflows/doc.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 5d3fb48..8018255 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -54,14 +54,14 @@ jobs: geopandas pyinterp>=2026.2.0 dask - - name: Install package (for autodoc) - shell: bash -l {0} - run: | - pip install -e . - name: Install AVISO Client shell: bash -l {0} run: | pip install altimetry-downloader-aviso + - name: Install package (for autodoc) + shell: bash -l {0} + run: | + pip install -e . - name: Restore cached sample data uses: actions/cache@v4 id: restore_samples