Example #1
0
 def test_vtk_set_dataset_wrong_datatype(self):
     mesh_points = fh.FileHandler(
         'tests/test_datasets/matlab_field_test_bin.vtk').get_dataset(
             'Pressure')
     with self.assertRaises(ValueError):
         fh.FileHandler(
             'tests/test_datasets/matlab_field_test_bin.vtk').set_dataset(
                 mesh_points, 'Pressure', 'faces')
Example #2
0
    def test_vtk_write0(self):
        outfilename = 'tests/test_datasets/matlab_field_test_bin_write.vtk'
        read_handl = fh.FileHandler(
            'tests/test_datasets/matlab_field_test_bin.vtk')
        points, cells = read_handl.get_geometry(get_cells=True)

        write_handl = fh.FileHandler(outfilename)
        write_handl.set_geometry(points, cells)
        os.remove(outfilename)
Example #3
0
    def test_stl_write_comparison(self):
        output = fh.FileHandler(mat_file).get_dataset('output')
        output[0] = [1.1]
        output[1] = [1.1]
        output[2] = [1.1]
        output[11] = [1.1]
        output[12] = [1.1]
        output[13] = [1.1]
        output[30] = [1.1]
        output[31] = [1.1]
        output[32] = [1.1]

        outfilename = 'tests/test_datasets/matlab_output_test_out.mat'

        fh.FileHandler(outfilename).set_dataset(output, 'output')
        os.remove(outfilename)
Example #4
0
	def test_vtk_list_output_point(self):
		read_handl = fh.FileHandler(
			'tests/test_datasets/matlab_field_test_bin.vtk'
		)
		out_point, out_cell = read_handl.get_all_output_names()
		expected_out = ['Velocity', 'Pressure']
		assert (out_point == expected_out)
Example #5
0
	def test_vtk_list_output_cell(self):
		read_handl = fh.FileHandler(
			'tests/test_datasets/openfoam_output_test.vtk'
		)
		out_point, out_cell = read_handl.get_all_output_names()
		expected_out = ['cellID', 'p', 'U']
		assert (out_cell == expected_out)
Example #6
0
	def test_vtk_write_failing_filename_type(self):
		handler = fh.FileHandler(
			'tests/test_datasets/matlab_field_test_bin.vtk'
		)
		output = handler.get_dataset('Pressure')
		with self.assertRaises(TypeError):
			handler.set_dataset(output, 4.)
Example #7
0
    def test_stl_set_geometry_comparison(self):
        mesh_points, cells = fh.FileHandler(stl_file).get_geometry(
            get_cells=True)
        mesh_points[0] = [-40.2, -20.5, 60.9]
        mesh_points[1] = [-40.2, -10.5, 60.9]
        mesh_points[2] = [-40.2, -10.5, 60.9]
        mesh_points[50] = [-40.2, -20.5, 60.9]
        mesh_points[51] = [-40.2, -10.5, 60.9]
        mesh_points[52] = [-40.2, -10.5, 60.9]
        mesh_points[126] = [-40.2, -20.5, 60.9]
        mesh_points[127] = [-40.2, -10.5, 60.9]
        mesh_points[128] = [-40.2, -10.5, 60.9]

        outfilename = 'tests/test_datasets/test_sphere_out.stl'
        outfilename_expected = 'tests/test_datasets/test_sphere_out_true.stl'

        fh.FileHandler(outfilename).set_geometry(mesh_points, cells)
        self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
        os.remove(outfilename)
Example #8
0
 def test_stl_get_geometry_coords_5_bin(self):
     mesh_points = fh.FileHandler(stl_file).get_geometry()[0]
     np.testing.assert_almost_equal(mesh_points[-1, 2], -0.45048400)
Example #9
0
 def test_mat_parse_failing_output_name_type(self):
     with self.assertRaises(TypeError):
         output = fh.FileHandler(mat_file).get_dataset(5.2)
