Skip to content

Commit 45ce630

Browse files
committed
revert tests
1 parent 909ea6b commit 45ce630

19 files changed

+568
-928
lines changed

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import matplotlib
22

3-
matplotlib.use("Agg")
3+
matplotlib.use('Agg')

tests/test_bffd.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import filecmp
2+
import os
13
from unittest import TestCase
2-
34
import numpy as np
4-
55
from pygem import BFFD
66

77

@@ -10,29 +10,23 @@ class TestBFFD(TestCase):
1010
def test_nothing_happens_bffd(self):
1111
np.random.seed(0)
1212
original_mesh_points = np.random.rand(100, 3)
13-
np.random.rand(3, original_mesh_points.reshape(-1).shape[0])
13+
A = np.random.rand(3, original_mesh_points.reshape(-1).shape[0])
1414

1515
b = np.mean(original_mesh_points, axis=0)
1616
cffd = BFFD(b)
1717
cffd.adjust_control_points(original_mesh_points)
1818
new_mesh_points = cffd.ffd(original_mesh_points)
19-
assert ( # nosec # nosec
20-
np.linalg.norm(original_mesh_points - new_mesh_points)
21-
/ np.linalg.norm(original_mesh_points)
22-
< 1e-02
23-
)
19+
assert np.linalg.norm(original_mesh_points - new_mesh_points
20+
) / np.linalg.norm(original_mesh_points) < 1e-02
2421

2522
def test_constraint_bffd(self):
2623
np.random.seed(0)
2724
original_mesh_points = np.random.rand(100, 3)
28-
np.random.rand(3, original_mesh_points.reshape(-1).shape[0])
25+
A = np.random.rand(3, original_mesh_points.reshape(-1).shape[0])
2926
b = np.mean(original_mesh_points, axis=0) + 0.02 * np.random.rand(3)
3027
cffd = BFFD(b)
31-
cffd.read_parameters("tests/test_datasets/parameters_test_cffd.prm")
28+
cffd.read_parameters('tests/test_datasets/parameters_test_cffd.prm')
3229
cffd.adjust_control_points(original_mesh_points)
3330
new_mesh_points = cffd.ffd(original_mesh_points)
34-
assert ( # nosec # nosec
35-
np.linalg.norm(b - np.mean(new_mesh_points, axis=0))
36-
/ np.linalg.norm(b)
37-
< 1e-02
38-
)
31+
assert np.linalg.norm(
32+
b - np.mean(new_mesh_points, axis=0)) / np.linalg.norm(b) < 1e-02

tests/test_cffd.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import filecmp
2+
import os
13
from unittest import TestCase
2-
34
import numpy as np
4-
55
from pygem import CFFD
66

77

@@ -20,11 +20,8 @@ def fun(x):
2020
cffd = CFFD(b, fun)
2121
cffd.adjust_control_points(original_mesh_points)
2222
new_mesh_points = cffd.ffd(original_mesh_points)
23-
assert ( # nosec # nosec
24-
np.linalg.norm(original_mesh_points - new_mesh_points)
25-
/ np.linalg.norm(original_mesh_points)
26-
< 1e-02
27-
)
23+
assert np.linalg.norm(original_mesh_points - new_mesh_points
24+
) / np.linalg.norm(original_mesh_points) < 1e-02
2825

2926
def test_constraint_cffd(self):
3027
np.random.seed(0)
@@ -37,9 +34,9 @@ def fun(x):
3734

3835
b = fun(original_mesh_points) + 0.02 * np.random.rand(3)
3936
cffd = CFFD(b, fun)
40-
cffd.read_parameters("tests/test_datasets/parameters_test_cffd.prm")
37+
cffd.read_parameters('tests/test_datasets/parameters_test_cffd.prm')
4138
cffd.adjust_control_points(original_mesh_points)
4239
new_mesh_points = cffd.ffd(original_mesh_points)
43-
assert ( # nosec # nosec
44-
np.linalg.norm(b - fun(new_mesh_points)) / np.linalg.norm(b) < 1e-02
45-
)
40+
assert np.linalg.norm(b -
41+
fun(new_mesh_points)) / np.linalg.norm(b) < 1e-02
42+

tests/test_custom_deformation.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from unittest import TestCase
22

33
import numpy as np
4-
54
from pygem import CustomDeformation
65

76

@@ -21,14 +20,12 @@ def get_cube_mesh_points(self):
2120
def test_class_members_func(self):
2221
def move(x):
2322
return x + x**2
24-
2523
CustomDeformation(move)
2624

