Example #1
0
def test_legend_fit():
    # Generate data
    x = np.linspace(0,np.pi,50)
    y = np.sin(x)
    # Fit
    dfit = xafits.func_fit(x, y, 'legendre', 4)
    x2 = np.linspace(0,np.pi,100)
    y2 = xafits.func_val(x2,dfit)
    np.testing.assert_allclose(y2[50], 0.99940823486206976)
Example #2
0
def test_bspline_fit():
    # Generate data
    x = np.linspace(0,np.pi,50)
    y = np.sin(x)
    # Fit
    dfit = xafits.func_fit(x, y, 'bspline', 3, everyn=25)
    x2 = np.linspace(0,np.pi,100)
    y2 = xafits.func_val(x2,dfit)
    np.testing.assert_allclose(y2[50], 0.9941836965580888)
Example #3
0
def test_poly_fit():
    # Generate data
    x = np.linspace(0,np.pi,50)
    y = np.sin(x)
    # Fit
    dfit = xafits.func_fit(x, y, 'polynomial', 3)
    x2 = np.linspace(0,np.pi,100)
    y2 = xafits.func_val(x2,dfit)
    np.testing.assert_allclose(y2[50], 0.97854984428713754)
Example #4
0
def test_bspline_fit():
    # Generate data
    x = np.linspace(0, np.pi, 50)
    y = np.sin(x)
    # Fit
    dfit = xafits.func_fit(x, y, 'bspline', 3, everyn=25)
    x2 = np.linspace(0, np.pi, 100)
    y2 = xafits.func_val(x2, dfit)
    np.testing.assert_allclose(y2[50], 0.9941836965580888)
Example #5
0
def test_legend_fit():
    # Generate data
    x = np.linspace(0, np.pi, 50)
    y = np.sin(x)
    # Fit
    dfit = xafits.func_fit(x, y, 'legendre', 4)
    x2 = np.linspace(0, np.pi, 100)
    y2 = xafits.func_val(x2, dfit)
    np.testing.assert_allclose(y2[50], 0.99940823486206976)
Example #6
0
def test_poly_fit():
    # Generate data
    x = np.linspace(0, np.pi, 50)
    y = np.sin(x)
    # Fit
    dfit = xafits.func_fit(x, y, 'polynomial', 3)
    x2 = np.linspace(0, np.pi, 100)
    y2 = xafits.func_val(x2, dfit)
    np.testing.assert_allclose(y2[50], 0.97854984428713754)
Example #7
0
def test_iter_fit():
    # Generate data
    x = np.linspace(0,np.pi,100)
    y = np.sin(x)
    # 
    y[50] = 3.
    # Fit
    dfit, mask = xafits.iter_fit(x, y, 'bspline', 3, everyn=25)
    assert np.sum(mask) == 1
    x2 = np.linspace(0,np.pi,100)
    y2 = xafits.func_val(x2,dfit)
    np.testing.assert_allclose(y2[50], 0.9991193590298185)
Example #8
0
def test_iter_fit():
    # Generate data
    x = np.linspace(0, np.pi, 100)
    y = np.sin(x)
    #
    y[50] = 3.
    # Fit
    dfit, mask = xafits.iter_fit(x, y, 'bspline', 3, everyn=25)
    assert np.sum(mask) == 1
    x2 = np.linspace(0, np.pi, 100)
    y2 = xafits.func_val(x2, dfit)
    np.testing.assert_allclose(y2[50], 0.9991193590298185)