def test_reconstruct_f_biharmonic(self): x, y, xx, yy = sample_data() nd.reconstruct_f(original_input=x, original_output=y, rbf_input=xx, rbf_output=yy, basis='multi_quadratic_biharmonic_spline', radius=10.) # assert that the argmin(xx) nearest to point x=4.5 is the same index # for argmin(yy) nearest to point y=20.25, where y=x*x idx = (np.abs(xx - 4.5)).argmin() idx2 = (np.abs(yy - 20.25)).argmin() assert idx == idx2
def test_reconstruct_f_wendland(self): x, y, xx, yy = sample_data() nd.reconstruct_f(original_input=x, original_output=y, rbf_input=xx, rbf_output=yy, basis='beckert_wendland_c2_basis', radius=20.) # assert that the argmin(xx) nearest to point x=4.5 is the same index # for argmin(yy) nearest to point y=20.25, where y=x*x idx = (np.abs(xx - 4.5)).argmin() idx2 = (np.abs(yy - 20.25)).argmin() assert idx == idx2
def test_reconstruct_f_vectorial(self): x = np.arange(10).reshape(5, 2) y = np.square(x) x_rbf = np.arange(8).reshape(4, 2) y_rbf = np.zeros(x_rbf.shape) nd.reconstruct_f(original_input=x, original_output=y, rbf_input=x_rbf, rbf_output=y_rbf, radius=1.0, basis='beckert_wendland_c2_basis') y_rbf_expected = np.asarray([[0., 1.], [4., 9.], [16., 25.], [36., 49.]]) np.testing.assert_almost_equal(y_rbf, y_rbf_expected)
def test_reconstruct_f_scalar(self): x = np.arange(10) y = x * x x_rbf = np.linspace(0, 9, 5) y_rbf = np.zeros(5) nd.reconstruct_f(original_input=x, original_output=y, rbf_input=x_rbf, rbf_output=y_rbf, basis='beckert_wendland_c2_basis', radius=2.) y_rbf_expected = np.asarray( [0., 4.85579754, 19.1322168, 44.53940674, 81.]) np.testing.assert_almost_equal(y_rbf, y_rbf_expected)