Skip to content

Commit

Permalink
Add a test of spline
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeiOssokine committed Apr 4, 2023
1 parent fd2f77f commit 2e2f98b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/test_spline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import numpy as np
from pygsl_lite import spline

def test_cubic_spline():
t_old = np.linspace(-2*np.pi,2*np.pi,50)
y_old = np.cos(t_old)
n = len(t_old)
intrp = spline.cspline(n)
intrp.init(t_old, y_old)
t_new = np.linspace(-2*np.pi,2*np.pi,200)
y_interp = intrp.eval_e_vector(t_new)
assert np.abs(np.sum(y_interp)-0.9878615069653094)<1e-8,"Interpolation test failed"

0 comments on commit 2e2f98b

Please sign in to comment.