mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
fix: no-autograd exception in fits works again.
This commit is contained in:
parent
9ad0146d96
commit
967ddb0ecd
1 changed files with 8 additions and 6 deletions
|
@ -263,14 +263,15 @@ def total_least_squares(x, y, func, silent=False, **kwargs):
|
||||||
output.chisquare_by_expected_chisquare)
|
output.chisquare_by_expected_chisquare)
|
||||||
|
|
||||||
fitp = out.beta
|
fitp = out.beta
|
||||||
|
try:
|
||||||
hess = jacobian(jacobian(odr_chisquare))(np.concatenate((fitp, out.xplus.ravel())))
|
hess = jacobian(jacobian(odr_chisquare))(np.concatenate((fitp, out.xplus.ravel())))
|
||||||
|
except TypeError:
|
||||||
|
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None
|
||||||
condn = np.linalg.cond(hess)
|
condn = np.linalg.cond(hess)
|
||||||
if condn > 1e8:
|
if condn > 1e8:
|
||||||
warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.".format(condn), RuntimeWarning)
|
warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.".format(condn), RuntimeWarning)
|
||||||
try:
|
try:
|
||||||
hess_inv = np.linalg.inv(hess)
|
hess_inv = np.linalg.inv(hess)
|
||||||
except TypeError:
|
|
||||||
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None
|
|
||||||
except np.linalg.LinAlgError:
|
except np.linalg.LinAlgError:
|
||||||
raise Exception("Cannot invert hessian matrix.")
|
raise Exception("Cannot invert hessian matrix.")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -549,14 +550,15 @@ def _standard_fit(x, y, func, silent=False, **kwargs):
|
||||||
output.chisquare_by_expected_chisquare)
|
output.chisquare_by_expected_chisquare)
|
||||||
|
|
||||||
fitp = fit_result.x
|
fitp = fit_result.x
|
||||||
|
try:
|
||||||
hess = jacobian(jacobian(chisqfunc))(fitp)
|
hess = jacobian(jacobian(chisqfunc))(fitp)
|
||||||
|
except TypeError:
|
||||||
|
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None
|
||||||
condn = np.linalg.cond(hess)
|
condn = np.linalg.cond(hess)
|
||||||
if condn > 1e8:
|
if condn > 1e8:
|
||||||
warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.".format(condn), RuntimeWarning)
|
warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.".format(condn), RuntimeWarning)
|
||||||
try:
|
try:
|
||||||
hess_inv = np.linalg.inv(hess)
|
hess_inv = np.linalg.inv(hess)
|
||||||
except TypeError:
|
|
||||||
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None
|
|
||||||
except np.linalg.LinAlgError:
|
except np.linalg.LinAlgError:
|
||||||
raise Exception("Cannot invert hessian matrix.")
|
raise Exception("Cannot invert hessian matrix.")
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue