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)
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)
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)
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)
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)
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)
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()
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()
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()
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)
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)
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)
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()
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()
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)
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()
def test_member_param_nbasis_rake(self): deform = dfm.Deformation('tests/test_datasets/parameters.prm') assert deform.param.nbasis['rake'] == 4
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')
def test_member_param_rake(self): deform = dfm.Deformation('tests/test_datasets/parameters.prm') np.testing.assert_equal(deform.param.parameters['rake'], rake)
def test_member_param_npoints_pitch(self): deform = dfm.Deformation('tests/test_datasets/parameters.prm') assert deform.param.npoints['pitch'] == 400
def test_member_param_skew(self): deform = dfm.Deformation('tests/test_datasets/parameters.prm') np.testing.assert_equal(deform.param.parameters['skew'], skew)
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')
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))
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))
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')
def test_member_param_camber(self): deform = dfm.Deformation('tests/test_datasets/parameters.prm') np.testing.assert_equal(deform.param.parameters['camber'], camber)
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)
def test_member_param_degree_chord(self): deform = dfm.Deformation('tests/test_datasets/parameters.prm') assert deform.param.degree['chord'] == 3
def test_member_control_points_camber_init(self): deform = dfm.Deformation('tests/test_datasets/parameters.prm') assert deform.control_points['camber'] is None
def test_member_param_pitch(self): deform = dfm.Deformation('tests/test_datasets/parameters.prm') np.testing.assert_equal(deform.param.parameters['pitch'], pitch)