Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/test_datasets/meshpoints_cube_mod_rbf.npy
Binary file not shown.
Binary file added tests/test_datasets/weights_rbf_cube.npy
Binary file not shown.
11 changes: 0 additions & 11 deletions tests/test_freeform.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def test_ffd_original_mesh_points_member(self):
def test_ffd_default_modified_mesh_points_member(self):
params = ffdp.FFDParameters()
params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_identity.prm')
params.print_info()
mesh_points = np.load('tests/test_datasets/meshpoints_sphere_orig.npy')
free_form = ffd.FFD(params, mesh_points)
assert free_form.modified_mesh_points == None
Expand All @@ -42,16 +41,6 @@ def test_ffd_modified_mesh_points_member(self):
free_form = ffd.FFD(params, mesh_points)
free_form.perform()
np.testing.assert_array_almost_equal(free_form.modified_mesh_points, mesh_points)


def test_ffd_identity(self):
params = ffdp.FFDParameters()
params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_identity.prm')
mesh_points = np.load('tests/test_datasets/meshpoints_sphere_orig.npy')
free_form = ffd.FFD(params, mesh_points)
free_form.perform()
mesh_points_test = free_form.modified_mesh_points
np.testing.assert_array_almost_equal(mesh_points_test, mesh_points)


def test_ffd_sphere_mod(self):
Expand Down
78 changes: 78 additions & 0 deletions tests/test_radial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

from unittest import TestCase
import unittest
import pygem.radial as rad
import pygem.params as rbfp
import numpy as np

#parameters_rbf_cube.prm
#parameters_rbf_default.prm


class TestRadial(TestCase):

def get_cube_mesh_points(self):
# Points that define a cube
nx, ny, nz = (20, 20, 20)
mesh = np.zeros((nx * ny * nz, 3))
xv = np.linspace(0, 1, nx)
yv = np.linspace(0, 1, ny)
zv = np.linspace(0, 1, nz)
z, y, x = np.meshgrid(zv, yv, xv)
mesh = np.array([x.ravel(), y.ravel(), z.ravel()])
original_mesh_points = mesh.T
return original_mesh_points

def test_rbf_parameters_member(self):
params = rbfp.RBFParameters()
params.read_parameters(filename='tests/test_datasets/parameters_rbf_default.prm')
rbf = rad.RBF(params, self.get_cube_mesh_points())
assert rbf.parameters == params


def test_rbf_original_mesh_points_member(self):
params = rbfp.RBFParameters()
params.read_parameters(filename='tests/test_datasets/parameters_rbf_default.prm')
rbf = rad.RBF(params, self.get_cube_mesh_points())
np.testing.assert_array_almost_equal(rbf.original_mesh_points, self.get_cube_mesh_points())


def test_rbf_default_modified_mesh_points_member(self):
params = rbfp.RBFParameters()
params.read_parameters(filename='tests/test_datasets/parameters_rbf_default.prm')
rbf = rad.RBF(params, self.get_cube_mesh_points())
assert rbf.modified_mesh_points == None


def test_rbf_modified_mesh_points_member(self):
params = rbfp.RBFParameters()
params.read_parameters(filename='tests/test_datasets/parameters_rbf_default.prm')
rbf = rad.RBF(params, self.get_cube_mesh_points())
rbf.perform()
np.testing.assert_array_almost_equal(rbf.modified_mesh_points, self.get_cube_mesh_points())


def test_rbf_original_mesh_points_member(self):
params = rbfp.RBFParameters()
params.read_parameters(filename='tests/test_datasets/parameters_rbf_cube.prm')
rbf = rad.RBF(params, self.get_cube_mesh_points())
weights_true = np.load('tests/test_datasets/weights_rbf_cube.npy')
np.testing.assert_array_almost_equal(rbf.weights, weights_true)


def test_rbf_cube_mod(self):
params = rbfp.RBFParameters()
params.read_parameters(filename='tests/test_datasets/parameters_rbf_cube.prm')
mesh_points_ref = np.load('tests/test_datasets/meshpoints_cube_mod_rbf.npy')
rbf = rad.RBF(params, self.get_cube_mesh_points())
rbf.perform()
mesh_points_test = rbf.modified_mesh_points
np.testing.assert_array_almost_equal(mesh_points_test, mesh_points_ref)


def test_wrong_basis(self):
params = rbfp.RBFParameters()
params.read_parameters('tests/test_datasets/parameters_rbf_bugged_02.prm')
with self.assertRaises(NameError):
rbf = rad.RBF(params, self.get_cube_mesh_points())