mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-06-30 08:49:28 +02:00
fix: flak8 & pytest
This commit is contained in:
parent
500c5234cf
commit
3d6ec7b397
3 changed files with 54 additions and 59 deletions
BIN
examples/my_db.sqlite
Normal file
BIN
examples/my_db.sqlite
Normal file
Binary file not shown.
|
@ -457,7 +457,6 @@ from .obs import *
|
||||||
from .correlators import *
|
from .correlators import *
|
||||||
from .fits import *
|
from .fits import *
|
||||||
from .misc import *
|
from .misc import *
|
||||||
from . import combined_fits
|
|
||||||
from . import dirac
|
from . import dirac
|
||||||
from . import input
|
from . import input
|
||||||
from . import linalg
|
from . import linalg
|
||||||
|
|
|
@ -70,7 +70,6 @@ class Fit_result(Sequence):
|
||||||
|
|
||||||
def least_squares(x, y, func, priors=None, silent=False, **kwargs):
|
def least_squares(x, y, func, priors=None, silent=False, **kwargs):
|
||||||
r'''Performs a non-linear fit to y = func(x).
|
r'''Performs a non-linear fit to y = func(x).
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
@ -688,6 +687,7 @@ def _standard_fit(x, y, func, silent=False, **kwargs):
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def _combined_fit(x, y, func, silent=False, **kwargs):
|
def _combined_fit(x, y, func, silent=False, **kwargs):
|
||||||
|
|
||||||
if kwargs.get('correlated_fit') is True:
|
if kwargs.get('correlated_fit') is True:
|
||||||
|
@ -803,7 +803,6 @@ def _combined_fit(x,y,func,silent=False,**kwargs):
|
||||||
c2 += len(x_array)
|
c2 += len(x_array)
|
||||||
model = anp.array(func[key](d[:n_parms], x_array))
|
model = anp.array(func[key](d[:n_parms], x_array))
|
||||||
y_obs = y[key]
|
y_obs = y[key]
|
||||||
y_f = [o.value for o in y_obs]
|
|
||||||
dy_f = [o.dvalue for o in y_obs]
|
dy_f = [o.dvalue for o in y_obs]
|
||||||
C_inv = np.diag(np.diag(np.ones((len(x_array), len(x_array))))) / dy_f / dy_f
|
C_inv = np.diag(np.diag(np.ones((len(x_array), len(x_array))))) / dy_f / dy_f
|
||||||
list_tmp.append(anp.sum((d[n_parms + c1:n_parms + c2] - model) @ C_inv @ (d[n_parms + c1:n_parms + c2] - model)))
|
list_tmp.append(anp.sum((d[n_parms + c1:n_parms + c2] - model) @ C_inv @ (d[n_parms + c1:n_parms + c2] - model)))
|
||||||
|
@ -840,7 +839,6 @@ def _combined_fit(x,y,func,silent=False,**kwargs):
|
||||||
except np.linalg.LinAlgError:
|
except np.linalg.LinAlgError:
|
||||||
raise Exception("Cannot invert hessian matrix.")
|
raise Exception("Cannot invert hessian matrix.")
|
||||||
|
|
||||||
|
|
||||||
if kwargs.get('expected_chisquare') is True:
|
if kwargs.get('expected_chisquare') is True:
|
||||||
if kwargs.get('correlated_fit') is not True:
|
if kwargs.get('correlated_fit') is not True:
|
||||||
W = np.diag(1 / np.asarray(dy_f))
|
W = np.diag(1 / np.asarray(dy_f))
|
||||||
|
@ -853,7 +851,6 @@ def _combined_fit(x,y,func,silent=False,**kwargs):
|
||||||
if not silent:
|
if not silent:
|
||||||
print('chisquare/expected_chisquare:', output.chisquare_by_expected_chisquare)
|
print('chisquare/expected_chisquare:', output.chisquare_by_expected_chisquare)
|
||||||
|
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for i in range(n_parms):
|
for i in range(n_parms):
|
||||||
result.append(derived_observable(lambda x_all, **kwargs: (x_all[0] + np.finfo(np.float64).eps) / (y_all[0].value + np.finfo(np.float64).eps) * fitp[i], list(y_all), man_grad=list(deriv_y[i])))
|
result.append(derived_observable(lambda x_all, **kwargs: (x_all[0] + np.finfo(np.float64).eps) / (y_all[0].value + np.finfo(np.float64).eps) * fitp[i], list(y_all), man_grad=list(deriv_y[i])))
|
||||||
|
@ -863,7 +860,6 @@ def _combined_fit(x,y,func,silent=False,**kwargs):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def fit_lin(x, y, **kwargs):
|
def fit_lin(x, y, **kwargs):
|
||||||
"""Performs a linear fit to y = n + m * x and returns two Obs n, m.
|
"""Performs a linear fit to y = n + m * x and returns two Obs n, m.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue