@@ -86,6 +86,105 @@ def test_class_members_generic_array_mu_z(self):
8686 np .testing .assert_array_almost_equal (params .array_mu_z ,
8787 np .zeros ((2 , 3 , 5 )))
8888
89+ def test_reflect_n_control_points_1 (self ):
90+ params = FFDParameters ([2 , 3 , 5 ])
91+ params .reflect (axis = 0 )
92+ assert np .array_equal (params .n_control_points , [3 , 3 , 5 ])
93+
94+ def test_reflect_n_control_points_2 (self ):
95+ params = FFDParameters ([2 , 3 , 5 ])
96+ params .reflect (axis = 1 )
97+ assert np .array_equal (params .n_control_points , [2 , 5 , 5 ])
98+
99+ def test_reflect_n_control_points_3 (self ):
100+ params = FFDParameters ([2 , 3 , 5 ])
101+ params .reflect (axis = 2 )
102+ assert np .array_equal (params .n_control_points , [2 , 3 , 9 ])
103+
104+ def test_reflect_box_length_1 (self ):
105+ params = FFDParameters ([2 , 3 , 5 ])
106+ params .reflect (axis = 0 )
107+ assert params .lenght_box [0 ] == 2
108+
109+ def test_reflect_box_length_2 (self ):
110+ params = FFDParameters ([2 , 3 , 5 ])
111+ params .reflect (axis = 1 )
112+ assert params .lenght_box [1 ] == 2
113+
114+ def test_reflect_box_length_3 (self ):
115+ params = FFDParameters ([2 , 3 , 5 ])
116+ params .reflect (axis = 2 )
117+ assert params .lenght_box [2 ] == 2
118+
119+ def test_reflect_wrong_axis (self ):
120+ params = FFDParameters ([2 , 3 , 5 ])
121+ with self .assertRaises (ValueError ):
122+ params .reflect (axis = 4 )
123+
124+ def test_reflect_wrong_symmetry_plane_1 (self ):
125+ params = FFDParameters ([3 , 2 , 2 ])
126+ params .read_parameters ('tests/test_datasets/parameters_sphere.prm' )
127+ params .array_mu_x = np .array (
128+ [0.2 , 0. , 0. , 0. , 0.5 , 0. , 0. , 0. , 1. , 0. , 0.3 , 0. ]).reshape ((3 , 2 ,
129+ 2 ))
130+ with self .assertRaises (RuntimeError ):
131+ params .reflect (axis = 0 )
132+
133+ def test_reflect_wrong_symmetry_plane_2 (self ):
134+ params = FFDParameters ([3 , 2 , 2 ])
135+ params .read_parameters ('tests/test_datasets/parameters_sphere.prm' )
136+ params .array_mu_y = np .array (
137+ [0.2 , 0. , 0. , 0. , 0.5 , 0. , 0. , 0. , 1. , 0. , 0.3 , 0. ]).reshape ((3 , 2 ,
138+ 2 ))
139+ with self .assertRaises (RuntimeError ):
140+ params .reflect (axis = 1 )
141+
142+ def test_reflect_wrong_symmetry_plane_3 (self ):
143+ params = FFDParameters ([3 , 2 , 2 ])
144+ params .read_parameters ('tests/test_datasets/parameters_sphere.prm' )
145+ params .array_mu_z = np .array (
146+ [0.2 , 0. , 0. , 0. , 0.5 , 0. , 0. , 0. , 1. , 0. , 0.3 , 0.1 ]).reshape ((3 , 2 ,
147+ 2 ))
148+ with self .assertRaises (RuntimeError ):
149+ params .reflect (axis = 2 )
150+
151+ def test_reflect_axis_0 (self ):
152+ params = FFDParameters ([3 , 2 , 2 ])
153+ params .read_parameters ('tests/test_datasets/parameters_sphere.prm' )
154+ params .array_mu_x = np .array (
155+ [0.2 , 0. , 0. , 0. , 0.5 , 0. , 0. , .2 , 0. , 0. , 0. , 0. ]).reshape ((3 , 2 ,
156+ 2 ))
157+ params .reflect (axis = 0 )
158+ array_mu_x_exact = np .array ([0.2 , 0. , 0. , 0. , 0.5 , 0. , 0. , 0.2 , 0. ,
159+ 0. , 0. , 0. , - 0.5 , - 0. , - 0. , - 0.2 , - 0.2 , - 0. , - 0. , - 0. ]).reshape ((5 , 2 ,
160+ 2 ))
161+ np .testing .assert_array_almost_equal (params .array_mu_x ,
162+ array_mu_x_exact )
163+
164+ def test_reflect_axis_1 (self ):
165+ params = FFDParameters ([3 , 2 , 2 ])
166+ params .read_parameters ('tests/test_datasets/parameters_sphere.prm' )
167+ params .array_mu_y = np .array (
168+ [0.2 , 0. , 0. , 0. , 0.5 , 0. , 0. , 0. , 0. , 0. , 0. , 0. ]).reshape ((3 , 2 ,
169+ 2 ))
170+ params .reflect (axis = 1 )
171+ array_mu_y_exact = np .array ([0.2 , 0. , 0. , 0. , - 0.2 , - 0. , 0.5 , 0. , 0. , 0. ,
172+ - 0.5 , - 0. , 0. , 0. , 0. , 0. , 0. , 0. ]).reshape ((3 , 3 , 2 ))
173+ np .testing .assert_array_almost_equal (params .array_mu_y ,
174+ array_mu_y_exact )
175+
176+ def test_reflect_axis_2 (self ):
177+ params = FFDParameters ([3 , 2 , 2 ])
178+ params .read_parameters ('tests/test_datasets/parameters_sphere.prm' )
179+ params .array_mu_z = np .array (
180+ [0.2 , 0. , 0. , 0. , 0.5 , 0. , 0. , 0. , 0. , 0. , 0. , 0. ]).reshape ((3 , 2 ,
181+ 2 ))
182+ params .reflect (axis = 2 )
183+ array_mu_z_exact = np .array ([0.2 , 0. , - 0.2 , 0. , 0. , 0. , 0.5 , 0. , - 0.5 ,
184+ 0. , 0. , - 0. , 0. , 0. , - 0. , 0. , 0. , - 0. ]).reshape ((3 , 2 , 3 ))
185+ np .testing .assert_array_almost_equal (params .array_mu_z ,
186+ array_mu_z_exact )
187+
89188 def test_read_parameters_conversion_unit (self ):
90189 params = FFDParameters (n_control_points = [3 , 2 , 2 ])
91190 params .read_parameters ('tests/test_datasets/parameters_sphere.prm' )
@@ -119,7 +218,6 @@ def test_read_parameters_array_mu_x(self):
119218 array_mu_x_exact = np .array (
120219 [0.2 , 0. , 0. , 0. , 0.5 , 0. , 0. , 0. , 1. , 0. , 0. , 0. ]).reshape ((3 , 2 ,
121220 2 ))
122- print (params .array_mu_x )
123221 np .testing .assert_array_almost_equal (params .array_mu_x ,
124222 array_mu_x_exact )
125223
0 commit comments