mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
fix: multi dim fits fixed in least squares. Test added. (#160)
Co-authored-by: Simon Kuberski <simon.kuberski@uni-muenster.de>
This commit is contained in:
parent
cb289a55ec
commit
82cd2f11ea
2 changed files with 12 additions and 1 deletions
|
@ -554,7 +554,7 @@ def _combined_fit(x, y, func, silent=False, **kwargs):
|
|||
for key in key_ls:
|
||||
if not callable(funcd[key]):
|
||||
raise TypeError('func (key=' + key + ') is not a function.')
|
||||
if len(xd[key]) != len(yd[key]):
|
||||
if np.asarray(xd[key]).shape[-1] != len(yd[key]):
|
||||
raise Exception('x and y input (key=' + key + ') do not have the same length')
|
||||
for i in range(100):
|
||||
try:
|
||||
|
|
|
@ -913,6 +913,17 @@ def test_combined_resplot_qqplot():
|
|||
plt.close('all')
|
||||
|
||||
|
||||
def test_x_multidim_fit():
|
||||
x1 = np.arange(1, 10)
|
||||
x = np.array([[xi, xi] for xi in x1]).T
|
||||
y = [pe.pseudo_Obs(i + 2 / i, .1 * i, 't') for i in x[0]]
|
||||
[o.gm() for o in y]
|
||||
def fitf(a, x):
|
||||
return a[0] * x[0] + a[1] / x[1]
|
||||
|
||||
pe.fits.least_squares(x, y, fitf)
|
||||
|
||||
|
||||
def fit_general(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.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue