Skip to content

Commit 1478065

Browse files
authored
interpdn / SciPy>=1.15 (#353)
1 parent f9d2831 commit 1478065

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

CHANGELOG.rst

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ Changelog
66
""""""""""
77

88

9+
v1.8.7 : Release SciPy restriction
10+
----------------------------------
11+
12+
**2025-01-09**
13+
14+
- Maintenance:
15+
16+
- Replace ``scipy.interpolate.interpnd`` with ``scipy.interpolate._interpnd``
17+
(should be a temporary solution, would be better to not use private
18+
modules).
19+
- Fix test failures; they were related to the change of SciPy v1.15 of
20+
``constants.mu_0`` value changed to the more precise double precision value
21+
(https://github.com/scipy/scipy/pull/11345).
22+
23+
924
v1.8.6 : Tmp restrict SciPy
1025
---------------------------
1126

emg3d/maps.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
import numba as nb
2525
import numpy as np
2626
import scipy as sp
27+
# Remove if-else once minimum SciPy = 1.15
28+
if int(sp.__version__.split('.')[1]) < 15:
29+
interpnd = sp.interpolate.interpnd
30+
else:
31+
interpnd = sp.interpolate._interpnd
2732

2833
from emg3d.utils import _requires
2934
from emg3d.core import _numba_setting
@@ -479,8 +484,7 @@ def _points_from_grids(grid, values, xi, method):
479484
else:
480485
# Replicate the same expansion of xi as used in
481486
# RegularGridInterpolator, so the input xi can be quite flexible.
482-
new_points = sp.interpolate.interpnd._ndim_coords_from_arrays(
483-
xi, ndim=3)
487+
new_points = interpnd._ndim_coords_from_arrays(xi, ndim=3)
484488
shape = new_points.shape[:-1]
485489
new_points = new_points.reshape(-1, 3, order='F')
486490

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ authors = [
1212
]
1313
dependencies = [
1414
"numpy",
15-
"scipy (>=1.10,<1.15)",
15+
"scipy>=1.10",
1616
"numba",
1717
"empymod>=2.3.2",
1818
]

tests/test_cli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -816,5 +816,5 @@ def test_import_time(script_runner):
816816
cmd = ["python", "-Ximporttime", "-c", "import emg3d"]
817817
out = script_runner.run(cmd, print_result=False)
818818
import_time_s = float(out.stderr.split('|')[-2])/1e6
819-
# Currently we check t < 2.0 s (really slow, should be < 0.5 s)
820-
assert import_time_s < 2.0
819+
# Currently we check t < 5.0 s (really slow, should be < 0.5 s)
820+
assert import_time_s < 5.0

tests/test_fields.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_basic(self):
6060

6161
# Try setting values
6262
ee3.field = ee.field
63-
assert ee3.smu0/ee3.sval == constants.mu_0
63+
assert_allclose(ee3.smu0/ee3.sval, constants.mu_0)
6464
assert ee != ee3 # First has no frequency
6565
ee3.fx = ee.fx
6666
ee3.fy = ee.fy

tests/test_meshes.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44
import numpy as np
5+
import scipy as sp
56
from scipy.constants import mu_0
67
from numpy.testing import assert_allclose
78

@@ -313,7 +314,13 @@ def test_basics(self, capsys):
313314
assert "Comp. dom. DC [m] : -19.8 - 19.8" in out
314315
assert "Final extent [m] : -20.0 - 20.0" in out
315316
assert "Cell widths [m] : 1.0 / 1.0 / 1.0 [min(DS) / m" in out
316-
assert "Number of cells : 40 (4 / 36 / 0) [Total (DS/" in out
317+
# For scipy<1.15, mu_0 was not precise to double precision. This
318+
# funnily changed the output of this test.
319+
# Remove if-else once minimum SciPy = 1.15
320+
if int(sp.__version__.split('.')[1]) < 15:
321+
assert "Number of cells : 40 (4 / 36 / 0) [Total (DS/" in out
322+
else:
323+
assert "Number of cells : 40 (2 / 38 / 0) [Total (DS/" in out
317324
assert "Max stretching : 1.000 (1.000) / 1.000 [DS (" in out
318325

319326
with pytest.warns(FutureWarning, match='`center` will change'):

0 commit comments

Comments
 (0)