2725
def test_ffd_sphere_mod(self):
2826
def move(x):
2927
x0, x1, x2 = x
3028
return [x0**2, x1, x2]
31-
3229
deform = CustomDeformation(move)
3330
mesh_points = self.get_cube_mesh_points()
3431
mesh_points_test = deform(mesh_points)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
from unittest import TestCase
22

3-
from pygem.cad import CADDeformation, CustomDeformation
3+
import numpy as np
4+
from pygem.cad import CustomDeformation
5+
from pygem.cad import CADDeformation
46

57

68
class TestCustomDeformation(TestCase):
79

810
def test_class_members_func(self):
911
def move(x):
1012
return x + x**2
11-
12-
CustomDeformation(move)
13+
deform = CustomDeformation(move)
1314

1415
def test_customdeform_cad_type(self):
1516
def move(x):
1617
x0, x1, x2 = x
1718
return [x0**2, x1, x2]
18-
19-
filename = "tests/test_datasets/test_pipe_hollow.iges"
19+
filename = 'tests/test_datasets/test_pipe_hollow.iges'
2020
orig_shape = CADDeformation.read_shape(filename)
2121
deform = CustomDeformation(move)
2222
new_shape = deform(orig_shape)
23-
assert type(new_shape) == type(orig_shape) # nosec # nosec
23+
assert type(new_shape) == type(orig_shape)

tests/test_elmerhandler.py

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import filecmp
2-
import os
31
from unittest import TestCase
4-
5-
import numpy as np
6-
2+
import unittest
73
import pygem.elmerhandler as elh
4+
import numpy as np
5+
import filecmp
6+
import os
87

98

109
class TestElmerHandler(TestCase):
1110
def test_elmer_instantiation(self):
12-
elh.ElmerHandler()
13-
11+
elmer_handler = elh.ElmerHandler()
12+
1413
def test_elmer_default_infile_member(self):
1514
elmer_handler = elh.ElmerHandler()
1615
self.assertIsNone(elmer_handler.infile)
@@ -21,112 +20,97 @@ def test_elmer_default_outfile_member(self):
2120

2221
def test_elmer_default_extension_member(self):
2322
elmer_handler = elh.ElmerHandler()
24-
self.assertListEqual(elmer_handler.extensions, [".nodes"])
23+
self.assertListEqual(elmer_handler.extensions, ['.nodes'])
2524

2625
def test_elmer_parse_failing_filename_type(self):
2726
elmer_handler = elh.ElmerHandler()
2827
with self.assertRaises(TypeError):
29-
elmer_handler.parse(0.2)
28+
mesh_points = elmer_handler.parse(.2)
3029

3130
def test_elmer_parse_failing_check_extension(self):
3231
elmer_handler = elh.ElmerHandler()
3332
with self.assertRaises(ValueError):
3433
mesh_points = elmer_handler.parse(
35-
"tests/test_datasets/test_square.iges"
36-
)
34+
'tests/test_datasets/test_square.iges')
3735

3836
def test_elmer_parse_infile(self):
3937
elmer_handler = elh.ElmerHandler()
4038
mesh_points = elmer_handler.parse(
41-
"tests/test_datasets/test_elmer.nodes"
42-
)
43-
self.assertEqual(
44-
elmer_handler.infile, "tests/test_datasets/test_elmer.nodes"
45-
)
39+
'tests/test_datasets/test_elmer.nodes')
40+
self.assertEqual(elmer_handler.infile,
41+
'tests/test_datasets/test_elmer.nodes')
4642

4743
def test_elmer_parse_shape(self):
4844
elmer_handler = elh.ElmerHandler()
4945
mesh_points = elmer_handler.parse(
50-
"tests/test_datasets/test_elmer.nodes"
51-
)
46+
'tests/test_datasets/test_elmer.nodes')
5247
self.assertTupleEqual(mesh_points.shape, (240, 3))
5348

5449
def test_elmer_parse_coords_1(self):
5550
elmer_handler = elh.ElmerHandler()
5651
mesh_points = elmer_handler.parse(
57-
"tests/test_datasets/test_elmer.nodes"
58-
)
52+
'tests/test_datasets/test_elmer.nodes')
5953
np.testing.assert_almost_equal(mesh_points[33][0], 2.94650796191)
6054

6155
def test_open_foam_parse_coords_2(self):
6256
elmer_handler = elh.ElmerHandler()
6357
mesh_points = elmer_handler.parse(
64-
"tests/test_datasets/test_elmer.nodes"
65-
)
58+
'tests/test_datasets/test_elmer.nodes')
6659
np.testing.assert_almost_equal(mesh_points[149][1], 2)
6760