Example #10
0
 def test_stl_get_geometry_coords_2(self):
     mesh_points = fh.FileHandler(stl_file).get_geometry()[0]
     expected_coordinates = np.array([-0.25, -0.433012992, 0])
     np.testing.assert_array_almost_equal(mesh_points[147],
                                          expected_coordinates)
Example #11
0
 def test_stl_get_geometry_coords_3(self):
     cells = fh.FileHandler(stl_file).get_geometry(get_cells=True)[1]
     expected_list = [19, 17, 20]
     assert (expected_list == cells[17])
Example #12
0
	def test_file_available_ext(self):
		with self.assertRaises(TypeError):
			handler = fh.FileHandler('inexistent_file.pdf')
Example #13
0
 def test_base_class_infile(self):
     file_handler = fh.FileHandler()
     assert file_handler.infile == None
Example #14
0
 def test_mat_get_dataset_coords_1(self):
     output = fh.FileHandler(mat_file).get_dataset('output')
     np.testing.assert_almost_equal(output[33][0], 16.8143769)
Example #15
0
 def test_vtk_instantiation2(self):
     vtk_handler = fh.FileHandler(vtk_file)
     assert (isinstance(vtk_handler, vh.VtkHandler))
Example #16
0
 def test_vtk_parse_failing_output_name_type(self):
     with self.assertRaises(TypeError):
         output = fh.FileHandler(
             'tests/test_datasets/openfoam_output_test.vtk').get_dataset(5.2)
Example #17
0
 def test_mat_instantiation1(self):
     mat_handler = fh.FileHandler(mat_file)
     assert (isinstance(mat_handler, mh.MatlabHandler))
Example #18
0
 def test_vtk_parse_coords_2(self):
     output = fh.FileHandler('tests/test_datasets/matlab_field_test_bin.vtk'
                             ).get_dataset('Pressure')
     np.testing.assert_almost_equal(output[0], 8.2308226)
Example #19
0
 def test_vtk_parse_check_data_format_2(self):
     output = fh.FileHandler(
         'tests/test_datasets/openfoam_output_test.vtk').get_dataset(
             'p', 'cell')
     assert output.shape == (400, 1)
Example #20
0
 def test_vtk_parse_shape(self):
     output = fh.FileHandler('tests/test_datasets/matlab_field_test_bin.vtk'
                             ).get_dataset('Pressure')
     assert output.shape == (2500, 1)
Example #21
0
 def test_mat_parse_failing_filename_type(self):
     with self.assertRaises(TypeError):
         fh.FileHandler(5.2)
Example #22
0
 def test_stl_get_geometry_wrong_filename(self):
     with self.assertRaises(RuntimeError):
         mesh_points = fh.FileHandler('nonexistent.stl').get_geometry()
Example #23
0
 def test_mat_get_dataset_shape(self):
     output = fh.FileHandler(mat_file).get_dataset('output')
     assert output.shape == (64, 1)
Example #24
0
 def test_stl_instantiation(self):
     stl_handler = fh.FileHandler(stl_file)
     assert (isinstance(stl_handler, sh.StlHandler))
Example #25
0
 def test_mat_get_dataset_coords_2(self):
     output = fh.FileHandler(mat_file).get_dataset('output')
     np.testing.assert_almost_equal(output[0][0], 149.0353302)
Example #26
0
 def test_stl_shape_point(self):
     mesh_points = fh.FileHandler(stl_file).get_geometry()[0]
     assert mesh_points.shape == (197, 3)
Example #27
0
	def test_file_wrong_type_filename(self):
		with self.assertRaises(TypeError):
			handler = fh.FileHandler([3])
Example #28
0
 def test_stl_shape_cell(self):
     cells = fh.FileHandler(stl_file).get_geometry(get_cells=True)[1]
     assert len(cells) == 390
Example #29
0
	def test_file_filename(self):
		handler = fh.FileHandler('inexistent_file.vtk')
		assert (handler._filename == 'inexistent_file.vtk')
Example #30
0
 def test_stl_coords_1(self):
     mesh_points = fh.FileHandler(stl_file).get_geometry()[0]
     np.testing.assert_almost_equal(mesh_points[33, 0], 0.198186)