Exemplo n.º 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)
Exemplo n.º 2
0
def test_ndim(f, a):
    fc = jit(f)
    assert f(a) == fc(a)
Exemplo n.º 3
0
def test_np_loop(f, a):
    fc = jit(f)
    assert fc(a) == f(a)
Exemplo n.º 4
0
def test_for(f):
    f = jit(f)
    assert f() == f.py_function()
Exemplo n.º 5
0
def test_out(f, a, b):
    fc = jit(f)
    assert f(a, b) == fc(a, b)
Exemplo n.º 6
0
def test_int(f, x):
    fc = jit(f)
    assert f(x) == fc(x)
Exemplo n.º 7
0
def test_return(f):
    fc = jit(f)
    assert fc.py_function is f
    assert f() == fc()
Exemplo n.º 8
0
def test_none(f):
    fc = jit(f)
    assert fc.py_function is f
    assert fc() is None
Exemplo n.º 9
0
def test_inference(f):
    fc = jit(f)
    assert f() == fc()