
\K]c           @` s=  d  d l  m Z m Z m Z d  d l m Z d  d l m Z m Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l Z d d l m Z d  d l m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z d  d l m  Z  m! Z! d  d	 l" m# Z# d  d
 l$ m% Z% m& Z& m' Z' m( Z( d  d l) m* Z* d  d l+ m, Z, d  d l- m. Z. m/ Z/ d  d l0 m1 Z1 d  d l2 m3 Z3 e j4   Z5 d e j6 f d     YZ7 e7   Z8 e8 j9 d  d d d d d d d d d d d d d d  d! g Z: d" e d# e:  f d$     YZ; e d% d d d& d' g  Z< d(   Z= e> e8 i  d)  Z? d*   Z@ d+ eA f d,     YZB d- eC f d.     YZD d/ eA f d0     YZE d1 eA f d2     YZF d3 eF f d4     YZG d5   ZH e> eG d6  ZI f  e> eJ e> eG d7  ZK d8   ZL d9   ZM d:   ZN d;   ZO i  d<  ZP d=   ZQ d>   ZR d?   ZS d S(@   i    (   t   print_functiont   divisiont   absolute_import(   t   contextmanager(   t
   namedtuplet   defaultdictNi   (   t   event(   t   bytecodet   interpretert   funcdesct   postproct   typingt	   typeinfert   loweringt
   pyloweringt   utilst   configt   errorst   typest   irt   rewritest
   transforms(   t   cput   callconv(   t   type_annotations(   t   PreParforPasst
   ParforPasst   Parfort   ParforDiagnostics(   t   InlineClosureCallPass(   t   CompilerError(   t   raise_on_unsupported_featuret   warn_deprecated(   t   global_compiler_lock(   t   dead_branch_prunet   Flagsc           B` s   e  Z i e d  6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d	 6e j e  d
 6e d 6e d 6d d 6e j e  d 6e d 6Z RS(   t   enable_loopliftt   enable_pyobjectt   enable_pyobject_loopliftt   force_pyobjectt   release_gilt
   no_compilet	   debuginfot
   boundcheckt   forceinlinet   no_cpython_wrappert   auto_parallelt   nrtt   no_rewritest   pythont   error_modelt   fastmatht   noalias(   t   __name__t
   __module__t   FalseR   t   ParallelOptionst   FastMathOptionst   OPTIONS(    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR#      s"   R/   t   typing_contextt   target_contextt   entry_pointt   typing_errort   type_annotationt	   signaturet
   objectmodet   liftedt   fndesct
   interpmodet   libraryt   call_helpert   environmentt   metadatat   reload_initt   CompileResultt   _CompileResultc           B` s&   e  Z d Z d    Z e d    Z RS(   c      	   C` sk   |  j  j   } t |  j  } |  j } d | _ | _ | |  j |  j |  j	 |  j
 |  j |  j | |  j f	 S(   sA   
        Reduce a CompileResult to picklable components.
        N(   RE   t   serialize_using_object_codet   strR?   RC   t   Nonet   typemapt	   calltypesRG   R@   RA   RD   RB   RI   (   t   selft   libdatat   typeannRC   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   _reduceV   s    	c         C` s   |
 r! x |
 D] } |   q Wn  | j    j |  } | j | | |  } |  d | d | j d | d | d | d | d |	 d | d	 | d
 | d | d d  d d  d d  d |
  } | S(   NR<   R;   RE   RG   R=   RC   R?   R@   RA   RD   RB   R>   RF   RH   RI   (   t   codegent   unserialize_libraryt   get_executableR;   RN   (   t   clsR<   RR   RC   t   envR@   RA   RD   RB   RS   RI   t   fnRE   t   cfunct   cr(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   _rebuilde   s*    		(    (   R5   R6   t	   __slots__RT   t   classmethodR]   (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyRJ   S   s   	t   _LowerResultR[   RY   c          K` s   t  |  j    } t  t  } | | } | r= t |    n  | | } x | D] } d  |  | <qN Wt j d k r |  d } | d  k	 r | j d   |  d <q n  t |    S(   Ni   R>   (   i   (	   t   sett   keyst	   CR_FIELDSt	   NameErrorRN   t   syst   version_infot   with_tracebackRJ   (   t   kwsRb   t   fieldsett   badnamest   missingt   kt   err(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   compile_result   s    


c         C` sd   d d l  m } t j   } t j |  } | j | |  ! t | | |  | | | |  SWd QXd S(   sp   
    Compile the function in an isolated environment (typing and target
    context).
    Good for testing.
    i   (   t
   cpu_targetN(   t   targets.registryRo   R   t   ContextR   t
   CPUContextt   nested_contextt   compile_extra(   t   funct   argst   return_typet   flagst   localsRo   t	   typingctxt	   targetctx(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   compile_isolated   s    c         C` s_   t  j j |   } t j |  } t  j d |  } | j |  } t j |  } | j	   | S(   su   
    Run the compiler frontend over the given Python function, and return
    the function's canonical Numba IR.
    t   func_id(
   R   t   FunctionIdentityt   from_functionR   t   Interpretert   ByteCodet	   interpretR
   t   PostProcessort   run(   Ru   R}   t   interpt   bct   func_irt	   post_proc(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   run_frontend   s    
t   _CompileStatusc           B` s/   e  Z d  Z d d d g Z d   Z d   Z RS(   s   
    Used like a C record
    t   fail_reasont   can_fallbackt
   can_giveupc         C` s   d  |  _ | |  _ | |  _ d  S(   N(   RN   R   R   R   (   RQ   R   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   __init__   s    		c      	   C` sO   g  } x9 |  j  D]. } | j d j d | d t |  |    q Wd j |  S(   Ns   {k}={v}Rl   t   vs   , (   R^   t   appendt   formatt   getattrt   join(   RQ   t   valsRl   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   __repr__   s    ,(   R5   R6   t   __doc__R^   R   R   (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR      s   	t   _EarlyPipelineCompletionc           B` s   e  Z d    Z RS(   c         C` s   | |  _  d  S(   N(   t   result(   RQ   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR      s    (   R5   R6   R   (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR      s   t   _PipelineManagerc           B` sD   e  Z d    Z d   Z d   Z d   Z d   Z e d    Z RS(   c         C` s   g  |  _  i  |  _ t |  _ d  S(   N(   t   pipeline_ordert   pipeline_stagesR7   t
   _finalized(   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR      s    		c         C` s@   |  j  s t d   |  j j |  g  |  j | <| |  _ d  S(   Ns    Pipelines can no longer be added(   R   t   AssertionErrorR   R   R   t   current(   RQ   t   pipeline_name(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   create_pipeline   s    c         C` sG   |  j  s t d   |  j d } | | f } |  j | j |  d  S(   Ns   Stages can no longer be added.i(   R   R   R   R   R   (   RQ   t   stage_functiont   stage_descriptiont   current_pipeline_namet   func_desc_tuple(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt	   add_stage   s    c         C` s   t  |  _ d  S(   N(   t   TrueR   (   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   finalize   s    c         C` s~   d j  d | d |  } t j rn t j rn t j | j d  d  } d } | j  d t j	   d |  } n  | f | _
 | S(	   sG   
        Patches the error to show the stage that it arose in.
        s   {desc}
{exc}t   desct   excs   
i   s   Caused By:
{tb}
{newmsg}t   tbt   newmsg(   R   R   t   IS_PY3R   t   FULL_TRACEBACKSt
   _termcolort   errmsgt   splitt	   tracebackt
   format_excRv   (   RQ   R   R   R   t   strippedt   fmt(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   _patch_error   s    !c   	      C` s   |  j  s t d   x |  j D] } t d |  | |  j d k } x |  j | D] \ } } y t d |  |   WqT t k
 r } | j St k
 r } d | | f } |  j | |  } | r |  q | | _	 PqT XqT Wd  Sq Wt d   d  S(   Ns!   PM must be finalized before run()s   Pipeline: %sis   -- %ss%   Failed in %s mode pipeline (step: %s)s   All pipelines have failed(   R   R   R   R   R   R   R   t   BaseExceptionR   R   RN   R   (	   RQ   t   statusR   t   is_final_pipelinet   staget
   stage_namet   et   msgt   patched_exception(    (    s-   lib/python2.7/site-packages/numba/compiler.pyR      s(    			(	   R5   R6   R   R   R   R   R   R!   R   (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR      s   					t   BasePipelinec           B` s  e  Z d  Z d   Z e d    Z e d    Z d   Z d   Z d/ d0 d  Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d    Z$ d!   Z% d"   Z& d#   Z' d$   Z( d%   Z) d& d'  Z* d( d)  Z+ d* d+  Z, d,   Z- d-   Z. d.   Z/ RS(1   s=   
    Stores and manages states for the compiler pipeline
    c         C` s  t  j   | j   | j   | |  _ t | |  |  _ | |  _ | |  _ | |  _ | |  _	 | |  _
 d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ i  |  _ g  |  _ t   |  _ |  j |  j d <t d |  j	 j d t  j  |  _ d  S(   Nt   parfor_diagnosticsR   R   (   R   t   reload_configt   refreshRz   t   _make_subtargetR{   RE   Rv   Rw   Rx   Ry   RN   R   R}   R   RB   t   lifted_fromRO   RP   R?   RH   RI   R   R   R   R%   t   COMPATIBILITY_MODER   (   RQ   Rz   R{   RE   Rv   Rw   Rx   Ry   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     s2    


																c         c` s   y	 d VWn t  k
 r } |  j j s-   q t j d k rN | j d  } n  |  j j r` d n d } d | | f } t	 j
 d | | f t j |  j j |  j j    n Xd S(   sH   
        Wraps code that would signal a fallback to object mode
        Ni   t    t   OUTsQ   
Compilation is falling back to object mode WITH%s looplifting enabled because %ss   %s due to: %s(   i   (   R   R   R   R   t	   PYVERSIONRg   RN   Rx   R$   t   warningst   warn_explicitR   t   NumbaWarningR}   t   filenamet   firstlineno(   RQ   R   R   t	   loop_liftt   msg_rewrite(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   fallback_context>  s    		c         c` s   y	 d VWnx t  k
 r } |  j j s-   q t j d k rN | j d  } n  t j d | | f t	 j
 |  j j |  j j    n Xd S(   sM   
        Wraps code that would signal a fallback to interpreter mode
        Ni   s   %s: %s(   i   (   R   R   R   R   R   Rg   RN   R   R   R   R   R}   R   R   (   RQ   R   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   giveup_contextX  s    		c         C` s/   t  j |  } t j r+ t | j    n  | S(   s0   
        Extract bytecode from function
        (   R   R   R   t   DUMP_BYTECODEt   printt   dump(   RQ   R}   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   extract_bytecodem  s    	c         C` s   t  j j |  |  _ y |  j |  j  } Wn6 t k
 rc } |  j j rZ |  j   |  j	 S|  n X| |  _
 d |  _ d  |  _ |  j   S(   N(    (   R   R~   R   R}   R   R   R   R   t   stage_compile_interp_modeR\   R   RB   RN   R   t   _compile_bytecode(   RQ   Ru   R   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyRt   w  s    

			c         C` s5   | j  |  _  | |  _ | |  _ |  j |  |  j   S(   N(   R}   RB   R   t   _set_and_check_irt   _compile_ir(   RQ   R   RB   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt
   compile_ir  s
    		c         C` s&   t  |  j |  j  } |  j |  d S(   s>   
        Analyze bytecode and translating to Numba IR
        N(   t   translate_stageR}   R   R   (   RQ   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_analyze_bytecode  s    c         C` s   | |  _  |  j  j |  _ |  j rG |  j j rG t j f |  j |  _ n= t |  j  |  j k r t	 d t |  j  |  j f   n  d  S(   NsL   Signature mismatch: %d argument types given, but function takes %d arguments(
   R   t	   arg_countt   nargsRv   Rx   R'   R   t   pyobjectt   lent	   TypeError(   RQ   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     s    	c         C` s   t  |  j  d  S(   N(   t   ir_processing_stageR   (   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_process_ir  s    c         C` s  |  j  j   } |  j  j   } | j d  | j d  |  j  j sT | j d  n  t j |  j d |  j d |  j d |  j	 d | \ } } | rt
 j s t
 j r x$ | D] } t d | j    q Wn  t |  j |  j | |  j |  j | |  j	 d t |  d	 d d
 t } | Sd S(   s:   
        Loop lifting analysis and transformation
        R$   R%   Rz   R{   Ry   Rx   s   Lifting loopRB   R   t   is_lifted_loopN(   Rx   t   copyt   unsetR&   R   t   loop_liftingR   Rz   R{   Ry   R   t   DEBUG_FRONTENDt   DEBUGR   t   get_source_locationR   Rv   Rw   t   tupleRN   R   (   RQ   t
   loop_flagst   outer_flagst   maint   loopst   loopt   cres(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   frontend_looplift  s*    				c         C` s   t  j d |  j d |  j d |  j d |  j d |  j  \ } } | r t |  j |  j | |  j |  j	 |  j |  j d t
 |  d d	 d t |   } t |   n  d	 S(
   s'   
        Extract with-contexts
        R   Rz   R{   Rx   Ry   RB   R   t   pipeline_classN(   R   t   with_liftingR   Rz   R{   Rx   Ry   R   Rv   Rw   R   RN   t   typeR   (   RQ   R   t   withsR   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_frontend_withlift  s    					c         C` sz   |  j  j rF |  j s t  |  j   } | d k	 rF t |   qF n  t d    |  _ t d    |  _	 t
 j |  _ d S(   sM   
        Front-end: Analyze bytecode, generate Numba IR, infer types
        c           S` s   t  j S(   N(   R   R   (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   <lambda>  R   c           S` s   t  j S(   N(   R   R   (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     R   N(   Rx   R$   RB   R   R   RN   R   R   RO   RP   R   R   Rw   (   RQ   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_objectmode_frontend  s    c         C` s   |  j  s t  d |  j j f } |  j |   t |  j  |  j  Wd QXt j s] t j	 r t
 d j d d   t
 |  j  j    t
 d j d d   n  d S(   s   
        This prunes dead branches, a dead branch is one which is derivable as
        not taken at compile time purely based on const/literal evaluation.
        sh   Internal error in pre-inference dead branch pruning pass encountered during compilation of function "%s"Nt   branch_pruned_iriP   t   -s   end branch_pruned_ir(   R   R   R}   t	   func_nameR   R"   Rv   R   R   t   DUMP_IRR   t   centerR   (   RQ   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_dead_branch_prune  s    c      
   C` s   |  j  d |  j j f  P t |  j |  j |  j |  j |  j  \ } } } | |  _	 | |  _ | |  _
 Wd QX|  j  d |  j j f   t |  j |  j |  j  Wd QXd S(   s1   
        Type inference and legalization
        s#   Function "%s" failed type inferenceNs%   Function "%s" has invalid return type(   R   R}   R   t   type_inference_stageRz   R   Rv   Rw   Ry   RO   RP   t   legalize_return_typeR{   (   RQ   RO   Rw   RP   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_nopython_frontend  s    				c         C` sU   |  j  s t  d |  j j f } |  j |   t j j d |  |  j   Wd QXd S(   sa   
        Perform any intermediate representation rewrites before type
        inference.
        s^   Internal error in pre-inference rewriting pass encountered during compilation of function "%s"s   before-inferenceN(   R   R   R}   R   R   R   t   rewrite_registryt   apply(   RQ   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_generic_rewrites  s    c         C` s   |  j  s t  t t |  d d  t  s0 t  t t |  d d  t  sQ t  d |  j j f } |  j |   t	 j
 j d |  |  j   Wd QXd S(   s`   
        Perform any intermediate representation rewrites after type
        inference.
        RO   RP   s_   Internal error in post-inference rewriting pass encountered during compilation of function "%s"s   after-inferenceN(   R   R   t
   isinstanceR   RN   t   dictR}   R   R   R   R  R  (   RQ   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_nopython_rewrites  s    !!c         C` sV   |  j  s t  t |  j  |  j j |  j j |  j |  j j |  j	 j
  } | j   d S(   s?   
        Preprocessing for data-parallel computations.
        N(   R   R   R   R?   RO   RP   Rz   Rx   R.   R   t   replaced_fnsR   (   RQ   t   preparfor_pass(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_pre_parfor_pass*  s    		c      	   C` s  |  j  s t  t |  j  |  j j |  j j |  j |  j |  j j	 |  j |  j
  } | j   t } xK |  j  j j   D]7 } x- | j D] } t | t  r t } Pq q Wqt Pqt W| s |  j  j j d k s d } d | } t j t j | |  j  j   q n  |  j j t  d S(   sF   
        Convert data-parallel computations into Parfor nodes
        s   <string>sG   http://numba.pydata.org/numba-doc/latest/user/parallel.html#diagnosticss   
The keyword argument 'parallel=True' was specified but no transformation for parallel execution was possible.

To find out why, try turning on parallel diagnostics, see %s for help.N(   R   R   R   R?   RO   RP   Rw   Rz   Rx   R.   R   R   R7   t   blockst   valuest   bodyR  R   R   t   locR   R   t   warnR   t   NumbaPerformanceWarningRI   R   t   _reload_parfors(   RQ   t   parfor_passt
   has_parfort   blkt   stmntt   urlR   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_parfor_pass:  s*    
c         C` s   |  j  s t  t |  j t j j  } t |  j  |  j j	 |  j
 j |  } | j   t j |  j   } | j   t j s t j r |  j  j j } t d | j d d   |  j  j   n  d S(   s;   
        Inline calls to locally defined closures.
        s   IR DUMP: %siP   R   N(   R   R   R  Rw   R   t   misct   PyObjectR   Rx   R.   R   R  R   R
   R   R   R   R   R}   t   func_qualnameR   R   R   (   RQ   t
   typed_passt   inline_passR   t   name(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_inline_pass^  s    				

c         C` s   t  j d |  j d |  j d |  j d |  j d |  j d |  j d |  j d t	 j
  |  _ t	 j r t d	 j d
 d   t |  j  t d d
  n  t	 j
 r t t	 j
 d   } |  j j |  Wd QXn  d S(   s=   
        Create type annotation after type inference
        R   RO   RP   RB   R   Rv   Rw   t   html_outputt
   ANNOTATIONiP   R   t   =t   wN(   R   t   TypeAnnotationR   RO   RP   RB   R   Rv   Rw   R   t   HTMLR?   t   ANNOTATER   R   t   opent   html_annotate(   RQ   t   fout(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_annotate_typew  s     										c         C` sS   |  j  j j rO t j rO |  j d  k	 r= |  j j t j  qL t d   qO n  d  S(   Ns   Diagnostics failed.(	   Rx   R.   t   enabledR   t   PARALLEL_DIAGNOSTICSR   RN   R   t   RuntimeError(   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_dump_diagnostics  s
    	c      	   C` s   |  j  d |  j j f  o t |  j  |  j k rh t |  j  t j f |  j t |  j  |  _ n  t	 |  j
 |  j |  j |  j  SWd QXd S(   s)   
        Object mode compilation
        s*   Function %s failed at object mode loweringN(   R   R}   R   R   Rv   R   R   R   R   t   py_lowering_stageR{   RE   R   Rx   (   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   backend_object_mode  s    		c         C` sd   d |  j  j f } |  j |  < t |  j |  j |  j |  j |  j |  j	 |  j
 |  j  SWd QXd S(   s   Native mode compilations,   Function %s failed at nopython mode loweringN(   R}   R   R   t   native_lowering_stageR{   RE   R   RO   Rw   RP   Rx   RH   (   RQ   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   backend_nopython_mode  s    c         C` s   |  j  d k rF |  j j   } | j |  j j  |  _  |  j  j   n  |   } t j	 |  j
 |  j  } t d |  j d |  j d | j d |  j j d |  j d |  j  d | j d | d	 | d
 t d |  j d | j d | j d |  j d |  j  |  _ d S(   sS   
        Back-end: Generate LLVM IR from Numba IR, compile to machine code
        R;   R<   R=   R>   R?   RE   RF   R@   RA   RD   RB   RC   RG   RH   RI   N(   RE   RN   R{   RU   t   create_libraryR}   R  t   enable_object_cachingR   R@   Rw   Rv   Rn   Rz   R[   R   R   R?   RF   R7   RB   RC   RY   RH   RI   R\   (   RQ   t   lowerfnRA   RU   t   loweredR@   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   _backend  s,    											c         C` s   |  j  } |  j | d t |  j j s t |  j  d k rS d |  j j f } n d |  j j f } t	 j
 t j | |  j j   d } d | } t	 j
 t j | |  j j   |  j j r d } t	 j | t j |  j j |  j j  q n  d S(	   s*   
        Lowering for object mode
        RA   i    sV   Function "%s" was compiled in object mode without forceobj=True, but has lifted loops.s@   Function "%s" was compiled in object mode without forceobj=True.s   http://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jits   
Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

For more information visit %ssN   Code running in object mode won't allow parallel execution despite nogil=True.N(   R/  R6  R   Rx   R'   R   RB   R}   R   R   R  R   R   R   R  t   NumbaDeprecationWarningR(   R   R   R   (   RQ   R4  t   warn_msgR  R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_objectmode_backend  s&    		c         C` s    |  j  } |  j | d t d S(   s*   
        Do lowering for nopython
        RA   N(   R1  R6  R7   (   RQ   R4  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_nopython_backend  s    	c         C` s   t  j g t |  j  } t j t  j |  } t d |  j d |  j d |  j	 j
 d |  j j d d d | d t d	 t d
 d d d  
|  _ d S(   sC   
        Just create a compile result for interpreter mode
        R;   R<   R=   R>   R?   s   <Interpreter mode function>R@   RA   RD   RB   RC   N(    (   R   R   R   Rv   R   R@   Rn   Rz   R{   R}   Ru   R   R   R7   R   RN   R\   (   RQ   Rv   R@   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     s    	c         C` s*   t  |  j |  j  t |  j |  j  d  S(   N(   R   R   RO   R    (   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_ir_legalization  s    c         C` s   d S(   sD   
        Cleanup intermediate results to release resources.
        N(    (   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   stage_cleanup  R   c         C` s   t     d S(   s?   Child classes override this to customize the pipeline.
        N(   t   NotImplementedError(   RQ   t   pm(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   define_pipelines  s    c         C` s<   |  j  d k r% | j |  j d  n  | j |  j d  d S(   s`   Add the preprocessing stage that analyzes the bytecode to prepare
        the Numba IR.
        s   analyzing bytecodes   processing IRN(   R   RN   R   R   R   (   RQ   R>  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   add_preprocessing_stage  s    c         C` sL   |  j  j s5 | j |  j d  | j |  j d  n  | j |  j d  d S(   sw   Add any stages that go before type-inference.
        The current stages contain type-agnostic rewrite passes.
        s   nopython rewritess   dead branch prunings(   inline calls to locally defined closuresN(   Rx   R0   R   R  R   R  (   RQ   R>  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   add_pre_typing_stage%  s
    c         C` s*   | j  |  j d  | j  |  j d  d S(   sB   Add the type-inference stage necessary for nopython mode.
        s   nopython frontends   annotate typeN(   R   R  R)  (   RQ   R>  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   add_typing_stage/  s    c         C` sp   |  j  j j r% | j |  j d  n  |  j  j sG | j |  j d  n  |  j  j j rl | j |  j d  n  d S(   s!   Add optimization stages.
        s   Preprocessing for parforss   nopython rewritess   convert to parforsN(   Rx   R.   R*  R   R
  R0   R  R  (   RQ   R>  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   add_optimization_stage5  s    
c         C` s   | j  |  j d  d S(   sC   Add the lowering (code-generation) stage for nopython-mode
        s   nopython mode backendN(   R   R:  (   RQ   R>  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   add_lowering_stage@  s    c         C` s   | j  |  j d  d S(   s?   Add the clean-up stage to remove intermediate results.
        s   cleanup intermediate resultsN(   R   R<  (   RQ   R>  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   add_cleanup_stageE  s    c         C` s   | j  |  j d  d  S(   Ns   Handle with contexts(   R   R   (   RQ   R>  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   add_with_handling_stageJ  s    t   nopythonc         C` s   | j  |  |  j |  |  j |  |  j |  |  j |  |  j |  | j |  j d  |  j |  | j |  j	 d  |  j
 |  d S(   s?   Add the nopython-mode pipeline to the pipeline manager
        s$   ensure IR is legal prior to lowerings   dump diagnosticsN(   R   R@  RF  RA  RB  RC  R   R;  RD  R-  RE  (   RQ   R>  R  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   define_nopython_pipelineM  s    t   objectc         C` s   | j  |  |  j |  | j |  j d  | j |  j d  | j |  j d  | j |  j d  | j |  j d  |  j |  d S(   s=   Add the object-mode pipeline to the pipeline manager
        s   object mode frontends(   inline calls to locally defined closuress   annotate types$   ensure IR is legal prior to lowerings   object mode backendN(	   R   R@  R   R   R  R)  R;  R9  RE  (   RQ   R>  R  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   define_objectmode_pipeline\  s    R   c         C` s1   | j  |  | j |  j d  |  j |  d S(   sM   Add the interpreted-mode (fallback) pipeline to the pipeline manager
        s   compiling with interpreter modeN(   R   R   R   RE  (   RQ   R>  R  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   define_interpreted_pipelinek  s    c         C` sb   t    } |  j |  | j   | j |  j  } | d k	 rB | S|  j d k	 sW t  |  j Sd S(   s4   
        Populate and run compiler pipeline
        N(   R   R?  R   R   R   RN   R\   R   (   RQ   R>  t   res(    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   _compile_cores  s    	
c         C` s   |  j  d k s t  |  j   S(   s>   
        Populate and run pipeline for bytecode input
        N(   R   RN   R   RM  (   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     s    c         C` s   |  j  d k	 s t  |  j   S(   s8   
        Populate and run pipeline for IR input
        N(   R   RN   R   RM  (   RQ   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     s    (    N(0   R5   R6   R   R   R   R   R   R   Rt   RN   R   R   R   R   R   R   R   R   R  R  R  R
  R  R  R)  R-  R/  R1  R6  R9  R:  R   R;  R<  R?  R@  RA  RB  RC  RD  RE  RF  RH  RJ  RK  RM  R   R   (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     sX   	$	
													$							$							
							t   Pipelinec           B` s   e  Z d  Z d   Z RS(   s"   The default compiler pipeline
    c         C` sd   |  j  j s |  j |  n  |  j j s4 |  j  j rD |  j |  n  |  j j r` |  j |  n  d  S(   N(   Rx   R'   RH  R   R   RJ  R   RK  (   RQ   R>  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR?    s    (   R5   R6   R   R?  (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyRN    s   c         C` s   i  } | j  r t | d <n  | j r2 t | d <n  | j rH t | d <n  | j ra | j | d <n  | j rz | j | d <n  t j | j |   } | | d <|  j	 |   S(   sL   
    Make a new target context from the given target context and flags.
    t   enable_debuginfot   enable_boundcheckt
   enable_nrtR.   R3   R2   (
   R*   R   R+   R/   R.   R3   R   t   create_error_modelR2   t	   subtarget(   R{   Rx   t   subtargetoptionsR2   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     s    					
c	   
      C` s+   | |  | | | | | |  }	 |	 j  |  S(   sD  Compiler entry point

    Parameter
    ---------
    typingctx :
        typing context
    targetctx :
        target context
    func : function
        the python function to be compiled
    args : tuple, list
        argument types
    return_type :
        Use ``None`` to indicate void return
    flags : numba.compiler.Flags
        compiler flags
    library : numba.codegen.CodeLibrary
        Used to store the compiled code.
        If it is ``None``, a new CodeLibrary is used.
    pipeline_class : type like numba.compiler.BasePipeline
        compiler pipeline
    (   Rt   (
   Rz   R{   Ru   Rv   Rw   Rx   Ry   RE   R   t   pipeline(    (    s-   lib/python2.7/site-packages/numba/compiler.pyRt     s    c      	   ` s  |	 r t  j |  } t | _           f	 d   } | | j    |  } d } | j s t j   E t j d t j	  y | | j    |  } Wn t
 k
 r n XWd QXn  | d k	 r | } n | } | S       |   } | j d | d  d   Sd S(   sK   
    Compile a function with the given IR.

    For internal use only.
    c         ` s:          |   } | j  d |  d  d   S(   NR   RB   R   (   R   (   t   the_irt	   the_flagsRU  (	   Rv   RE   RB   R   Ry   R   Rw   R{   Rz   (    s-   lib/python2.7/site-packages/numba/compiler.pyt   compile_local  s    t   ignoreNR   RB   R   (   R   t   deepcopyR   R0   RN   R   t   catch_warningst   simplefilterR   R   t	   ExceptionR   (   Rz   R{   R   Rv   Rw   Rx   Ry   RB   R   R   RE   R   t
   norw_flagsRX  t	   norw_crest   rw_cresR   RU  (    (	   Rv   RE   RB   R   Ry   R   Rw   R{   Rz   s-   lib/python2.7/site-packages/numba/compiler.pyR     s*    
	'		c   	      C` s+   t  |  | | | | | |  } | j |  S(   s    
    For internal use only.
    (   RN  Rt   (	   Rz   R{   RE   Ru   Rv   Rw   Rx   Ry   RU  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   compile_internal  s    c         C` s  | j  rlt |  t j  rlg  } i  } t   } x | j j   D] \ } } x | j D] } t | t j	  r | j
 | j j  qW t | t j  rW t | j t j  r | j j d k r | j | | j j <qt | j t j  r| j | j j  qqW qW WqA W| st d   x | D]B }	 | j |	  }
 |
 d k sV|
 j j | k r#t d   q#q#WnB t |  t j  st |  t j  rd } t | j |     n  d S(   s   
    Only accept array return type iff it is passed into the function.
    Reject function object return types if in nopython mode.
    t   casts   No return statements?sC   Only accept returning of array passed into the function as arguments2   Can't return function object ({}) in nopython modeN(   RQ  R  R   t   ArrayRa   R  t   itemsR  R   t   ReturnR   t   valueR  t   Assignt   Exprt   opt   targett   Argt   addR   t   getRN   R   t   Functiont   PhantomR   (   Rw   R   R{   t   retstmtst	   caststmtst   argvarst   bidR  t   instt   varRb  R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR     s.    	!c         C` s   t  j |   } | j |  S(   N(   R   R   R   (   R}   R   R   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR   <  s    c         C` s   t  j |   } | j   t j s+ t j r |  j j } t d | j	 d d   |  j
   |  j r t d | j	 d d   |  j   q n  |  S(   Ns   IR DUMP: %siP   R   s   GENERATOR INFO: %s(   R
   R   R   R   R   R   R}   R  R   R   R   t   is_generatort   dump_generator_info(   R   R   R  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR   A  s    

	c      	   C` s8  t  |  | j k r$ t d   n  t j t j  } t j |  | |  } |  j j	 | | j
 |   x? t t | j |   D]% \ } \ } }	 | j | | |	  q W| d  k	 r | j |  n  x* | j   D] \ }
 } | j |
 |  q W| j   | j   | j   \ } } } Wd  QX| j   | | | f S(   Ns!   Mismatch number of argument types(   R   R   R   R   t   WarningsFixerR   R   t   TypeInferert	   callstackt   registerR}   t	   enumeratet   zipt	   arg_namest   seed_argumentRN   t   seed_returnRd  t	   seed_typet   build_constraintt	   propagatet   unifyt   flush(   Rz   R   Rv   Rw   Ry   R   t   infert   indexR  t   tyRl   R   RO   t   restypeRP   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR   P  s     +


c         C` s  t  j j | | | | d |  j d | j d | j } |  j |  ^ t j |  | | | d | }	 |	 j	   | j
 s |	 j | j  n  |	 j }
 |	 j } ~	 Wd  QX| j r t | | d d  d |
 S|  j | | |
  } |  j | | | g  t | | d | d |
 Sd  S(   Nt   manglert   inlineR4   RH   R[   RY   (   R	   t   PythonFunctionDescriptort   from_specialized_functionR  R,   R4   t   push_code_libraryR   t   Lowert   lowerR-   t   create_cpython_wrapperR(   RY   RF   R)   R`   RN   RW   t   insert_user_function(   R{   RE   R   RO   R  RP   Rx   RH   RC   R  RY   RF   R[   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR0  m  s"    		
					c   	   	   C` s   t  j j |  } |  j |  R t j |  | | |  } | j   | j sZ | j   n  | j	 } | j
 } ~ Wd  QX| j r t | | d d  d | S|  j | | |  } t | | d | d | Sd  S(   NR[   RY   (   R	   R  t   from_object_mode_functionR  R   t   PyLowerR  R-   R  RY   RF   R)   R`   RN   RW   (	   R{   RE   R   Rx   RC   R  RY   RF   R[   (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR.    s    		
					c          C` s   d d l  m }  |    d S(   s    Reloader for cached parfors
    i    (   t   _launch_threadsN(   t   numba.npyufunc.parallelR  (   R  (    (    s-   lib/python2.7/site-packages/numba/compiler.pyR    s    (T   t
   __future__R    R   R   t
   contextlibR   t   collectionsR   R   Re   R   R   R   t   tracingR   t   numbaR   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   t   numba.targetsR   R   t   numba.annotationsR   t   numba.parforR   R   R   R   t   numba.inline_closurecallR   t   numba.errorsR   t   numba.ir_utilsR   R    t   numba.compiler_lockR!   t   numba.analysisR"   t	   termcolorR   t   ConfigOptionsR#   t   DEFAULT_FLAGSRa   Rc   RJ   R`   Rn   RN   R|   R   RI  R   R]  R   R   R   RN  R   Rt   R7   R   Ra  R   R   R   R   R0  R.  R  (    (    (    s-   lib/python2.7/site-packages/numba/compiler.pyt   <module>   s   d" 		0		D  }		>	
	#				