diff --git a/code_formatter.sh b/code_formatter.sh index 90221fa..9b2d981 100755 --- a/code_formatter.sh +++ b/code_formatter.sh @@ -34,7 +34,7 @@ done # Find all python files in code directories python_files="" for dir in $code_directories; do - python_files="$python_files `ls $dir/*.py`" + python_files="$python_files $(find $dir -name '*.py')" done [[ $# != 0 ]] && python_files=$@ diff --git a/pygem/params/ffdparams.py b/pygem/params/ffdparams.py index 7ebab1f..7ccf748 100644 --- a/pygem/params/ffdparams.py +++ b/pygem/params/ffdparams.py @@ -126,7 +126,7 @@ def position_vertices(self): :rtype: numpy.ndarray """ return self.origin_box + np.vstack([ - np.zeros((1, 3)), + np.zeros((1, 3)), self.rotation_matrix.dot(np.diag(self.lenght_box)).T ]) @@ -330,16 +330,17 @@ def save(self, filename, write_deformed=True): if write_deformed: box_points = np.array([ - lattice_x_coords.ravel() + self.array_mu_x.ravel() * - self.lenght_box[0], - lattice_y_coords.ravel() + self.array_mu_y.ravel() * - self.lenght_box[1], - lattice_z_coords.ravel() + self.array_mu_z.ravel() * - self.lenght_box[2] + lattice_x_coords.ravel() + + self.array_mu_x.ravel() * self.lenght_box[0], + lattice_y_coords.ravel() + + self.array_mu_y.ravel() * self.lenght_box[1], + lattice_z_coords.ravel() + + self.array_mu_z.ravel() * self.lenght_box[2] ]) else: box_points = np.array([ - lattice_x_coords.ravel(), lattice_y_coords.ravel(), + lattice_x_coords.ravel(), + lattice_y_coords.ravel(), lattice_z_coords.ravel() ]) diff --git a/pygem/params/rbfparams.py b/pygem/params/rbfparams.py index a6f0ac6..a45892d 100644 --- a/pygem/params/rbfparams.py +++ b/pygem/params/rbfparams.py @@ -10,6 +10,7 @@ import numpy as np + class RBFParameters(object): """ Class that handles the Radial Basis Functions parameters in terms of RBF @@ -41,24 +42,12 @@ def __init__(self): self.basis = 'gaussian_spline' self.radius = 0.5 self.power = 2 - self.original_control_points = np.array([ - [0., 0., 0.], - [0., 0., 1.], - [0., 1., 0.], - [1., 0., 0.], - [0., 1., 1.], - [1., 0., 1.], - [1., 1., 0.], - [1., 1., 1.]]) - self.deformed_control_points = np.array([ - [0., 0., 0.], - [0., 0., 1.], - [0., 1., 0.], - [1., 0., 0.], - [0., 1., 1.], - [1., 0., 1.], - [1., 1., 0.], - [1., 1., 1.]]) + self.original_control_points = np.array( + [[0., 0., 0.], [0., 0., 1.], [0., 1., 0.], [1., 0., 0.], + [0., 1., 1.], [1., 0., 1.], [1., 1., 0.], [1., 1., 1.]]) + self.deformed_control_points = np.array( + [[0., 0., 0.], [0., 0., 1.], [0., 1., 0.], [1., 0., 0.], + [0., 1., 1.], [1., 0., 1.], [1., 1., 0.], [1., 1., 1.]]) @property def n_control_points(self): @@ -108,9 +97,9 @@ def read_parameters(self, filename='parameters_rbf.prm'): if len(lines) != self.n_control_points: raise TypeError("The number of control points must be equal both in" - "the 'original control points' and in the 'deformed" - "control points' section of the parameters file" - "({0!s})".format(filename)) + "the 'original control points' and in the 'deformed" + "control points' section of the parameters file" + "({0!s})".format(filename)) self.deformed_control_points = np.zeros((self.n_control_points, 3)) for line, i in zip(lines, list(range(0, self.n_control_points))): @@ -233,4 +222,3 @@ def save(self, filename, write_deformed=True): else: writer.SetInputData(data) writer.Write() - diff --git a/tests/test_ffdparams.py b/tests/test_ffdparams.py index 92bd762..ee2e1f9 100644 --- a/tests/test_ffdparams.py +++ b/tests/test_ffdparams.py @@ -62,12 +62,8 @@ def test_class_members_default_rotation_matrix(self): def test_class_members_default_position_vertices(self): params = FFDParameters() - expected_matrix = np.array([ - [0., 0., 0.], - [1., 0., 0.], - [0., 1., 0.], - [0., 0., 1.] - ]) + expected_matrix = np.array([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], + [0., 0., 1.]]) np.testing.assert_array_almost_equal(params.position_vertices, expected_matrix) @@ -177,12 +173,10 @@ def test_read_parameters_position_vertex_0_origin(self): def test_read_parameters_position_vertex_0(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') - position_vertices = np.array([ - [-20.0, -55.0, -45.0], - [24.17322326, -52.02107006, -53.05309404], - [-20., 29.41000412, -13.77579136], - [-2.82719042, -85.65053198, 37.85915459] - ]) + position_vertices = np.array( + [[-20.0, -55.0, -45.0], [24.17322326, -52.02107006, -53.05309404], + [-20., 29.41000412, + -13.77579136], [-2.82719042, -85.65053198, 37.85915459]]) np.testing.assert_array_almost_equal(params.position_vertices, position_vertices) @@ -260,22 +254,14 @@ def test_build_bounding_box_2(self): params = FFDParameters() params.build_bounding_box(cube) - expected_matrix = np.array([ - [0., 0., 0.], - [1., 0., 0.], - [0., 1., 0.], - [0., 0., 1.] - ]) + expected_matrix = np.array([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], + [0., 0., 1.]]) np.testing.assert_almost_equal( params.position_vertices, expected_matrix, decimal=5) def test_set_position_of_vertices(self): - expected_matrix = np.array([ - [0., 0., 0.], - [1., 0., 0.], - [0., 1., 0.], - [0., 0., 1.] - ]) + expected_matrix = np.array([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], + [0., 0., 1.]]) tops = np.array([1., 1., 1.]) params = FFDParameters() params.origin_box = expected_matrix[0] diff --git a/tests/test_rbfparams.py b/tests/test_rbfparams.py index 3fb9034..eab6f5d 100644 --- a/tests/test_rbfparams.py +++ b/tests/test_rbfparams.py @@ -6,15 +6,9 @@ from pygem import RBFParameters -unit_cube = np.array([ - [0., 0., 0.], - [0., 0., 1.], - [0., 1., 0.], - [1., 0., 0.], - [0., 1., 1.], - [1., 0., 1.], - [1., 1., 0.], - [1., 1., 1.]]) +unit_cube = np.array([[0., 0., 0.], [0., 0., 1.], [0., 1., 0.], [1., 0., 0.], + [0., 1., 1.], [1., 0., 1.], [1., 1., 0.], [1., 1., 1.]]) + class TestRBFParameters(TestCase): def test_class_members_default_basis(self):