예제 #1
0
    def test_constructor(self):
        """
        Test initialization
        """
        # Initialize empty map
        f = Map()
        self.assertTrue(isinstance(f, Map))
        self.assertIsNone(f.dim())

        #
        # Exceptions
        #

        mesh = Mesh1D()

        # Mesh dimension incompatible with element
        element = QuadFE(2, 'DQ1')
        #self.assertRaises(Exception, Map, **{'mesh':mesh, 'element':element})

        # Dofhandler incompatibility
        element = QuadFE(1, 'Q1')
        dofhandler = DofHandler(mesh, element)
        #self.assertRaises(Exception, Map, **{'dofhandler': dofhandler,
        #                                     'dim':2})

        # function returns the same mesh
        f1 = Map(dofhandler=dofhandler)
        f2 = Map(mesh=mesh)
        self.assertEqual(f1.mesh(), f2.mesh())
예제 #2
0
파일: test.py 프로젝트: 47045039/PYSnippet
 def func(name, x):
     from function import Map
     if Map.has_key(name):
         print Map[name](x)
     else:
         print 'It\'s not a valid function name:', name, ', valid function names:', Map.keys()
         print 'It\'s not a valid function name:' + name + ', valid function names:' + str(Map.keys())
예제 #3
0
파일: test.py 프로젝트: 47045039/PYSnippet
 def func():
     from function import Map
     print Map.keys()        # ['func3', 'func2', 'func1']
     print Map.values()      # [<function <lambda> at 0x21feed8>, <function <lambda> at 0x21fee60>, <function <lambda> at 0x21fede8>]
     print Map.iteritems()   # <dictionary-itemiterator object at 0x226ef18>
     print Map.viewkeys()    # dict_keys(['func3', 'func2', 'func1'])
     print Map.viewvalues()  # dict_values([<function <lambda> at 0x21feed8>, <function <lambda> at 0x21fee60>, <function <lambda> at 0x21fede8>])
     print Map.viewitems()   # dict_items([('func3', <function <lambda> at 0x21feed8>), ('func2', <function <lambda> at 0x21fee60>), ('func1', <function <lambda> at 0x21fede8>)])