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
32 changes: 32 additions & 0 deletions tests/test_datasets/parameters_idw_cube.prm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

[Inverse Distance Weighting]
# This section describes the setting of idw.

# the power parameter
power: 2


[Control points]
# This section describes the RBF control points.

# original control points collects the coordinates of the interpolation control
# points before the deformation.
original control points: -.1 0.0 0.0
0.0 0.0 1.0
0.0 1.0 0.0
1.0 0.0 0.0
0.0 1 1.0
1.0 0.0 1.0
1.0 1.0 0
1.0 1.0 1.0

# deformed control points collects the coordinates of the interpolation control
# points after the deformation.
deformed control points: 0.1 0.2 .3
0.0 0.0 1.0
0.0 1.0 0.0
1.0 0.0 0.0
0.0 .8 1.0
1.0 0.0 1.0
1.0 1.0 0.0
1.2 1.2 1.2
12 changes: 10 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@


class TestUtils(TestCase):
def cmp(self, f1, f2):
"""
Check if the two files have the same content, skipping comment lines
"""
content1 = [line for line in open(f1) if not line.startswith('#')]
content2 = [line for line in open(f1) if not line.startswith('#')]
return content1 == content2

def test_utils_write_original_box(self):
params = pars.FFDParameters()
params.read_parameters(
Expand Down Expand Up @@ -45,7 +53,7 @@ def test_utils_check_vtk_original_box(self):

ut.write_bounding_box(params, outfilename, write_deformed=False)

self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
self.assertTrue(self.cmp(outfilename, outfilename_expected))
os.remove(outfilename)

def test_utils_check_vtk_modified_box(self):
Expand All @@ -62,7 +70,7 @@ def test_utils_check_vtk_modified_box(self):

ut.write_bounding_box(params, outfilename)

self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
self.assertTrue(self.cmp(outfilename, outfilename_expected))
os.remove(outfilename)

def test_utils_plot_rbf_control_points(self):
Expand Down
10 changes: 9 additions & 1 deletion tests/test_vtkhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@


class TestVtkHandler(TestCase):
def cmp(self, f1, f2):
"""
Check if the two files have the same content, skipping comment lines
"""
content1 = [line for line in open(f1) if not line.startswith('#')]
content2 = [line for line in open(f1) if not line.startswith('#')]
return content1 == content2

def test_vtk_instantiation(self):
vtk_handler = vh.VtkHandler()

Expand Down Expand Up @@ -139,7 +147,7 @@ def test_vtk_write_comparison(self):
outfilename_expected = 'tests/test_datasets/test_red_blood_cell_out_true_version6.vtk'

vtk_handler.write(mesh_points, outfilename)
self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
self.assertTrue(self.cmp(outfilename, outfilename_expected))
os.remove(outfilename)

def test_vtk_plot_failing_outfile_type(self):
Expand Down
244 changes: 244 additions & 0 deletions tutorials/tutorial-5-idw.ipynb

Large diffs are not rendered by default.