Skip to content

Commit daef9ef

Browse files
committed
Account for change in scipy solver API
`tol=` -> `rtol=` in SciPy 1.12 http://docs.scipy.org/doc/scipy-1.12.0/release/1.12.0-notes.html#deprecated-features
1 parent 2876d0a commit daef9ef

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fipy/solvers/scipy/scipyKrylovSolver.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77

88
import os
99
import warnings
10+
import scipy
1011

1112
from .scipySolver import ScipySolver
1213
from fipy.tools import numerix
1314
from fipy.tools.timer import Timer
15+
from fipy.tools.version import Version, parse_version
16+
17+
scipy_has_tol = (parse_version(scipy.__version__) < Version("1.12"))
1418

1519
class ScipyKrylovSolver(ScipySolver):
1620
"""
@@ -76,12 +80,17 @@ def _solve_(self, L, x, b):
7680
self._log.debug("BEGIN solve")
7781

7882
with Timer() as t:
83+
if scipy_has_tol:
84+
tolerance = dict(tol=rtol)
85+
else:
86+
tolerance = dict(rtol=rtol)
87+
7988
x, info = self.solveFnc(L, b, x,
80-
tol=rtol,
8189
atol=self.absolute_tolerance,
8290
maxiter=self.iterations,
8391
M=M,
84-
callback=self._countIterations)
92+
callback=self._countIterations,
93+
**tolerance)
8594

8695
self._log.debug("END solve - {} ns".format(t.elapsed))
8796

0 commit comments

Comments
 (0)