Merge branch 'develop' into documentation

This commit is contained in:
fjosw 2022-05-25 14:21:53 +00:00
commit cf305354d4
3 changed files with 40 additions and 5 deletions

15
.github/workflows/binder.yml vendored Normal file
View file

@ -0,0 +1,15 @@
name: binder
on:
push:
branches:
- develop
jobs:
Create-MyBinderOrg-Cache:
runs-on: ubuntu-latest
steps:
- name: cache binder build on mybinder.org
uses: jupyterhub/repo2docker-action@master
with:
NO_PUSH: true
MYBINDERORG_TAG: ${{ github.event.ref }} # This builds the container on mybinder.org with the branch that was pushed on.

View file

@ -264,9 +264,19 @@ def total_least_squares(x, y, func, silent=False, **kwargs):
fitp = out.beta fitp = out.beta
try: try:
hess_inv = np.linalg.pinv(jacobian(jacobian(odr_chisquare))(np.concatenate((fitp, out.xplus.ravel())))) hess = jacobian(jacobian(odr_chisquare))(np.concatenate((fitp, out.xplus.ravel())))
except TypeError: except TypeError:
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None 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)
if condn > 1e8:
warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.\n \
Maybe try rescaling the problem such that all parameters are of O(1).".format(condn), RuntimeWarning)
try:
hess_inv = np.linalg.inv(hess)
except np.linalg.LinAlgError:
raise Exception("Cannot invert hessian matrix.")
except Exception:
raise Exception("Unkown error in connection with Hessian inverse.")
def odr_chisquare_compact_x(d): def odr_chisquare_compact_x(d):
model = func(d[:n_parms], d[n_parms:n_parms + m].reshape(x_shape)) model = func(d[:n_parms], d[n_parms:n_parms + m].reshape(x_shape))
@ -542,9 +552,19 @@ def _standard_fit(x, y, func, silent=False, **kwargs):
fitp = fit_result.x fitp = fit_result.x
try: try:
hess_inv = np.linalg.pinv(jacobian(jacobian(chisqfunc))(fitp)) hess = jacobian(jacobian(chisqfunc))(fitp)
except TypeError: except TypeError:
raise Exception("It is required to use autograd.numpy instead of numpy within fit functions, see the documentation for details.") from None 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)
if condn > 1e8:
warnings.warn("Hessian matrix might be ill-conditioned ({0:1.2e}), error propagation might be unreliable.\n \
Maybe try rescaling the problem such that all parameters are of O(1).".format(condn), RuntimeWarning)
try:
hess_inv = np.linalg.inv(hess)
except np.linalg.LinAlgError:
raise Exception("Cannot invert hessian matrix.")
except Exception:
raise Exception("Unkown error in connection with Hessian inverse.")
if kwargs.get('correlated_fit') is True: if kwargs.get('correlated_fit') is True:
def chisqfunc_compact(d): def chisqfunc_compact(d):