remove keyword n_parms from fit standard

This commit is contained in:
Fabian Joswig 2021-10-11 09:10:23 +01:00
parent 090a26919b
commit 960fc521c4

View file

@ -14,7 +14,7 @@ from autograd import elementwise_grad as egrad
from .pyerrors import Obs, derived_observable, covariance, pseudo_Obs from .pyerrors import Obs, derived_observable, covariance, pseudo_Obs
def standard_fit(x, y, func,n_parms="auto", silent=False, **kwargs): def standard_fit(x, y, func, silent=False, **kwargs):
"""Performs a non-linear fit to y = func(x) and returns a list of Obs corresponding to the fit parameters. """Performs a non-linear fit to y = func(x) and returns a list of Obs corresponding to the fit parameters.
x has to be a list of floats. x has to be a list of floats.
@ -68,19 +68,16 @@ def standard_fit(x, y, func,n_parms="auto", silent=False, **kwargs):
if not callable(func): if not callable(func):
raise TypeError('func has to be a function.') raise TypeError('func has to be a function.')
if n_parms=="auto": for i in range(25):
for i in range(25): try:
try: func(np.arange(i), x.T[0])
func(np.arange(i), x.T[0]) except:
except: pass
pass else:
else: break
break
n_parms = i n_parms = i
if not silent: if not silent:
print('Fit with', n_parms, 'parameters') print('Fit with', n_parms, 'parameters')