Skip to content

Commit

Permalink
interpdn / SciPy>=1.15 (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
prisae authored Jan 9, 2025
1 parent f9d2831 commit 1478065
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------------

Expand Down
8 changes: 6 additions & 2 deletions emg3d/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
]
dependencies = [
"numpy",
"scipy (>=1.10,<1.15)",
"scipy>=1.10",
"numba",
"empymod>=2.3.2",
]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion tests/test_meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'):
Expand Down

0 comments on commit 1478065

Please sign in to comment.