diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 24ea60df..1b77bd7a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,21 @@ Changelog """""""""" +v1.8.7 : Release SciPy restriction +---------------------------------- + +**2025-01-09** + +- Maintenance: + + - Replace ``scipy.interpolate.interpnd`` with ``scipy.interpolate._interpnd`` + (should be a temporary solution, would be better to not use private + modules). + - Fix test failures; they were related to the change of SciPy v1.15 of + ``constants.mu_0`` value changed to the more precise double precision value + (https://github.com/scipy/scipy/pull/11345). + + v1.8.6 : Tmp restrict SciPy --------------------------- diff --git a/emg3d/maps.py b/emg3d/maps.py index bf93022b..10f3ba5d 100644 --- a/emg3d/maps.py +++ b/emg3d/maps.py @@ -24,6 +24,11 @@ import numba as nb import numpy as np import scipy as sp +# Remove if-else once minimum SciPy = 1.15 +if int(sp.__version__.split('.')[1]) < 15: + interpnd = sp.interpolate.interpnd +else: + interpnd = sp.interpolate._interpnd from emg3d.utils import _requires from emg3d.core import _numba_setting @@ -479,8 +484,7 @@ def _points_from_grids(grid, values, xi, method): else: # Replicate the same expansion of xi as used in # RegularGridInterpolator, so the input xi can be quite flexible. - new_points = sp.interpolate.interpnd._ndim_coords_from_arrays( - xi, ndim=3) + new_points = interpnd._ndim_coords_from_arrays(xi, ndim=3) shape = new_points.shape[:-1] new_points = new_points.reshape(-1, 3, order='F') diff --git a/pyproject.toml b/pyproject.toml index c20edf15..8e4c1d2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ authors = [ ] dependencies = [ "numpy", - "scipy (>=1.10,<1.15)", + "scipy>=1.10", "numba", "empymod>=2.3.2", ] diff --git a/tests/test_cli.py b/tests/test_cli.py index f57f7e72..a24db02d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -816,5 +816,5 @@ def test_import_time(script_runner): cmd = ["python", "-Ximporttime", "-c", "import emg3d"] out = script_runner.run(cmd, print_result=False) import_time_s = float(out.stderr.split('|')[-2])/1e6 - # Currently we check t < 2.0 s (really slow, should be < 0.5 s) - assert import_time_s < 2.0 + # Currently we check t < 5.0 s (really slow, should be < 0.5 s) + assert import_time_s < 5.0 diff --git a/tests/test_fields.py b/tests/test_fields.py index ccbe05d3..d6962e50 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -60,7 +60,7 @@ def test_basic(self): # Try setting values ee3.field = ee.field - assert ee3.smu0/ee3.sval == constants.mu_0 + assert_allclose(ee3.smu0/ee3.sval, constants.mu_0) assert ee != ee3 # First has no frequency ee3.fx = ee.fx ee3.fy = ee.fy diff --git a/tests/test_meshes.py b/tests/test_meshes.py index d1e5fd83..1c5ec980 100644 --- a/tests/test_meshes.py +++ b/tests/test_meshes.py @@ -2,6 +2,7 @@ import pytest import numpy as np +import scipy as sp from scipy.constants import mu_0 from numpy.testing import assert_allclose @@ -313,7 +314,13 @@ def test_basics(self, capsys): assert "Comp. dom. DC [m] : -19.8 - 19.8" in out assert "Final extent [m] : -20.0 - 20.0" in out assert "Cell widths [m] : 1.0 / 1.0 / 1.0 [min(DS) / m" in out - assert "Number of cells : 40 (4 / 36 / 0) [Total (DS/" in out + # For scipy<1.15, mu_0 was not precise to double precision. This + # funnily changed the output of this test. + # Remove if-else once minimum SciPy = 1.15 + if int(sp.__version__.split('.')[1]) < 15: + assert "Number of cells : 40 (4 / 36 / 0) [Total (DS/" in out + else: + assert "Number of cells : 40 (2 / 38 / 0) [Total (DS/" in out assert "Max stretching : 1.000 (1.000) / 1.000 [DS (" in out with pytest.warns(FutureWarning, match='`center` will change'):