mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-07-01 09:19:27 +02:00
fix: Error handling for fits and root finding with numpy instead of autograd.numpy
improved. Tests added.
This commit is contained in:
parent
7f5989dfb9
commit
b14314b424
4 changed files with 53 additions and 10 deletions
|
@ -31,7 +31,10 @@ def find_root(d, func, guess=1.0, **kwargs):
|
|||
|
||||
# Error propagation as detailed in arXiv:1809.01289
|
||||
dx = jacobian(func)(root[0], d.value)
|
||||
da = jacobian(lambda u, v: func(v, u))(d.value, root[0])
|
||||
try:
|
||||
da = jacobian(lambda u, v: func(v, u))(d.value, root[0])
|
||||
except TypeError:
|
||||
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) / (d.value + np.finfo(np.float64).eps) * root[0], [d], man_grad=[deriv])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue