[feat] Relax strict autograd.numpy requirement (#285)

* [feat] Relax strict autograd.numpy requirement

* [Fix] Re-impose --Werror for python 3.14 runs after new autograd release
This commit is contained in:
Fabian Joswig 2026-06-30 08:55:49 +02:00 committed by GitHub
commit 229ea45ac7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 71 additions and 17 deletions

View file

@ -481,7 +481,7 @@ def least_squares(x, y, func, priors=None, silent=False, **kwargs):
try:
hess = hessian(chisqfunc)(fitp)
except TypeError:
except (TypeError, ValueError, np.linalg.LinAlgError):
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None
len_y = len(y_f)
@ -722,7 +722,7 @@ def total_least_squares(x, y, func, silent=False, **kwargs):
fitp = out.beta
try:
hess = hessian(odr_chisquare)(np.concatenate((fitp, out.xplusd.ravel())))
except TypeError:
except (TypeError, ValueError, np.linalg.LinAlgError):
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None
def odr_chisquare_compact_x(d):

View file

@ -32,10 +32,10 @@ def find_root(d, func, guess=1.0, **kwargs):
root = scipy.optimize.fsolve(func, guess, d_val)
# Error propagation as detailed in arXiv:1809.01289
dx = jacobian(func)(root[0], d_val)
try:
dx = jacobian(func)(root[0], d_val)
da = jacobian(lambda u, v: func(v, u))(d_val, root[0])
except TypeError:
except (TypeError, ValueError, np.linalg.LinAlgError):
raise Exception("It is required to use autograd.numpy instead of numpy within root functions, see the documentation for details.") from None
deriv = - da / dx
res = derived_observable(lambda x, **kwargs: (x[0] + np.finfo(np.float64).eps) / (np.array(d).reshape(-1)[0].value + np.finfo(np.float64).eps) * root[0],