ó
\K]c           @   sž   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l m	 Z	 d d l
 m Z m Z d d	 l m Z e d
 „  ƒ Z e d „  ƒ Z d S(   sd   
This file provides internal compiler utilities that support certain special
operations with numpy.
iÿÿÿÿ(   t   types(   t   typing(   t   unpack_tuple(   t	   intrinsic(   t   impl_ret_new_ref(   t   RequireLiteralValuet   TypingErrori   (   t   tuple_setitemc            sb   d d l  m ‰  ‡  f d †  } t | ƒ } t j d | d d d t j ƒ } | | ƒ } | | f S(   s×   A version of numpy.empty whose dtype is inferred by the type system.

    Expects `shape` to be a int-tuple.

    There is special logic in the type-inferencer to handle the "refine"-ing
    of undefined dtype.
    iÿÿÿÿ(   t   _empty_nd_implc            s\   | j  } | j ƒ  s t ‚ t | | d ƒ } ˆ  |  | | | ƒ } t |  | | | j ƒ  ƒ S(   Ni    (   t   return_typet
   is_preciset   AssertionErrorR   R   t	   _getvalue(   t   contextt   buildert	   signaturet   argst   arrtyt   shapest   res(   R   (    s3   lib/python2.7/site-packages/numba/unsafe/ndarray.pyt   codegen   s
    	t   ndimt   layoutt   Ct   dtype(   t   numba.targets.arrayobjR   t   lenR    t   Arrayt	   undefined(   t	   typingctxt   shapeR   t   ndt   array_tyt   sig(    (   R   s3   lib/python2.7/site-packages/numba/unsafe/ndarray.pyt   empty_inferred   s    	
!c            s    t  | t j ƒ s! t d ƒ ‚ n  | j d k rK t d j | j ƒ ƒ ‚ n  t | j ƒ ‰  t j	 d | j
 d ˆ  ƒ ‰ ˆ | | ƒ } ‡  ‡ f d †  } | | f S(   sÑ   Convert *array* into a tuple of *length*

    Returns ``UniTuple(array.dtype, length)``

    ** Warning **
    - No boundchecking.
      If *length* is longer than *array.size*, the behavior is undefined.
    s$   *length* argument must be a constanti   s   Not supported on array.ndim={}R   t   countc            sŠ   d „  } | j  d t j ˆ g } t j ˆ | Œ } |  j t j ƒ } |  j ˆ ƒ } | d | ˆ  ƒ | g }	 |  j | | | |	 ƒ }
 |
 S(   Nc         S   s7   | } x* t  | ƒ D] } t | | |  | ƒ } q W| S(   N(   t   rangeR   (   t   arrayt   lengtht   empty_tuplet   outt   i(    (    s3   lib/python2.7/site-packages/numba/unsafe/ndarray.pyt   impl@   s    i    (   R   R    t   intpR   R   t   get_value_typet   get_constant_undeft   compile_internal(   R   R   R   R   R*   t   inner_argtypest	   inner_sigt   ll_idx_typeR'   t
   inner_argsR   (   t
   tuple_sizet
   tuple_type(    s3   lib/python2.7/site-packages/numba/unsafe/ndarray.pyR   ?   s    	(   t
   isinstanceR    t   IntegerLiteralR   R   R   t   formatt   intt   literal_valuet   UniTupleR   (   R   R%   R&   R!   R   (    (   R3   R4   s3   lib/python2.7/site-packages/numba/unsafe/ndarray.pyt   to_fixed_tuple*   s    
N(   t   __doc__t   numbaR    R   t   numba.cgutilsR   t   numba.extendingR   t   numba.targets.imputilsR   t   numba.errorsR   R   t   tupleR   R"   R;   (    (    (    s3   lib/python2.7/site-packages/numba/unsafe/ndarray.pyt   <module>   s   