Exemplo n.º 1
0
 def test_iges_write_modified_tolerance(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     outfilename = 'tests/test_datasets/test_pipe_out.iges'
     iges_handler.write(mesh_points, outfilename, 1e-3)
     assert iges_handler.outfile == outfilename
     os.remove(outfilename)
 def test_iges_write_shape_to_file_igs(self):
     ihp = BRepPrimAPI_MakeBox(1., 1., 1.).Shape()
     path = 'tests/test_datasets/x.igs'
     iges_handler = ih.IgesHandler()
     iges_handler.write_shape_to_file(ihp, path)
     self.assertTrue(os.path.exists(path))
     self.addCleanup(os.remove, path)
 def test_iges_write_modified_tolerance(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     outfilename = 'tests/test_datasets/test_pipe_out.iges'
     iges_handler.write(mesh_points, outfilename, 1e-3)
     self.assertEqual(iges_handler.outfile, outfilename)
     self.addCleanup(os.remove, outfilename)
Exemplo n.º 4
0
	def precompute_active_subspace(self):
		import active_subspaces as ac
		import numpy as np
		import pygem.igeshandler as ih

		X1, fX1 = read_input_output("input_output_total", dF=False)
		self.ss = ac.subspaces.Subspaces()

		#Estimated gradients using local linear models
		dfX0 = ac.gradients.local_linear_gradients(X1, fX1)#, p=15) 

		self.ss.compute(df=dfX0, nboot=1000)
		self.ss.partition(2)

		RS = ac.utils.response_surfaces.PolynomialApproximation(3)
		#Train the surface with active variable values (y = XX.dot(self.ss.W1)) and function values (f)
		y1 = X1.dot(self.ss.W1)
		RS.train(y1, fX1)

		avdom = ac.domains.BoundedActiveVariableDomain(self.ss)
		avmap = ac.domains.BoundedActiveVariableMap(avdom)
		self.asrs = ac.response_surfaces.ActiveSubspaceResponseSurface(avmap=avmap, respsurf=RS)

		# Since we have to load only one time the original mesh we put it here
		self.original_mesh_points = np.load('goteborg_original.npy')

		self.handler = ih.IgesHandler()
		self.handler.infile = 'goteborg_original.iges'
		self.handler._control_point_position = np.load('control_position.npy').tolist()
		self.handler.shape = self.handler.load_shape_from_file('goteborg_original.iges')
Exemplo n.º 5
0
    def test_iges_write_comparison_igs(self):
        iges_handler = ih.IgesHandler()
        mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.igs')
        mesh_points[0][0] = 2.2
        mesh_points[5][1] = 4.3
        mesh_points[9][2] = 0.5
        mesh_points[12][0] = 7.2
        mesh_points[16][1] = -1.2
        mesh_points[31][2] = -3.6

        outfilename = 'tests/test_datasets/test_pipe_out.igs'
        outfilename_expected = 'tests/test_datasets/test_pipe_out_true.igs'

        iges_handler.write(mesh_points, outfilename)

        mesh_points = iges_handler.parse(outfilename)
        mesh_points_expected = iges_handler.parse(outfilename_expected)
        np.testing.assert_array_almost_equal(mesh_points, mesh_points_expected)
        os.remove(outfilename)
Exemplo n.º 6
0
 def test_iges_parse_failing_filename_type(self):
     iges_handler = ih.IgesHandler()
     with self.assertRaises(TypeError):
         mesh_points = iges_handler.parse(5.2)
Exemplo n.º 7
0
 def test_iges_default_tolerance(self):
     iges_handler = ih.IgesHandler()
     assert iges_handler.tolerance == 1e-6
Exemplo n.º 8
0
 def test_iges_default_extension_member(self):
     iges_handler = ih.IgesHandler()
     assert iges_handler.extension == ['.iges', '.igs']
Exemplo n.º 9
0
 def test_iges_show_failing_outfile_type(self):
     iges_handler = ih.IgesHandler()
     with self.assertRaises(TypeError):
         iges_handler.show(show_file=1.1)
Exemplo n.º 10
0
 def test_iges_default_outfile_member(self):
     iges_handler = ih.IgesHandler()
     assert iges_handler.outfile == None
Exemplo n.º 11
0
 def test_iges_parse_control_point_position_member(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     assert iges_handler._control_point_position == [
         0, 6, 12, 18, 24, 28, 32
     ]
 def test_iges_write_shape_to_file_raises_wrong_extension(self):
     iges_handler = ih.IgesHandler()
     with self.assertRaises(ValueError):
         iges_handler.load_shape_from_file('tests/test_datasets/x.stp')
Exemplo n.º 13
0
 def test_iges_parse_coords_2(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     np.testing.assert_almost_equal(mesh_points[8][1], 999.99999997448208)
Exemplo n.º 14
0
 def test_iges_parse_coords_5_igs(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.igs')
     np.testing.assert_almost_equal(mesh_points[-1][2], 10000.0)
Exemplo n.º 15
0
 def test_iges_write_failing_infile_instantiation(self):
     iges_handler = ih.IgesHandler()
     mesh_points = np.zeros((20, 3))
     with self.assertRaises(RuntimeError):
         iges_handler.write(mesh_points,
                            'tests/test_datasets/test_pipe_out.iges')
 def test_iges_load_shape_from_file_raises_wrong_type(self):
     iges_handler = ih.IgesHandler()
     with self.assertRaises(TypeError):
         iges_handler.load_shape_from_file(None)
Exemplo n.º 17
0
 def test_iges_write_failing_check_extension(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     with self.assertRaises(ValueError):
         iges_handler.write(mesh_points,
                            'tests/test_datasets/test_square.stl')
 def test_iges_parse_shape_igs(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.igs')
     self.assertTupleEqual(mesh_points.shape, (32, 3))
 def test_iges_load_shape_correct_igs(self):
     iges_handler = ih.IgesHandler()
     shape = iges_handler.load_shape_from_file(
         'tests/test_datasets/test_pipe.igs')
     self.assertEqual(type(shape), TopoDS_Compound)
Exemplo n.º 20
0
 def test_iges_parse_failing_check_extension(self):
     iges_handler = ih.IgesHandler()
     with self.assertRaises(ValueError):
         mesh_points = iges_handler.parse(
             'tests/test_datasets/test_pipe.vtk')
 def test_iges_default_extension_member(self):
     iges_handler = ih.IgesHandler()
     self.assertListEqual(iges_handler.extensions, ['.iges', '.igs'])
Exemplo n.º 22
0
 def test_iges_parse_infile(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     assert iges_handler.infile == 'tests/test_datasets/test_pipe.iges'
Exemplo n.º 23
0
 def test_iges_plot_failing_outfile_type(self):
     iges_handler = ih.IgesHandler()
     with self.assertRaises(TypeError):
         iges_handler.plot(plot_file=3)
Exemplo n.º 24
0
 def test_iges_parse_shape_igs(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.igs')
     assert mesh_points.shape == (32, 3)
 def test_iges_write_shape_to_file_raises_wrong_type(self):
     iges_handler = ih.IgesHandler()
     with self.assertRaises(TypeError):
         iges_handler.write_shape_to_file(None, None)
Exemplo n.º 26
0
 def test_iges_instantiation(self):
     iges_handler = ih.IgesHandler()
Exemplo n.º 27
0
 def test_iges_default_control_point_position_member(self):
     iges_handler = ih.IgesHandler()
     assert iges_handler._control_point_position == None
Exemplo n.º 28
0
 def test_iges_write_failing_filename_type(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     with self.assertRaises(TypeError):
         iges_handler.write(mesh_points, -2)
Exemplo n.º 29
0
 def test_iges_plot_save_fig(self):
     iges_handler = ih.IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     iges_handler.plot(save_fig=True)
     self.assertTrue(os.path.isfile('tests/test_datasets/test_pipe.png'))
     os.remove('tests/test_datasets/test_pipe.png')