Ejemplo n.º 1
0
    def test_assign_variable_types(self):
        a = arange(10, dtype=float32)
        b = arange(5, dtype=float64)
        c = 5
        arg_list = ['a', 'b', 'c']
        actual = ext_tools.assign_variable_types(arg_list, locals())

        ad = array_converter()
        ad.name, ad.var_type, ad.dims = 'a', float32, 1
        bd = array_converter()
        bd.name, bd.var_type, bd.dims = 'b', float64, 1

        cd = c_spec.int_converter()
        cd.name, cd.var_type = 'c', types.IntType
        desired = [ad, bd, cd]
        assert_equal(actual, desired)
Ejemplo n.º 2
0
    def test_assign_variable_types(self):
        a = arange(10, dtype=float32)
        b = arange(5, dtype=float64)
        c = 5
        arg_list = ["a", "b", "c"]
        actual = ext_tools.assign_variable_types(arg_list, locals())

        ad = array_converter()
        ad.name, ad.var_type, ad.dims = "a", float32, 1
        bd = array_converter()
        bd.name, bd.var_type, bd.dims = "b", float64, 1

        cd = c_spec.int_converter()
        cd.name, cd.var_type = "c", types.IntType
        desired = [ad, bd, cd]
        assert_equal(actual, desired)
    def test_assign_variable_types(self):
        try:
            from numpy.numerix import arange, Float32, Float64
        except:
            # skip this test if numpy.numerix not installed
            return

        import types
        a = arange(10,typecode=Float32)
        b = arange(5,typecode=Float64)
        c = 5
        arg_list = ['a','b','c']
        actual = ext_tools.assign_variable_types(arg_list,locals())
        # desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}

        ad = array_converter()
        ad.name, ad.var_type, ad.dims = 'a', Float32, 1
        bd = array_converter()
        bd.name, bd.var_type, bd.dims = 'b', Float64, 1

        cd = c_spec.int_converter()
        cd.name, cd.var_type = 'c', types.IntType
        desired = [ad,bd,cd]
        assert_equal(actual,desired)
Ejemplo n.º 4
0
    def test_assign_variable_types(self):
        try:
            from numpy.numerix import arange, Float32, Float64
        except:
            # skip this test if numpy.numerix not installed
            return

        import types
        a = arange(10,typecode = Float32)
        b = arange(5,typecode = Float64)
        c = 5
        arg_list = ['a','b','c']
        actual = ext_tools.assign_variable_types(arg_list,locals())
        #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}

        ad = array_converter()
        ad.name, ad.var_type, ad.dims = 'a', Float32, 1
        bd = array_converter()
        bd.name, bd.var_type, bd.dims = 'b', Float64, 1

        cd = c_spec.int_converter()
        cd.name, cd.var_type = 'c', int
        desired = [ad,bd,cd]
        assert_equal(actual,desired)
Ejemplo n.º 5
0
 def test_type_match_complex(self):
     s = c_spec.int_converter()
     assert_(not s.type_match(5.+1j))
Ejemplo n.º 6
0
 def test_type_match_float(self):
     s = c_spec.int_converter()
     assert_(not s.type_match(5.))
Ejemplo n.º 7
0
 def test_type_match_int(self):
     s = c_spec.int_converter()
     assert_(s.type_match(5))
Ejemplo n.º 8
0
 def test_type_match_string(self):
     s = c_spec.int_converter()
     assert_( not s.type_match('string') )
Ejemplo n.º 9
0
 def test_type_match_complex(self):
     s = c_spec.int_converter()
     assert_(not s.type_match(5. + 1j))
Ejemplo n.º 10
0
 def test_type_match_float(self):
     s = c_spec.int_converter()
     assert_(not s.type_match(5.))
Ejemplo n.º 11
0
 def test_type_match_int(self):
     s = c_spec.int_converter()
     assert_(s.type_match(5))
Ejemplo n.º 12
0
 def test_type_match_string(self):
     s = c_spec.int_converter()
     assert_(not s.type_match('string'))