Skip to content

Commit

Permalink
fix SciPy matrix for API change
Browse files Browse the repository at this point in the history
This patch changes the argument for cg, gmres, etc. from tol= to rtol= if SciPy
is newer than version 1.12.
https://docs.scipy.org/doc/scipy-1.12.0/release/1.12.0-notes.html#deprecated-features
  • Loading branch information
gertjanvanzwieten committed Jun 25, 2024
1 parent 230aeef commit 381b8b5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nutils/matrix/_scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def mycallback(arg):
if callback:
callback(res)
reformat(100 * numpy.log10(max(atol, res)) / numpy.log10(atol))
lhs, status = solverfun(self.core, rhs, M=precon, tol=0., atol=atol, callback=mycallback, **solverargs)
solverargs['rtol' if scipy.version.version >= '1.12.0' else 'tol'] = 0. # relative tolerance is already factored into atol
lhs, status = solverfun(self.core, rhs, M=precon, atol=atol, callback=mycallback, **solverargs)
if status != 0:
raise Exception('status {}'.format(status))
return lhs
Expand Down

0 comments on commit 381b8b5

Please sign in to comment.