예제 #1
0
 def test_elmer_write_failing_check_extension(self):
     elmer_handler = elh.ElmerHandler()
     mesh_points = elmer_handler.parse(
         'tests/test_datasets/test_elmer.nodes')
     with self.assertRaises(ValueError):
         elmer_handler.write(mesh_points,
                             'tests/test_datasets/test_square.iges')
예제 #2
0
 def test_elmer_write_outfile(self):
     elmer_handler = elh.ElmerHandler()
     mesh_points = elmer_handler.parse(
         'tests/test_datasets/test_elmer.nodes')
     outfilename = 'tests/test_datasets/test_elmer_out.nodes'
     elmer_handler.write(mesh_points, outfilename)
     self.assertEqual(elmer_handler.outfile, outfilename)
     self.addCleanup(os.remove, outfilename)
예제 #3
0
    def test_elmer_write_comparison(self):
        elmer_handler = elh.ElmerHandler()
        mesh_points = elmer_handler.parse(
            'tests/test_datasets/test_elmer.nodes')
        mesh_points[0] = [0.1, 1.1, 0.1]
        mesh_points[1] = [0.1, 1.2, 0.1]
        mesh_points[2] = [0.1, 1.6, 0.1]
        mesh_points[149] = [11.7910193185, 2.0, 0.1]
        mesh_points[150] = [12.858303628, 0.0, 0.1]
        mesh_points[151] = [12.858303628, 0.125, 0.1]
        mesh_points[-3] = [26.2, 1.6, 0.1]
        mesh_points[-2] = [26.2, 2.01666666667, 0.1]
        mesh_points[-1] = [26.2, 2.1, 0.1]

        outfilename = 'tests/test_datasets/test_elmer_out.nodes'
        outfilename_expected = 'tests/test_datasets/test_elmer_out_true.nodes'

        elmer_handler.write(mesh_points, outfilename)
        self.assertTrue(filecmp.cmp(outfilename, outfilename_expected))
        self.addCleanup(os.remove, outfilename)
예제 #4
0
 def test_elmer_write_failing_infile_instantiation(self):
     elmer_handler = elh.ElmerHandler()
     mesh_points = np.zeros((40, 3))
     with self.assertRaises(RuntimeError):
         elmer_handler.write(mesh_points,
                             'tests/test_datasets/test_elmer_out.nodes')
예제 #5
0
 def test_elmer_instantiation(self):
     elmer_handler = elh.ElmerHandler()
예제 #6
0
 def test_elmer_write_failing_filename_type(self):
     elmer_handler = elh.ElmerHandler()
     mesh_points = elmer_handler.parse(
         'tests/test_datasets/test_elmer.nodes')
     with self.assertRaises(TypeError):
         elmer_handler.write(mesh_points, -1.)
예제 #7
0
 def test_elmer_parse_coords_5(self):
     elmer_handler = elh.ElmerHandler()
     mesh_points = elmer_handler.parse(
         'tests/test_datasets/test_elmer.nodes')
     np.testing.assert_almost_equal(mesh_points[-1][1], 2)
예제 #8
0
 def test_elmer_parse_coords_1(self):
     elmer_handler = elh.ElmerHandler()
     mesh_points = elmer_handler.parse(
         'tests/test_datasets/test_elmer.nodes')
     np.testing.assert_almost_equal(mesh_points[33][0], 2.94650796191)
예제 #9
0
 def test_elmer_parse_shape(self):
     elmer_handler = elh.ElmerHandler()
     mesh_points = elmer_handler.parse(
         'tests/test_datasets/test_elmer.nodes')
     self.assertTupleEqual(mesh_points.shape, (240, 3))
예제 #10
0
 def test_elmer_parse_infile(self):
     elmer_handler = elh.ElmerHandler()
     mesh_points = elmer_handler.parse(
         'tests/test_datasets/test_elmer.nodes')
     self.assertEqual(elmer_handler.infile,
                      'tests/test_datasets/test_elmer.nodes')
예제 #11
0
 def test_elmer_parse_failing_filename_type(self):
     elmer_handler = elh.ElmerHandler()
     with self.assertRaises(TypeError):
         mesh_points = elmer_handler.parse(.2)
예제 #12
0
 def test_elmer_default_extension_member(self):
     elmer_handler = elh.ElmerHandler()
     self.assertListEqual(elmer_handler.extensions, ['.nodes'])
예제 #13
0
 def test_elmer_default_outfile_member(self):
     elmer_handler = elh.ElmerHandler()
     self.assertIsNone(elmer_handler.outfile)