Пример #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)
Пример #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)
Пример #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)
Пример #5
0
 def test_type_match_complex(self):
     s = c_spec.int_converter()
     assert_(not s.type_match(5.+1j))
Пример #6
0
 def test_type_match_float(self):
     s = c_spec.int_converter()
     assert_(not s.type_match(5.))
Пример #7
0
 def test_type_match_int(self):
     s = c_spec.int_converter()
     assert_(s.type_match(5))
Пример #8
0
 def test_type_match_string(self):
     s = c_spec.int_converter()
     assert_( not s.type_match('string') )
Пример #9
0
 def test_type_match_complex(self):
     s = c_spec.int_converter()
     assert_(not s.type_match(5. + 1j))
Пример #10
0
 def test_type_match_float(self):
     s = c_spec.int_converter()
     assert_(not s.type_match(5.))
Пример #11
0
 def test_type_match_int(self):
     s = c_spec.int_converter()
     assert_(s.type_match(5))
Пример #12
0
 def test_type_match_string(self):
     s = c_spec.int_converter()
     assert_(not s.type_match('string'))