def check_linear_1d(self): x = [1,2,3] y = [0,2,4] lut = UnivariateSpline(x,y,k=1) assert_array_almost_equal(lut.get_knots(),[1,3]) assert_array_almost_equal(lut.get_coeffs(),[0,4]) assert_almost_equal(lut.get_residual(),0.0) assert_array_almost_equal(lut([1,1.5,2]),[0,1,2])
def check_curfit_against_dierckx(self): """ Test against results obtined from the pure fortran routines. Here we check simple spline creation and evaluation. """ x,y = curfit_test['x'],curfit_test['y'] k,s = curfit_test_smth['k'],curfit_test_smth['s'] iopt = curfit_test_smth['iopt'] for i in range(len(k)): if iopt[i] == 0: uspl = UnivariateSpline(x,y,k=k[i],s=s[i]) elif iopt[i] == 1: uspl.set_smoothing_factor(s[i]) assert_almost_equal(uspl.get_residual(), curfit_test_smth['fp'][i], decimal=2) n = uspl._data[7] assert_equal(n,curfit_test_smth['n'][i]) assert_array_almost_equal(around(uspl.get_knots(),1), curfit_test_smth['t'][i][k[i]:n-k[i]]) assert_array_almost_equal(around(uspl.get_coeffs(),4), curfit_test_smth['c'][i], decimal=3) assert_array_almost_equal(around(uspl(x),1), curfit_test_smth['sp'][i])