Skip to content

Commit a89e01e

Browse files
committed
Code formatter script also in submodules
1 parent dc22c21 commit a89e01e

File tree

5 files changed

+33
-64
lines changed

5 files changed

+33
-64
lines changed

code_formatter.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ done
3434
# Find all python files in code directories
3535
python_files=""
3636
for dir in $code_directories; do
37-
python_files="$python_files `ls $dir/*.py`"
37+
python_files="$python_files $(find $dir -name '*.py')"
3838
done
3939
[[ $# != 0 ]] && python_files=$@
4040

pygem/params/ffdparams.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def position_vertices(self):
126126
:rtype: numpy.ndarray
127127
"""
128128
return self.origin_box + np.vstack([
129-
np.zeros((1, 3)),
129+
np.zeros((1, 3)),
130130
self.rotation_matrix.dot(np.diag(self.lenght_box)).T
131131
])
132132

@@ -330,16 +330,17 @@ def save(self, filename, write_deformed=True):
330330

331331
if write_deformed:
332332
box_points = np.array([
333-
lattice_x_coords.ravel() + self.array_mu_x.ravel() *
334-
self.lenght_box[0],
335-
lattice_y_coords.ravel() + self.array_mu_y.ravel() *
336-
self.lenght_box[1],
337-
lattice_z_coords.ravel() + self.array_mu_z.ravel() *
338-
self.lenght_box[2]
333+
lattice_x_coords.ravel() +
334+
self.array_mu_x.ravel() * self.lenght_box[0],
335+
lattice_y_coords.ravel() +
336+
self.array_mu_y.ravel() * self.lenght_box[1],
337+
lattice_z_coords.ravel() +
338+
self.array_mu_z.ravel() * self.lenght_box[2]
339339
])
340340
else:
341341
box_points = np.array([
342-
lattice_x_coords.ravel(), lattice_y_coords.ravel(),
342+
lattice_x_coords.ravel(),
343+
lattice_y_coords.ravel(),
343344
lattice_z_coords.ravel()
344345
])
345346

pygem/params/rbfparams.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import numpy as np
1212

13+
1314
class RBFParameters(object):
1415
"""
1516
Class that handles the Radial Basis Functions parameters in terms of RBF
@@ -41,24 +42,12 @@ def __init__(self):
4142
self.basis = 'gaussian_spline'
4243
self.radius = 0.5
4344
self.power = 2
44-
self.original_control_points = np.array([
45-
[0., 0., 0.],
46-
[0., 0., 1.],
47-
[0., 1., 0.],
48-
[1., 0., 0.],
49-
[0., 1., 1.],
50-
[1., 0., 1.],
51-
[1., 1., 0.],
52-
[1., 1., 1.]])
53-
self.deformed_control_points = np.array([
54-
[0., 0., 0.],
55-
[0., 0., 1.],
56-
[0., 1., 0.],
57-
[1., 0., 0.],
58-
[0., 1., 1.],
59-
[1., 0., 1.],
60-
[1., 1., 0.],
61-
[1., 1., 1.]])
45+
self.original_control_points = np.array(
46+
[[0., 0., 0.], [0., 0., 1.], [0., 1., 0.], [1., 0., 0.],
47+
[0., 1., 1.], [1., 0., 1.], [1., 1., 0.], [1., 1., 1.]])
48+
self.deformed_control_points = np.array(
49+
[[0., 0., 0.], [0., 0., 1.], [0., 1., 0.], [1., 0., 0.],
50+
[0., 1., 1.], [1., 0., 1.], [1., 1., 0.], [1., 1., 1.]])
6251

6352
@property
6453
def n_control_points(self):
@@ -108,9 +97,9 @@ def read_parameters(self, filename='parameters_rbf.prm'):
10897

10998
if len(lines) != self.n_control_points:
11099
raise TypeError("The number of control points must be equal both in"
111-
"the 'original control points' and in the 'deformed"
112-
"control points' section of the parameters file"
113-
"({0!s})".format(filename))
100+
"the 'original control points' and in the 'deformed"
101+
"control points' section of the parameters file"
102+
"({0!s})".format(filename))
114103

115104
self.deformed_control_points = np.zeros((self.n_control_points, 3))
116105
for line, i in zip(lines, list(range(0, self.n_control_points))):
@@ -233,4 +222,3 @@ def save(self, filename, write_deformed=True):
233222
else:
234223
writer.SetInputData(data)
235224
writer.Write()
236-

tests/test_ffdparams.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,8 @@ def test_class_members_default_rotation_matrix(self):
6262

6363
def test_class_members_default_position_vertices(self):
6464
params = FFDParameters()
65-
expected_matrix = np.array([
66-
[0., 0., 0.],
67-
[1., 0., 0.],
68-
[0., 1., 0.],
69-
[0., 0., 1.]
70-
])
65+
expected_matrix = np.array([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.],
66+
[0., 0., 1.]])
7167
np.testing.assert_array_almost_equal(params.position_vertices,
7268
expected_matrix)
7369

@@ -177,12 +173,10 @@ def test_read_parameters_position_vertex_0_origin(self):
177173
def test_read_parameters_position_vertex_0(self):
178174
params = FFDParameters(n_control_points=[3, 2, 2])
179175
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
180-
position_vertices = np.array([
181-
[-20.0, -55.0, -45.0],
182-
[24.17322326, -52.02107006, -53.05309404],
183-
[-20., 29.41000412, -13.77579136],
184-
[-2.82719042, -85.65053198, 37.85915459]
185-
])
176+
position_vertices = np.array(
177+
[[-20.0, -55.0, -45.0], [24.17322326, -52.02107006, -53.05309404],
178+
[-20., 29.41000412,
179+
-13.77579136], [-2.82719042, -85.65053198, 37.85915459]])
186180

187181
np.testing.assert_array_almost_equal(params.position_vertices,
188182
position_vertices)
@@ -260,22 +254,14 @@ def test_build_bounding_box_2(self):
260254
params = FFDParameters()
261255
params.build_bounding_box(cube)
262256

263-
expected_matrix = np.array([
264-
[0., 0., 0.],
265-
[1., 0., 0.],
266-
[0., 1., 0.],
267-
[0., 0., 1.]
268-
])
257+
expected_matrix = np.array([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.],
258+
[0., 0., 1.]])
269259
np.testing.assert_almost_equal(
270260
params.position_vertices, expected_matrix, decimal=5)
271261

272262
def test_set_position_of_vertices(self):
273-
expected_matrix = np.array([
274-
[0., 0., 0.],
275-
[1., 0., 0.],
276-
[0., 1., 0.],
277-
[0., 0., 1.]
278-
])
263+
expected_matrix = np.array([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.],
264+
[0., 0., 1.]])
279265
tops = np.array([1., 1., 1.])
280266
params = FFDParameters()
281267
params.origin_box = expected_matrix[0]

tests/test_rbfparams.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@
66

77
from pygem import RBFParameters
88

9-
unit_cube = np.array([
10-
[0., 0., 0.],
11-
[0., 0., 1.],
12-
[0., 1., 0.],
13-
[1., 0., 0.],
14-
[0., 1., 1.],
15-
[1., 0., 1.],
16-
[1., 1., 0.],
17-
[1., 1., 1.]])
9+
unit_cube = np.array([[0., 0., 0.], [0., 0., 1.], [0., 1., 0.], [1., 0., 0.],
10+
[0., 1., 1.], [1., 0., 1.], [1., 1., 0.], [1., 1., 1.]])
11+
1812

1913
class TestRBFParameters(TestCase):
2014
def test_class_members_default_basis(self):

0 commit comments

Comments
 (0)