mirror of
https://github.com/fjosw/pyerrors.git
synced 2026-08-04 11:31:21 +02:00
[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:
parent
30d109413d
commit
229ea45ac7
5 changed files with 71 additions and 17 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue