Ejemplo n.º 1
0
 def test_deformed_parameters_small_tolerance(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='camber', rbf_points=1000)
     deform.update_control_points(param='camber')
     deform.generate_spline(param='camber')
     with self.assertRaises(ValueError):
         deform.compute_deformed_parameters(param='camber', tol=1e-7)
Ejemplo n.º 2
0
 def test_compute_control_points_rbf_points_not_int(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='pitch', rbf_points=None)
     expected = np.load(
         'tests/test_datasets/pitch_control_points_no_rbf.npy')
     actual = deform.control_points['pitch']
     np.testing.assert_almost_equal(actual, expected)
Ejemplo n.º 3
0
 def test_update_control_points_pitch(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='pitch')
     deform.update_control_points(param='pitch')
     expected = np.load(
         'tests/test_datasets/pitch_updated_control_points.npy')
     actual = deform.control_points['pitch']
     np.testing.assert_almost_equal(actual, expected)
Ejemplo n.º 4
0
 def test_deformed_camber(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='camber', rbf_points=1000)
     deform.update_control_points(param='camber')
     deform.generate_spline(param='camber')
     deform.compute_deformed_parameters(param='camber', tol=1e-2)
     expected = np.load('tests/test_datasets/deformed_camber.npy')
     np.testing.assert_almost_equal(deform.deformed_parameters['camber'],
                                    expected)
Ejemplo n.º 5
0
 def test_export_param_file(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='camber', rbf_points=1000)
     deform.update_control_points(param='camber')
     deform.generate_spline(param='camber')
     deform.compute_deformed_parameters(param='camber', tol=1e-2)
     outfile = 'tests/test_datasets/parameters_mod.prm'
     deform.export_param_file(outfile=outfile)
     self.assertTrue(os.path.isfile(outfile))
     self.addCleanup(os.remove, outfile)
Ejemplo n.º 6
0
 def test_plot_deformed_camber_exception(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     with self.assertRaises(ValueError):
         deform._plot_parametric_curve(param='camber',
                                       original=False,
                                       ctrl_points=False,
                                       spline=False,
                                       rbf=False,
                                       rbf_points=500,
                                       deformed=True,
                                       outfile=None)
Ejemplo n.º 7
0
 def test_plot_skew_rbf(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform._plot_parametric_curve(param='skew',
                                   original=False,
                                   ctrl_points=False,
                                   spline=False,
                                   rbf=True,
                                   rbf_points=500,
                                   deformed=False,
                                   outfile=None)
     plt.close()
Ejemplo n.º 8
0
 def test_plot_pitch_control_points(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='pitch')
     deform._plot_parametric_curve(param='pitch',
                                   original=False,
                                   ctrl_points=True,
                                   spline=False,
                                   rbf=False,
                                   rbf_points=500,
                                   deformed=False,
                                   outfile=None)
     plt.close()
Ejemplo n.º 9
0
 def test_plot_only_one_not_list(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     params = 'chord'
     deform.plot(param=params,
                 original=True,
                 ctrl_points=False,
                 spline=False,
                 rbf=False,
                 rbf_points=500,
                 deformed=False,
                 outfile=None)
     plt.close()
Ejemplo n.º 10
0
 def test_compute_all(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.param.degree['rake'] = 3
     deform.compute_all(rbf_points=1000,
                        tol_chord=1e-3,
                        tol_pitch=1e-3,
                        tol_rake=1e-2,
                        tol_skew=1e-2,
                        tol_camber=1e-2)
     expected = np.load('tests/test_datasets/deformed_camber.npy')
     np.testing.assert_almost_equal(deform.deformed_parameters['camber'],
                                    expected)
Ejemplo n.º 11
0
 def test_plot_save_outfile_not_string(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     outfile = 5
     with self.assertRaises(ValueError):
         deform._plot_parametric_curve(param='chord',
                                       original=True,
                                       ctrl_points=False,
                                       spline=False,
                                       rbf=False,
                                       rbf_points=500,
                                       deformed=False,
                                       outfile=outfile)
Ejemplo n.º 12
0
 def test_plot_save(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     outfile = 'tests/test_datasets/test_plot_temp.png'
     deform._plot_parametric_curve(param='chord',
                                   original=True,
                                   ctrl_points=False,
                                   spline=False,
                                   rbf=False,
                                   rbf_points=500,
                                   deformed=False,
                                   outfile=outfile)
     self.assertTrue(os.path.isfile(outfile))
     self.addCleanup(os.remove, outfile)
Ejemplo n.º 13
0
 def test_plot_rake_spline(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.param.degree['rake'] = 3
     deform.compute_control_points(param='rake')
     deform.generate_spline(param='rake')
     deform._plot_parametric_curve(param='rake',
                                   original=False,
                                   ctrl_points=False,
                                   spline=True,
                                   rbf=False,
                                   rbf_points=500,
                                   deformed=False,
                                   outfile=None)
     plt.close()
Ejemplo n.º 14
0
 def test_plot_deformed_camber(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='camber', rbf_points=1000)
     deform.update_control_points(param='camber')
     deform.generate_spline(param='camber')
     deform.compute_deformed_parameters(param='camber', tol=1e-2)
     deform._plot_parametric_curve(param='camber',
                                   original=False,
                                   ctrl_points=False,
                                   spline=False,
                                   rbf=False,
                                   rbf_points=500,
                                   deformed=True,
                                   outfile=None)
     plt.close()
Ejemplo n.º 15
0
 def test_export_param_file_default_parameters(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='camber', rbf_points=1000)
     deform.update_control_points(param='camber')
     deform.generate_spline(param='camber')
     deform.compute_deformed_parameters(param='camber', tol=1e-2)
     deform.param.deformations['chord'] = np.zeros(deform.param.radii.size)
     outfile = 'tests/test_datasets/parameters_mod.prm'
     deform.export_param_file(outfile=outfile)
     prm = par.ParamFile()
     prm.read_parameters(outfile)
     assert prm.parameters['chord'][1] == deform.param.parameters['chord'][
         1]
     self.assertTrue(os.path.isfile(outfile))
     self.addCleanup(os.remove, outfile)
Ejemplo n.º 16
0
 def test_plot_only_one_list(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     params = ['chord']
     for param in params:
         deform.compute_control_points(param=param, rbf_points=1000)
         deform.update_control_points(param=param)
         deform.generate_spline(param=param)
         deform.compute_deformed_parameters(param=param, tol=1e-2)
     deform.plot(param=params,
                 original=True,
                 ctrl_points=True,
                 spline=True,
                 rbf=False,
                 rbf_points=500,
                 deformed=True,
                 outfile=None)
     plt.close()
Ejemplo n.º 17
0
 def test_member_param_nbasis_rake(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     assert deform.param.nbasis['rake'] == 4
Ejemplo n.º 18
0
 def test_deformed_parameters_incorrect_input(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     with self.assertRaises(ValueError):
         deform.compute_deformed_parameters(param='angle')
Ejemplo n.º 19
0
 def test_member_param_rake(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     np.testing.assert_equal(deform.param.parameters['rake'], rake)
Ejemplo n.º 20
0
 def test_member_param_npoints_pitch(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     assert deform.param.npoints['pitch'] == 400
Ejemplo n.º 21
0
 def test_member_param_skew(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     np.testing.assert_equal(deform.param.parameters['skew'], skew)
Ejemplo n.º 22
0
 def test_deformed_parameters_spline_not_computed(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     with self.assertRaises(ValueError):
         deform.compute_deformed_parameters(param='camber')
Ejemplo n.º 23
0
 def test_member_deformed_parameter_camber_init(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     np.testing.assert_equal(deform.deformed_parameters['camber'],
                             np.zeros(8))
Ejemplo n.º 24
0
 def test_member_param_deformations_skew(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     np.testing.assert_equal(deform.param.deformations['skew'],
                             np.arange(7, 0, -1))
Ejemplo n.º 25
0
 def test_update_control_points_deformations_array_different_length(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     deform.compute_control_points(param='pitch')
     deform.param.deformations['pitch'] = np.arange(4)
     with self.assertRaises(ValueError):
         deform.update_control_points(param='pitch')
Ejemplo n.º 26
0
 def test_member_param_camber(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     np.testing.assert_equal(deform.param.parameters['camber'], camber)
Ejemplo n.º 27
0
 def test_member_deformed_parameter_skew_init(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     expected = np.zeros(8)
     np.testing.assert_equal(deform.deformed_parameters['skew'], expected)
Ejemplo n.º 28
0
 def test_member_param_degree_chord(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     assert deform.param.degree['chord'] == 3
Ejemplo n.º 29
0
 def test_member_control_points_camber_init(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     assert deform.control_points['camber'] is None
Ejemplo n.º 30
0
 def test_member_param_pitch(self):
     deform = dfm.Deformation('tests/test_datasets/parameters.prm')
     np.testing.assert_equal(deform.param.parameters['pitch'], pitch)