Ejemplo n.º 1
0
        mod.compile(location=test_dir, compiler=self.compiler)
        exec('from ' + mod_name + ' import test')
        b = 1.+1j
        c = test(b)
        assert_(c == 3.+3j)

    @dec.slow
    def test_inline(self):
        a = numpy.complex128(1+1j)
        result = inline_tools.inline("return_val=1.0/a;",['a'])
        assert_(result == .5-.5j)


for _n in dir():
    if _n[-9:] == 'Converter':
        if msvc_exists():
            exec("class Test%sMsvc(%s):\n    compiler = 'msvc'" % (_n,_n))
        else:
            exec("class Test%sUnix(%s):\n    compiler = ''" % (_n,_n))
        if gcc_exists():
            exec("class Test%sGcc(%s):\n    compiler = 'gcc'" % (_n,_n))


def setup_test_location():
    test_dir = tempfile.mkdtemp()
    sys.path.insert(0,test_dir)
    return test_dir


test_dir = setup_test_location()
Ejemplo n.º 2
0
               a=py::dict();
               a["hello"] = 5;
               return_val = a;
               """
        test = ext_tools.ext_function('test', code, ['a'])
        mod.add_function(test)
        mod.compile(location=test_dir, compiler=self.compiler)
        exec('from ' + mod_name + ' import test')
        b = {'z': 2}
        c = test(b)
        assert_(c['hello'] == 5)


for _n in dir():
    if _n[-9:] == 'Converter':
        if msvc_exists():
            exec("class Test%sMsvc(%s):\n    compiler = 'msvc'" % (_n, _n))
        else:
            exec("class Test%sUnix(%s):\n    compiler = ''" % (_n, _n))
        if gcc_exists():
            exec("class Test%sGcc(%s):\n    compiler = 'gcc'" % (_n, _n))


def setup_location():
    test_dir = tempfile.mkdtemp()
    sys.path.insert(0, test_dir)
    return test_dir


test_dir = None
Ejemplo n.º 3
0
        mod.add_function(test)
        mod.compile(location = test_dir, compiler = self.compiler)
        exec 'from ' + mod_name + ' import test'
        b = {'z':2}
        c = test(b)
        assert_( c['hello'] == 5)


# for compiler in compilers:
    # for name,klass in globals().iteritems():
    #     if name[:4]=="Test" and name[-9:] == "Converter":
    #         exec("class %s%s(%s):\n    compiler = '%s'"%(name,compiler,name,compiler))
# for converter in
for _n in dir():
    if _n[-9:]=='Converter':
        if msvc_exists():
            exec "class Test%sMsvc(%s):\n    compiler = 'msvc'"%(_n,_n)
        else:
            exec "class Test%sUnix(%s):\n    compiler = ''"%(_n,_n)
        if gcc_exists():
            exec "class Test%sGcc(%s):\n    compiler = 'gcc'"%(_n,_n)

# class TestMsvcIntConverter(TestIntConverter):
#     compiler = 'msvc'
# class TestUnixIntConverter(TestIntConverter):
#     compiler = ''
# class TestGccIntConverter(TestIntConverter):
#     compiler = 'gcc'
#
# class TestMsvcFloatConverter(TestFloatConverter):
#     compiler = 'msvc'
Ejemplo n.º 4
0
        mod.compile(location=test_dir, compiler=self.compiler)
        exec('from ' + mod_name + ' import test')
        b = 1. + 1j
        c = test(b)
        assert_(c == 3. + 3j)

    @dec.slow
    def test_inline(self):
        a = numpy.complex128(1 + 1j)
        result = inline_tools.inline("return_val=1.0/a;", ['a'])
        assert_(result == .5 - .5j)


for _n in dir():
    if _n[-9:] == 'Converter':
        if msvc_exists():
            exec("class Test%sMsvc(%s):\n    compiler = 'msvc'" % (_n, _n))
        else:
            exec("class Test%sUnix(%s):\n    compiler = ''" % (_n, _n))
        if gcc_exists():
            exec("class Test%sGcc(%s):\n    compiler = 'gcc'" % (_n, _n))


def setup_test_location():
    test_dir = tempfile.mkdtemp()
    sys.path.insert(0, test_dir)
    return test_dir


test_dir = setup_test_location()