def test_del_default_basis(): m = mdl.Polynomial(n_terms=3, default_x=np.linspace(0, 1, 10)) assert m.default_basis.shape == (3, 10) del m.default_basis m.update_nterms(4) assert m.default_basis.shape == (4, 10) m.update_nterms(2) assert m.default_basis.shape == (2, 10) m.update_nterms(2) assert m.default_basis.shape == (2, 10)
def test_model_fit_intrinsic(): m = mdl.Polynomial(n_terms=2, default_x=np.linspace(0, 1, 10)) fit = m.fit(ydata=np.linspace(0, 1, 10)) assert np.allclose(fit.evaluate(m.default_x), fit.ydata)
def test_get_bad_indx(): m = mdl.Polynomial(n_terms=3) with pytest.raises(ValueError): m.get_basis(x=np.linspace(0, 1, 10), indices=list(range(4)))
def test_no_nterms(): with pytest.raises(ValueError): mdl.Polynomial()
def test_wrong_params(): with pytest.raises(ValueError): mdl.Polynomial(n_terms=5, parameters=(1, 2, 3, 4, 5, 6))