示例#1
0
    def test_object(self):
        @nd.functional.apply(jit = False)
        def f(x):
            return x

        self.assertEqual(f.type, ndt.callable(ndt.scalar, ndt.scalar))

        @nd.functional.apply(jit = False)
        @annotate(ndt.int32)
        def f(x):
            return x

        self.assertEqual(f.type, ndt.callable(ndt.int32, ndt.scalar))
        self.assertEqual(0, f(0))
        self.assertEqual(1, f(1))
        self.assertEqual(0.0, f(0.0))
        self.assertEqual(1.0, f(1.0))

        @nd.functional.apply(jit = False)
        @annotate(ndt.int32, ndt.int32)
        def f(x):
            return x

        self.assertEqual(f.type, ndt.callable(ndt.int32, ndt.int32))
        self.assertEqual(0, f(0))
        self.assertEqual(1, f(1))
    def test_numba(self):
        try:
            import numba
        except ImportError as error:
            raise unittest.SkipTest(error)

        @nd.functional.apply(jit = True)
        def f(x):
            return x

        self.assertEqual(f.type, ndt.callable(ndt.scalar, ndt.scalar))
        self.assertEqual(0, f(0))

        @nd.functional.apply(jit = True)
        def f(x):
            return x

        self.assertEqual(f.type, ndt.callable(ndt.scalar, ndt.scalar))
        self.assertEqual(0, f(0))
示例#3
0
    def test_numba(self):
        try:
            import numba
        except ImportError as error:
            raise unittest.SkipTest(error)

        @nd.functional.apply(jit=True)
        def f(x):
            return x

        self.assertEqual(f.type, ndt.callable(ndt.scalar, ndt.scalar))
        self.assertEqual(0, f(0))

        @nd.functional.apply(jit=True)
        def f(x):
            return x

        self.assertEqual(f.type, ndt.callable(ndt.scalar, ndt.scalar))
        self.assertEqual(0, f(0))
示例#4
0
 def test_callable_type(self):
     tp = ndt.callable(ndt.int32, ndt.float64)
示例#5
0
 def test_callable(self):
     tp = ndt.callable(ndt.void, ndt.int32, ndt.float64, x = ndt.complex128)
示例#6
0
 def test_callable_type(self):
     tp = ndt.callable(ndt.int32, ndt.float64)
示例#7
0
 def test_callable(self):
     tp = ndt.callable(ndt.void, ndt.int32, ndt.float64, x=ndt.complex128)