Skip to content

Commit 0c1c483

Browse files
authored
Merge pull request #86 from mtezzele/rbf
test rbf
2 parents f3b26ae + 2480b38 commit 0c1c483

File tree

4 files changed

+78
-11
lines changed

4 files changed

+78
-11
lines changed
188 KB
Binary file not shown.
368 Bytes
Binary file not shown.

tests/test_freeform.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def test_ffd_original_mesh_points_member(self):
2929
def test_ffd_default_modified_mesh_points_member(self):
3030
params = ffdp.FFDParameters()
3131
params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_identity.prm')
32-
params.print_info()
3332
mesh_points = np.load('tests/test_datasets/meshpoints_sphere_orig.npy')
3433
free_form = ffd.FFD(params, mesh_points)
3534
assert free_form.modified_mesh_points == None
@@ -42,16 +41,6 @@ def test_ffd_modified_mesh_points_member(self):
4241
free_form = ffd.FFD(params, mesh_points)
4342
free_form.perform()
4443
np.testing.assert_array_almost_equal(free_form.modified_mesh_points, mesh_points)
45-
46-
47-
def test_ffd_identity(self):
48-
params = ffdp.FFDParameters()
49-
params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_identity.prm')
50-
mesh_points = np.load('tests/test_datasets/meshpoints_sphere_orig.npy')
51-
free_form = ffd.FFD(params, mesh_points)
52-
free_form.perform()
53-
mesh_points_test = free_form.modified_mesh_points
54-
np.testing.assert_array_almost_equal(mesh_points_test, mesh_points)
5544

5645

5746
def test_ffd_sphere_mod(self):

tests/test_radial.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
2+
from unittest import TestCase
3+
import unittest
4+
import pygem.radial as rad
5+
import pygem.params as rbfp
6+
import numpy as np
7+
8+
#parameters_rbf_cube.prm
9+
#parameters_rbf_default.prm
10+
11+
12+
class TestRadial(TestCase):
13+
14+
def get_cube_mesh_points(self):
15+
# Points that define a cube
16+
nx, ny, nz = (20, 20, 20)
17+
mesh = np.zeros((nx * ny * nz, 3))
18+
xv = np.linspace(0, 1, nx)
19+
yv = np.linspace(0, 1, ny)
20+
zv = np.linspace(0, 1, nz)
21+
z, y, x = np.meshgrid(zv, yv, xv)
22+
mesh = np.array([x.ravel(), y.ravel(), z.ravel()])
23+
original_mesh_points = mesh.T
24+
return original_mesh_points
25+
26+
def test_rbf_parameters_member(self):
27+
params = rbfp.RBFParameters()
28+
params.read_parameters(filename='tests/test_datasets/parameters_rbf_default.prm')
29+
rbf = rad.RBF(params, self.get_cube_mesh_points())
30+
assert rbf.parameters == params
31+
32+
33+
def test_rbf_original_mesh_points_member(self):
34+
params = rbfp.RBFParameters()
35+
params.read_parameters(filename='tests/test_datasets/parameters_rbf_default.prm')
36+
rbf = rad.RBF(params, self.get_cube_mesh_points())
37+
np.testing.assert_array_almost_equal(rbf.original_mesh_points, self.get_cube_mesh_points())
38+
39+
40+
def test_rbf_default_modified_mesh_points_member(self):
41+
params = rbfp.RBFParameters()
42+
params.read_parameters(filename='tests/test_datasets/parameters_rbf_default.prm')
43+
rbf = rad.RBF(params, self.get_cube_mesh_points())
44+
assert rbf.modified_mesh_points == None
45+
46+
47+
def test_rbf_modified_mesh_points_member(self):
48+
params = rbfp.RBFParameters()
49+
params.read_parameters(filename='tests/test_datasets/parameters_rbf_default.prm')
50+
rbf = rad.RBF(params, self.get_cube_mesh_points())
51+
rbf.perform()
52+
np.testing.assert_array_almost_equal(rbf.modified_mesh_points, self.get_cube_mesh_points())
53+
54+
55+
def test_rbf_original_mesh_points_member(self):
56+
params = rbfp.RBFParameters()
57+
params.read_parameters(filename='tests/test_datasets/parameters_rbf_cube.prm')
58+
rbf = rad.RBF(params, self.get_cube_mesh_points())
59+
weights_true = np.load('tests/test_datasets/weights_rbf_cube.npy')
60+
np.testing.assert_array_almost_equal(rbf.weights, weights_true)
61+
62+
63+
def test_rbf_cube_mod(self):
64+
params = rbfp.RBFParameters()
65+
params.read_parameters(filename='tests/test_datasets/parameters_rbf_cube.prm')
66+
mesh_points_ref = np.load('tests/test_datasets/meshpoints_cube_mod_rbf.npy')
67+
rbf = rad.RBF(params, self.get_cube_mesh_points())
68+
rbf.perform()
69+
mesh_points_test = rbf.modified_mesh_points
70+
np.testing.assert_array_almost_equal(mesh_points_test, mesh_points_ref)
71+
72+
73+
def test_wrong_basis(self):
74+
params = rbfp.RBFParameters()
75+
params.read_parameters('tests/test_datasets/parameters_rbf_bugged_02.prm')
76+
with self.assertRaises(NameError):
77+
rbf = rad.RBF(params, self.get_cube_mesh_points())
78+

0 commit comments

Comments
 (0)