diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ae44e3f..9f17944 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,17 +42,23 @@ jobs: if: matrix.experimental == true shell: bash -l {0} run: | + python -m pip install versioneer pkgconfig setuptools-scm; \ + conda uninstall --force-remove -y scipy h5py pyresample pykdtree pandas xarray; \ python -m pip install \ -f https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/ \ + --trusted-host pypi.anaconda.org \ --no-deps --pre --upgrade \ matplotlib \ numpy \ pandas \ scipy; \ python -m pip install \ - --no-deps --upgrade \ + --no-deps --upgrade --pre --no-build-isolation \ git+https://github.com/dask/dask \ git+https://github.com/dask/distributed \ + git+https://github.com/h5py/h5py \ + git+https://github.com/storpipfugl/pykdtree \ + git+https://github.com/pytroll/pyresample \ git+https://github.com/zarr-developers/zarr \ git+https://github.com/pydata/bottleneck \ git+https://github.com/pydata/xarray; diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index e1b4de9..1bf04c3 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -64,9 +64,6 @@ jobs: CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *-manylinux_i686 *-musllinux_i686 *-musllinux_aarch64 *-win32" CIBW_ARCHS: "${{ matrix.cibw_archs }}" CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64" - # below only for building against unstable numpy - CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation" - CIBW_BEFORE_BUILD: "pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy cython setuptools versioneer" - uses: actions/upload-artifact@v4 with: diff --git a/geotiepoints/multilinear.py b/geotiepoints/multilinear.py index 740421d..e6cf5f7 100644 --- a/geotiepoints/multilinear.py +++ b/geotiepoints/multilinear.py @@ -13,7 +13,7 @@ def mlinspace(smin, smax, orders): else: meshes = np.meshgrid( *[np.linspace(smin[i], smax[i], orders[i]) for i in range(len(orders))], indexing='ij') - return np.row_stack([l.flatten() for l in meshes]) + return np.vstack([l.flatten() for l in meshes]) class MultilinearInterpolator: @@ -44,8 +44,8 @@ class MultilinearInterpolator: smax = [1,1] orders = [5,5] - f = lambda x: np.row_stack([np.sqrt( x[0,:]**2 + x[1,:]**2 ), - np.power( x[0,:]**3 + x[1,:]**3, 1.0/3.0 )]) + f = lambda x: np.vstack([np.sqrt( x[0,:]**2 + x[1,:]**2 ), + np.power( x[0,:]**3 + x[1,:]**3, 1.0/3.0 )]) interp = MultilinearInterpolator(smin,smax,orders) interp.set_values( f(interp.grid) ) @@ -59,9 +59,9 @@ class MultilinearInterpolator: __grid__ = None def __init__(self, smin, smax, orders, values=None, dtype=np.float64): - self.smin = np.array(smin, dtype=dtype, copy=False) - self.smax = np.array(smax, dtype=dtype, copy=False) - self.orders = np.array(orders, dtype=np.int_, copy=False) + self.smin = np.asarray(smin, dtype=dtype) + self.smax = np.asarray(smax, dtype=dtype) + self.orders = np.asarray(orders, dtype=np.int_) self.d = len(orders) self.dtype = dtype if values is not None: diff --git a/geotiepoints/tests/test_interpolator.py b/geotiepoints/tests/test_interpolator.py index c342db0..567e686 100644 --- a/geotiepoints/tests/test_interpolator.py +++ b/geotiepoints/tests/test_interpolator.py @@ -349,12 +349,12 @@ def test_interpolate(self, grid_interpolator): fine_x = np.arange(16) fine_y = np.arange(32) - res = grid_interpolator.interpolate((fine_y, fine_x), method="cubic") + res = grid_interpolator.interpolate((fine_y, fine_x), method="cubic_legacy") np.testing.assert_allclose(res, self.expected, atol=2e-9) def test_interpolate_slices(self, grid_interpolator): """Test that interpolation from slices is working.""" - res = grid_interpolator.interpolate_slices((slice(0, 32), slice(0, 16)), method="cubic") + res = grid_interpolator.interpolate_slices((slice(0, 32), slice(0, 16)), method="cubic_legacy") np.testing.assert_allclose(res, self.expected, atol=2e-9) @pytest.mark.parametrize("chunks, expected_chunks", [(10, (10, 10)), @@ -369,7 +369,7 @@ def test_interpolate_dask(self, grid_interpolator, chunks, expected_chunks): with mock.patch.object(grid_interpolator, "interpolate_numpy", wraps=grid_interpolator.interpolate_numpy) as interpolate: - res = grid_interpolator.interpolate((fine_y, fine_x), method="cubic", chunks=chunks) + res = grid_interpolator.interpolate((fine_y, fine_x), method="cubic_legacy", chunks=chunks) assert not interpolate.called assert isinstance(res, da.Array) @@ -395,5 +395,5 @@ def test_interpolate_preserves_dtype(self): fine_x = np.arange(16) fine_y = np.arange(32) - res = grid_interpolator.interpolate((fine_y, fine_x), method="cubic") + res = grid_interpolator.interpolate((fine_y, fine_x), method="cubic_legacy") assert res.dtype == data.dtype diff --git a/geotiepoints/tests/test_modis.py b/geotiepoints/tests/test_modis.py index c039683..b1532ff 100644 --- a/geotiepoints/tests/test_modis.py +++ b/geotiepoints/tests/test_modis.py @@ -20,6 +20,8 @@ import h5py import os +import pytest + FILENAME_250M_RESULT = os.path.join( os.path.dirname(__file__), '../../testdata/250m_lonlat_section_result.h5') FILENAME_250M_INPUT = os.path.join( @@ -68,8 +70,12 @@ def test_5_to_1(self): np.testing.assert_allclose(tlons, glons, atol=0.05) np.testing.assert_allclose(tlats, glats, atol=0.05) - def test_1000m_to_250m(self): + @pytest.mark.parametrize("ncores", [None, 4]) + def test_1000m_to_250m(self, ncores): """Test the 1 km to 250 meter interpolation facility.""" + if ncores: + import multiprocessing as mp + mp.set_start_method("spawn", force=True) with h5py.File(FILENAME_250M_RESULT) as h5f: glons = h5f['longitude'][:] / 1000. @@ -79,10 +85,7 @@ def test_1000m_to_250m(self): lons = h5f['longitude'][:] / 1000. lats = h5f['latitude'][:] / 1000. - tlons, tlats = modis1kmto250m(lons, lats) - np.testing.assert_allclose(tlons, glons, atol=0.05) - np.testing.assert_allclose(tlats, glats, atol=0.05) - - tlons, tlats = modis1kmto250m(lons, lats, cores=4) + kwargs = {"cores": ncores} if ncores is not None else {} + tlons, tlats = modis1kmto250m(lons, lats, **kwargs) np.testing.assert_allclose(tlons, glons, atol=0.05) np.testing.assert_allclose(tlats, glats, atol=0.05) diff --git a/geotiepoints/tests/test_multilinear.py b/geotiepoints/tests/test_multilinear.py index 58300ee..177d418 100644 --- a/geotiepoints/tests/test_multilinear.py +++ b/geotiepoints/tests/test_multilinear.py @@ -70,7 +70,7 @@ def test_multilinear_interp(self): smax = [1, 1] orders = [5, 5] - f = lambda x: np.row_stack([ + f = lambda x: np.vstack([ np.sqrt(x[0, :]**2 + x[1, :]**2), np.power(x[0, :]**3 + x[1, :]**3, 1.0 / 3.0) ]) diff --git a/pyproject.toml b/pyproject.toml index 3deb236..57e52e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools", "wheel", "oldest-supported-numpy", "Cython>=3", "versioneer"] +requires = ["setuptools", "wheel", "numpy>=2.0.0rc1,<3", "Cython>=3", "versioneer"] build-backend = "setuptools.build_meta" [tool.coverage.run]