Esempio n. 1
0
def test_addressof_error(arg, **kwds):
    """
    >>> test_addressof_error(error_func)
    Traceback (most recent call last):
        ...
    TypeError: Object is not a jit function

    >>> test_addressof_error(func, propagate=False)
    Traceback (most recent call last):
        ...
    ValueError: Writing unraisable exception is not yet supported
    """
    return numba.addressof(arg, **kwds)


def test_address_of_struct_function():
    S1 = before_computed_column.to_ctypes()
    S2 = with_computed_column.to_ctypes()
    ctypes_kernel = numba.addressof(cc_kernel)

    s1 = S1(10, 5)
    s2 = S2(0, 0, 0)
    ctypes_kernel(s2, s1)

    assert s2.x == s1.x
    assert s2.y == s1.y
    assert s2.mean == (s1.x + s1.y) / 2.0


numba.testmod()
Esempio n. 2
0
def class_decorators():
    @decorator
    class foo(object):
        pass
    def decorator(cls):
        return cls

def uninitialized_augmented_assignment():
    """
    >>> func = jitv(uninitialized_augmented_assignment)
    Traceback (most recent call last):
        ...
    NumbaError: 139:4: local variable 'x' referenced before assignment
    """
    x += 1


def uninitialized_augmented_assignment_loop():
    """
    >>> func = jitv(uninitialized_augmented_assignment_loop)
    Warning 148:8: local variable 'x' might be referenced before assignment
    """
    for i in range(10):
        x += 1

    x = 0

if __name__ == "__main__":
    import numba
    numba.testmod()
Esempio n. 3
0
def test(module):
    nb.testmod(module, runit=True)
Esempio n. 4
0
import doctest

import numba

@numba.autojit
def func(value):
    """
    >>> func(10.0)
    10.0
    """
    return value

numba.testmod()

@numba.autojit
def func2(value):
    """
    >>> raise ValueError("I am a message")
    Traceback (most recent call last):
        ...
    ValueError: I am a ...
    """

numba.testmod(verbosity=2, optionflags=doctest.ELLIPSIS)
Esempio n. 5
0
def test(module):
    nb.testmod(module, runit=True)
Esempio n. 6
0
import doctest

import numba


@numba.autojit
def func(value):
    """
    >>> func(10.0)
    10.0
    """
    return value


numba.testmod()


@numba.autojit
def func2(value):
    """
    >>> raise ValueError("I am a message")
    Traceback (most recent call last):
        ...
    ValueError: I am a ...
    """


numba.testmod(verbosity=2, optionflags=doctest.ELLIPSIS)