6861
def test_elmer_parse_coords_3(self):
6962
elmer_handler = elh.ElmerHandler()
7063
mesh_points = elmer_handler.parse(
71-
"tests/test_datasets/test_elmer.nodes"
72-
)
73-
np.testing.assert_almost_equal(mesh_points[239][2], 0.0)
64+
'tests/test_datasets/test_elmer.nodes')
65+
np.testing.assert_almost_equal(mesh_points[239][2], .0)
7466

7567
def test_elmer_parse_coords_4(self):
7668
elmer_handler = elh.ElmerHandler()
7769
mesh_points = elmer_handler.parse(
78-
"tests/test_datasets/test_elmer.nodes"
79-
)
70+
'tests/test_datasets/test_elmer.nodes')
8071
np.testing.assert_almost_equal(mesh_points[0][0], 0.0)
8172

8273
def test_elmer_parse_coords_5(self):
8374
elmer_handler = elh.ElmerHandler()
8475
mesh_points = elmer_handler.parse(
85-
"tests/test_datasets/test_elmer.nodes"
86-
)
76+
'tests/test_datasets/test_elmer.nodes')
8777
np.testing.assert_almost_equal(mesh_points[-1][1], 2)
8878

8979
def test_elmer_write_failing_filename_type(self):
9080
elmer_handler = elh.ElmerHandler()
9181
mesh_points = elmer_handler.parse(
92-
"tests/test_datasets/test_elmer.nodes"
93-
)
82+
'tests/test_datasets/test_elmer.nodes')
9483
with self.assertRaises(TypeError):
95-
elmer_handler.write(mesh_points, -1.0)
84+
elmer_handler.write(mesh_points, -1.)
9685

9786
def test_elmer_write_failing_check_extension(self):
9887
elmer_handler = elh.ElmerHandler()
9988
mesh_points = elmer_handler.parse(
100-
"tests/test_datasets/test_elmer.nodes"
101-
)
89+
'tests/test_datasets/test_elmer.nodes')
10290
with self.assertRaises(ValueError):
103-
elmer_handler.write(
104-
mesh_points, "tests/test_datasets/test_square.iges"
105-
)
91+
elmer_handler.write(mesh_points,
92+
'tests/test_datasets/test_square.iges')
10693

10794
def test_elmer_write_failing_infile_instantiation(self):
10895
elmer_handler = elh.ElmerHandler()
10996
mesh_points = np.zeros((40, 3))
11097
with self.assertRaises(RuntimeError):
111-
elmer_handler.write(
112-
mesh_points, "tests/test_datasets/test_elmer_out.nodes"
113-
)
98+
elmer_handler.write(mesh_points,
99+
'tests/test_datasets/test_elmer_out.nodes')
114100

115101
def test_elmer_write_outfile(self):
116102
elmer_handler = elh.ElmerHandler()
117103
mesh_points = elmer_handler.parse(
118-
"tests/test_datasets/test_elmer.nodes"
119-
)
120-
outfilename = "tests/test_datasets/test_elmer_out.nodes"
104+
'tests/test_datasets/test_elmer.nodes')
105+
outfilename = 'tests/test_datasets/test_elmer_out.nodes'
121106
elmer_handler.write(mesh_points, outfilename)
122107
self.assertEqual(elmer_handler.outfile, outfilename)
123108
self.addCleanup(os.remove, outfilename)
124109

125110
def test_elmer_write_comparison(self):
126111
elmer_handler = elh.ElmerHandler()
127112
mesh_points = elmer_handler.parse(
128-
"tests/test_datasets/test_elmer.nodes"
129-
)
113+
'tests/test_datasets/test_elmer.nodes')
130114
mesh_points[0] = [0.1, 1.1, 0.1]
131115
mesh_points[1] = [0.1, 1.2, 0.1]
132116
mesh_points[2] = [0.1, 1.6, 0.1]
@@ -136,9 +120,9 @@ def test_elmer_write_comparison(self):
136120
mesh_points[-3] = [26.2, 1.6, 0.1]
137121
mesh_points[-2] = [26.2, 2.01666666667, 0.1]
138122
mesh_points[-1] = [26.2, 2.1, 0.1]
139-
140-
outfilename = "tests/test_datasets/test_elmer_out.nodes"
141-
outfilename_expected = "tests/test_datasets/test_elmer_out_true.nodes"
123+
124+
outfilename = 'tests/test_datasets/test_elmer_out.nodes'
125+
outfilename_expected = 'tests/test_datasets/test_elmer_out_true.nodes'
142126

143127
elmer_handler.write(mesh_points, outfilename)
144128
self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))

0 commit comments

Comments
 (0)