fix: root module now also works with irregular monte carlo chains

This commit is contained in:
Fabian Joswig 2021-11-26 12:24:38 +00:00
parent f808c2243e
commit b2a249302a
2 changed files with 16 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import scipy.optimize
from autograd import jacobian
from .obs import derived_observable, pseudo_Obs
from .obs import derived_observable
def find_root(d, func, guess=1.0, **kwargs):
@ -33,4 +33,6 @@ def find_root(d, func, guess=1.0, **kwargs):
da = jacobian(lambda u, v: func(v, u))(d.value, root[0])
deriv = - da / dx
return derived_observable(lambda x, **kwargs: x[0], [pseudo_Obs(root, 0.0, d.names[0], d.shape[d.names[0]]), d], man_grad=[0, deriv])
res = derived_observable(lambda x, **kwargs: x[0], [d], man_grad=[deriv])
res._value = root[0]
return res