mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
fix: explicit Exception for combined fit constant edge case. (#202)
This commit is contained in:
parent
6dcd0c3518
commit
5c2a6de56f
2 changed files with 23 additions and 0 deletions
|
@ -1143,6 +1143,23 @@ def test_fit_dof():
|
|||
assert np.all(np.array(cd[1:]) > 0)
|
||||
|
||||
|
||||
def test_combined_fit_constant_shape():
|
||||
N1 = 16
|
||||
N2 = 10
|
||||
x = {"a": np.arange(N1),
|
||||
"": np.arange(N2)}
|
||||
y = {"a": [pe.pseudo_Obs(o + np.random.normal(0.0, 0.1), 0.1, "test") for o in range(N1)],
|
||||
"": [pe.pseudo_Obs(o + np.random.normal(0.0, 0.1), 0.1, "test") for o in range(N2)]}
|
||||
funcs = {"a": lambda a, x: a[0] + a[1] * x,
|
||||
"": lambda a, x: a[1]}
|
||||
with pytest.raises(ValueError):
|
||||
pe.fits.least_squares(x, y, funcs, method='migrad')
|
||||
|
||||
funcs = {"a": lambda a, x: a[0] + a[1] * x,
|
||||
"": lambda a, x: a[1] + x * 0}
|
||||
pe.fits.least_squares(x, y, funcs, method='migrad')
|
||||
|
||||
|
||||
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
Add a link
Reference in a new issue