Example #1
0
def test_calling_conventions():
    array = np.array([1.0, 2.5, 4.3])

    # Without decorators
    a = jit(f)  # guess signature from args
    assert not a.compiled
    a(array)
    assert a.compiled
    c = jit(f, signature)  # pass signature
    assert c.compiled
    b = jit(f_hints)  # with type hints
    assert b.compiled
    assert a(array) == b(array) == c(array)  # compare

    # With decorators
    assert not f_dec.compiled  # guess signature from args
    f_dec(array)
    assert f_dec.compiled
    assert f_dec_sig.compiled  # with signature
    assert f_dec_hints.compiled  # with type hints
    assert f_dec(array) == f_dec_sig(array) == f_dec_hints(array)

    assert a(array) == f_dec(array)
Example #2
0
def test_ndim(f, a):
    fc = jit(f)
    assert f(a) == fc(a)
Example #3
0
def test_np_loop(f, a):
    fc = jit(f)
    assert fc(a) == f(a)
Example #4
0
def test_for(f):
    f = jit(f)
    assert f() == f.py_function()
Example #5
0
def test_out(f, a, b):
    fc = jit(f)
    assert f(a, b) == fc(a, b)
Example #6
0
def test_int(f, x):
    fc = jit(f)
    assert f(x) == fc(x)
Example #7
0
def test_return(f):
    fc = jit(f)
    assert fc.py_function is f
    assert f() == fc()
Example #8
0
def test_none(f):
    fc = jit(f)
    assert fc.py_function is f
    assert fc() is None
Example #9
0
def test_inference(f):
    fc = jit(f)
    assert f() == fc()