σ
\K]c           @` sη   d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l m Z m	 Z	 d d l
 m Z m Z d d l m Z d d l m Z d	   Z d
 Z d i  d e d d  Z d   Z d d e d d  Z d   Z i  e d  Z d S(   s%   
Define @jit and related decorators.
i    (   t   print_functiont   divisiont   absolute_importNi   (   t   configt   sigutils(   t   DeprecationErrort   NumbaDeprecationWarning(   t   registry(   t   stencilc          O` s0   d } d | } t  j t |   t |  |   S(   s@   Deprecated.

    Use jit instead.  Calls to jit internally.
    s`   http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-numba-autojitsl   autojit is deprecated, use jit instead, which provides the same functionality. For more information visit %s(   t   warningst   warnR   t   jit(   t   argst   kwst   urlt   msg(    (    s/   lib/python2.7/site-packages/numba/decorators.pyt   autojit   s
    s`   Deprecated keyword argument `{0}`. Signatures should be passed as the first positional argument.t   cpuc   
      K` s  d | k r$ t  t j d    n  d | k rH t  t j d    n  |  d k rc d } d } nK t |  t  r d } |  } n- t j |   r’ d } |  g } n |  } d } i  } | d k	 rΝ | | d <n  t | d | d | d | d | | }	 | d k	 r
|	 |  S|	 Sd S(	   s  
    This decorator is used to compile a Python function into native code.

    Args
    -----
    signature:
        The (optional) signature or list of signatures to be compiled.
        If not passed, required signatures will be compiled when the
        decorated function is called, depending on the argument values.
        As a convenience, you can directly pass the function to be compiled
        instead.

    locals: dict
        Mapping of local variable names to Numba types. Used to override the
        types deduced by Numba's type inference engine.

    target: str
        Specifies the target platform to compile for. Valid targets are cpu,
        gpu, npyufunc, and cuda. Defaults to cpu.

    pipeline_class: type numba.compiler.BasePipeline
            The compiler pipeline type for customizing the compilation stages.

    options:
        For a cpu target, valid options are:
            nopython: bool
                Set to True to disable the use of PyObjects and Python API
                calls. The default behavior is to allow the use of PyObjects
                and Python API. Default value is False.

            forceobj: bool
                Set to True to force the use of PyObjects for every value.
                Default value is False.

            looplift: bool
                Set to True to enable jitting loops in nopython mode while
                leaving surrounding code in object mode. This allows functions
                to allocate NumPy arrays and use Python objects, while the
                tight loops in the function can still be compiled in nopython
                mode. Any arrays that the tight loop uses should be created
                before the loop is entered. Default value is True.

            error_model: str
                The error-model affects divide-by-zero behavior.
                Valid values are 'python' and 'numpy'. The 'python' model
                raises exception.  The 'numpy' model sets the result to
                *+/-inf* or *nan*. Default value is 'python'.

    Returns
    --------
    A callable usable as a compiled function.  Actual compiling will be
    done lazily if no explicit signatures are passed.

    Examples
    --------
    The function can be used in the following ways:

    1) jit(signatures, target='cpu', **targetoptions) -> jit(function)

        Equivalent to:

            d = dispatcher(function, targetoptions)
            for signature in signatures:
                d.compile(signature)

        Create a dispatcher object for a python function.  Then, compile
        the function with the given signature(s).

        Example:

            @jit("int32(int32, int32)")
            def foo(x, y):
                return x + y

            @jit(["int32(int32, int32)", "float32(float32, float32)"])
            def bar(x, y):
                return x + y

    2) jit(function, target='cpu', **targetoptions) -> dispatcher

        Create a dispatcher function object that specializes at call site.

        Examples:

            @jit
            def foo(x, y):
                return x + y

            @jit(target='cpu', nopython=True)
            def bar(x, y):
                return x + y

    t   argtypest   restypet   pipeline_classt   localst   targett   cachet   targetoptionsN(	   R   t   _msg_deprecated_signature_argt   formatt   Nonet
   isinstancet   listR   t   is_signaturet   _jit(
   t   signature_or_functionR   R   R   R   t   optionst   pyfunct   sigst   dispatcher_argst   wrapper(    (    s/   lib/python2.7/site-packages/numba/decorators.pyR   %   s.    _		
c         ` s2   t  j           f d   } | S(   Nc         ` sή   t  j r2  d k r2 d d l m } | j |   St  j rL  d k rL |  S d |  d  d    }   r} | j   n   d  k	 rΪ d d l m } | j	 |  - x  D] } | j
 |  q° W| j   Wd  QXn  | S(	   Nt   cudai   (   R&   t   npyufunct   py_funcR   R   (   t	   typeinfer(   R   t   ENABLE_CUDASIMt    R&   R   t   DISABLE_JITt   enable_cachingR   R)   t   register_dispatchert   compilet   disable_compile(   t   funcR&   t   dispR)   t   sig(   R   t
   dispatcherR$   R   R#   R   R   (    s/   lib/python2.7/site-packages/numba/decorators.pyR%   ©   s"    	(   R   t   dispatcher_registry(   R#   R   R   R   R   R$   R%   (    (   R   R4   R$   R   R#   R   R   s/   lib/python2.7/site-packages/numba/decorators.pyR   ¦   s    !c         K` sm   i  } | d	 k	 r | | d <n  t d d	 d i  d | d | d | d d |  } |  d	 k	 re | |   S| Sd	 S(
   s  
    This decorator allows flexible type-based compilation
    of a jitted function.  It works as `@jit`, except that the decorated
    function is called at compile-time with the *types* of the arguments
    and should return an implementation function for those types.
    R   R#   R   R   R   R   t	   impl_kindt	   generatedN(   R   R   (   t   functionR   R   R   R!   R$   R%   (    (    s/   lib/python2.7/site-packages/numba/decorators.pyt   generated_jitΑ   s    		
c          O` s_   d | k r t  j d t  n  d | k r> t  j d t  n  | j i t d 6 t |  |   S(   sr   
    Equivalent to jit(nopython=True)

    See documentation for jit function/decorator for full description.
    t   nopythons'   nopython is set for njit and is ignoredt   forceobjs'   forceobj is set for njit and is ignored(   R	   R
   t   RuntimeWarningt   updatet   TrueR   (   R   R   (    (    s/   lib/python2.7/site-packages/numba/decorators.pyt   njitΥ   s    c         ` s+   t  j         f d   } | S(   sω   
    This decorator is used to compile a Python function into a C callback
    usable with foreign C libraries.

    Usage::
        @cfunc("float64(float64, float64)", nopython=True, cache=True)
        def add(a, b):
            return a + b

    c         ` sL   d d l  m } | |   d  d  }   r> | j   n  | j   | S(   Ni   (   t   CFuncR   R!   (   t	   ccallbackR@   R-   R/   (   R1   R@   t   res(   R   R   R!   R3   (    s/   lib/python2.7/site-packages/numba/decorators.pyR%   π   s    
(   R   t   normalize_signature(   R3   R   R   R!   R%   (    (   R   R   R!   R3   s/   lib/python2.7/site-packages/numba/decorators.pyt   cfuncγ   s    (   t   __doc__t
   __future__R    R   R   t   sysR	   R+   R   R   t   errorsR   R   t   targetsR   R   R   R   R   t   FalseR   R   R9   R?   RD   (    (    (    s/   lib/python2.7/site-packages/numba/decorators.pyt   <module>   s    				