コード例 #1
0
ファイル: test_addressof.py プロジェクト: meteogrid/numba
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()
コード例 #2
0
ファイル: test_w_uninitialized.py プロジェクト: dwf/numba
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()
コード例 #3
0
def test(module):
    nb.testmod(module, runit=True)
コード例 #4
0
ファイル: test_user_doctest.py プロジェクト: ASPP/numba
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)
コード例 #5
0
ファイル: test_typed_tuple.py プロジェクト: lizecillie/numba
def test(module):
    nb.testmod(module, runit=True)
コード例 #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)