def test_reflect_axis_1(self): params = FFDParameters([3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') params.array_mu_y = np.array( [0.2, 0., 0., 0., 0.5, 0., 0., 0., 0., 0., 0., 0.]).reshape( (3, 2, 2)) params.reflect(axis=1) array_mu_y_exact = np.array([ 0.2, 0., 0., 0., -0.2, -0., 0.5, 0., 0., 0., -0.5, -0., 0., 0., 0., 0., 0., 0. ]).reshape((3, 3, 2)) np.testing.assert_array_almost_equal(params.array_mu_y, array_mu_y_exact)
def test_class_members_default_origin_box(self): params = FFDParameters() assert np.array_equal(params.origin_box, np.zeros(3))
def test_print(self): params = FFDParameters(n_control_points=[3, 2, 2]) print(params)
def test_reflect_wrong_axis(self): params = FFDParameters([2, 3, 5]) with self.assertRaises(ValueError): params.reflect(axis=4)
def test_read_parameters_n_control_points(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') assert np.array_equal(params.n_control_points, [3, 2, 2])
def test_class_members_generic_array_mu_z(self): params = FFDParameters([2, 3, 5]) np.testing.assert_array_almost_equal(params.array_mu_z, np.zeros((2, 3, 5)))
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.]]) np.testing.assert_array_almost_equal(params.position_vertices, expected_matrix)
def test_class_members_default_inv_psi_mapping(self): params = FFDParameters() np.testing.assert_array_almost_equal(params.inv_psi_mapping, np.diag([1, 1, 1]))
def test_read_parameters_inv_psi_mapping(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') inv_psi_mapping_exact = np.diag([45., 90., 90.]) np.testing.assert_array_almost_equal(params.inv_psi_mapping, inv_psi_mapping_exact)
def test_read_parameters_psi_mapping(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') psi_mapping_exact = np.diag([0.02222222, 0.01111111, 0.01111111]) np.testing.assert_array_almost_equal(params.psi_mapping, psi_mapping_exact)
def test_class_members_default_n_control_points(self): params = FFDParameters() assert np.array_equal(params.n_control_points, [2, 2, 2])
def test_read_parameters_rot_angle_x(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') assert np.array_equal(params.rot_angle, [20.3, 11.0, 0.])
def test_read_parameters_origin_box(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') origin_box_exact = np.array([-20.0, -55.0, -45.0]) np.testing.assert_array_almost_equal(params.origin_box, origin_box_exact)
def test_reflect_n_control_points_3(self): params = FFDParameters([2, 3, 5]) params.reflect(axis=2) assert np.array_equal(params.n_control_points, [2, 3, 9])
def test_class_members_default_rot_angle(self): params = FFDParameters() assert np.array_equal(params.rot_angle, np.zeros(3))
def test_read_parameters_position_vertex_0_origin(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') np.testing.assert_array_almost_equal(params.position_vertices[0], params.origin_box)
def test_class_members_default_array_mu_z(self): params = FFDParameters() np.testing.assert_array_almost_equal(params.array_mu_z, np.zeros((2, 2, 2)))
def test_class_members_default_conversion_unit(self): params = FFDParameters() assert params.conversion_unit == 1.
def test_class_members_default_rotation_matrix(self): params = FFDParameters() np.testing.assert_array_almost_equal(params.rotation_matrix, np.eye(3))
def test_write_parameters_failing_filename_type(self): params = FFDParameters(n_control_points=[3, 2, 2]) with self.assertRaises(TypeError): params.write_parameters(5)
def test_class_members_generic_n_control_points(self): params = FFDParameters([2, 3, 5]) assert np.array_equal(params.n_control_points, [2, 3, 5])
def test_write_parameters_filename_default_existance(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.write_parameters() outfilename = 'parameters.prm' assert os.path.isfile(outfilename) os.remove(outfilename)
def test_read_parameters_conversion_unit(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') assert params.conversion_unit == 1.
def test_class_members_default_lenght_box(self): params = FFDParameters() assert np.array_equal(params.lenght_box, np.ones(3))
def test_read_parameters_lenght_box_x(self): params = FFDParameters(n_control_points=[3, 2, 2]) params.read_parameters('tests/test_datasets/parameters_sphere.prm') assert np.array_equal(params.lenght_box, [45.0, 90.0, 90.0])
def test_reflect_box_length_3(self): params = FFDParameters([2, 3, 5]) params.reflect(axis=2) assert params.box_length[2] == 2