
\K]c           @` s  d  d l  m Z m Z m Z d  d l Z d  d l 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 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 d  d l m Z d  d l m Z d d	 l m Z m Z m Z m  Z  m! 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/ m0 Z0 m1 Z1 m2 Z2 m3 Z3 m4 Z4 m5 Z5 d  d l6 m7 Z7 m8 Z8 m9 Z9 m: Z: m; Z; e j< d f k Z= d d l> m? Z? m@ Z@ y@ d  d lA ZA e eA jB  d k  reC ZD n d  d lE jF jG ZD Wn eH k
 r;eC ZD n Xd eI f d     YZJ d e jK f d     YZL eL d  ZM eJ   ZN e% jO eJ  d    ZP e( eL e jQ  d    ZR d   ZS e- eL  e, jT  e/ eL  d    ZU d eI f d     YZV d e jK f d     YZW eW d  ZX eV   ZY e% jO eV  d    ZP d   ZZ e- eW  e, jT  e/ eW  d     ZU eC d!  Z[ e& e[  d"    Z\ e' e[  e' e[ e j]  d#     Z^ e' e[ e j_  d$    Z` e9 d% e7 f d&     Y Za e' d' eL  d(    Zb d)   Zc d*   Zd d+   Ze e) ec  d,    Zf e) ec  d-    Zg e) eh  d.    Zi e) e jj  d/    Zk e) e jl  d0    Zm e) e jn  d1    Zo e) e jp  d2    Zq d3   Zr d4   Zs e) e jt  d5    Zu d6   Zv d7   Zw d8   Zx d9   Zy d:   Zz e+ eL d;  d<    Z{ d=   Z| d>   Z} d?   Z~ d@   Z dA   Z dB   Z dC   Z dD   Z dE   Z dF   Z dG   Z dH   Z dI   Z e) e  dJ    Z dK   Z dL   Z dM   Z e: e  dN e; f dO     Y Z dP   Z e) e j  dQ    Z dR e f dS     YZ dT e f dU     YZ dV e f dW     YZ dX   Z dY e f dZ     YZ d[   Z d\ e f d]     YZ d^ e j f d_     YZ d` e j f da     YZ e db k re j   n  d S(c   i    (   t   print_functiont   divisiont   absolute_importN(   t   LooseVersion(   t   unittest_support(   t   njitt   jitt   typest   errorst   typingt   compiler(   t
   cpu_target(   t   compile_isolatedi   (   t   TestCaset   captured_stdoutt   tagt   temp_directoryt   override_config(   t   LoweringError(   t   typeof_implt   type_callablet   lower_builtint
   lower_castt   overloadt   overload_attributet   overload_methodt   modelst   register_modelt   boxt   unboxt   NativeValuet   make_attribute_wrappert	   intrinsict
   _Intrinsict   register_jitablet   get_cython_function_address(   t   ConcreteTemplatet	   signaturet   infert   infer_globalt   AbstractTemplatei   (   t   Indext   Seriess   0.19t   MyDummyc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR+   6   s   t   MyDummyTypec           B` s   e  Z d    Z RS(   c         C` s-   t  | t j  r) d d l m } | j Sd  S(   Ni    (   t
   Conversion(   t
   isinstanceR   t   Numbert   numba.typeconvR/   t   safe(   t   selft   contextt   totyR/   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   can_convert_to:   s    (   R,   R-   R7   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR.   9   s   t   mydummyc         C` s   t  S(   N(   t   mydummy_type(   t   valt   c(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   typeof_mydummyB   s    c         C` s   |  j  | d  S(   s2   
    Implicit conversion from MyDummy to int.
    i*   (   t   get_constant(   R5   t   buildert   fromtyR6   R:   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   mydummy_to_numberF   s    c           C` s   t  S(   N(   R8   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt	   get_dummyM   s    c         C` s   t  | j j    S(   N(   R   R5   t   get_dummy_value(   t   typt   objR;   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   unbox_indexR   s    t   MyDummy2c           B` s   e  Z RS(    (   R,   R-   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRF   Z   s   t   MyDummyType2c           B` s   e  Z RS(    (   R,   R-   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRG   ]   s   t	   mydummy_2c         C` s   t  S(   N(   t   mydummy_type_2(   R:   R;   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR<   c   s    c           C` s   t  S(   N(   RH   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   get_dummy_2h   s    c         C` s   t  | j j    S(   N(   R   R5   RB   (   RC   RD   R;   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRE   m   s    c         C` s
   t   d  S(   N(   t   NotImplementedError(   t   x(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   func1v   s    c         C` s   d  d  } | S(   Nc         S` s6   |  d  t j f k r t j St |  t j  r2 |  Sd  S(   N(   t   NoneR   t   nonet   int32R0   t   Float(   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   typer{   s    (   RN   (   R5   RR   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   type_func1y   s    c         C` s   |  j  | j d  S(   Ni*   (   R=   t   return_type(   R5   R>   t   sigt   args(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   func1_nullary   s    c         C` s   d   } |  j  | | | |  S(   Nc         S` s   t  j d |   S(   Ni   (   t   matht   sqrt(   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   func1_impl   s    (   t   compile_internal(   R5   R>   RU   RV   RZ   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   func1_unary   s    	t
   PrintDummyc           B` s#   e  Z d  Z e e j e  g Z RS(   t
   print_item(   R,   R-   t   keyR%   R   RO   R9   t   cases(    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR]      s   R^   c         C` sT   | \ } |  j  |  } | j | j d   } | j |  | j |  |  j   S(   Ns   hello!(   t   get_python_apit   unserializet   serialize_objectt   print_objectt   decrefRB   (   R5   R>   RU   RV   RL   t   pyapit   strobj(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   print_dummy   s    	c         C` s
   t   d  S(   N(   RK   (   t   condRL   t   y(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   where   s    c         C` s   t  j |  | |  S(   s8   
    Wrap np.where() to allow for keyword arguments
    (   t   npRk   (   Ri   RL   Rj   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   np_where   s    c         C` s   t  |  d | d | S(   NRj   RL   (   Rk   (   Ri   RL   Rj   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   call_where   s    c         C` sr   t  |  t j  rn | j | j k r6 t j d   n  t d   |  | | f D  ra d   } n	 d   } | Sd S(   s'   
    Implement where() for arrays.
    s"   x and y should have the same dtypec         s` s   |  ] } | j  d  k Vq d S(   t   CN(   t   layout(   t   .0t   ty(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pys	   <genexpr>   s    c   
      S` s   |  j  } | j  | k s' | j  | k r6 t d   n  t j |  } |  j } | j } | j } | j } x9 t |  j  D]( }	 | |	 r | |	 n | |	 | |	 <qy W| S(   sM   
                Fast implementation for C-contiguous arrays
                s%   all inputs should have the same shape(   t   shapet
   ValueErrorRl   t
   empty_liket   flatt   ranget   size(
   Ri   RL   Rj   Rs   t   rest   cft   xft   yft   rft   i(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   where_impl   s    					&c         S` s   |  j  } | j  | k s' | j  | k r6 t d   n  t j |  } x; t j |   D]* \ } } | rq | | n | | | | <qU W| S(   sI   
                Generic implementation for other arrays
                s%   all inputs should have the same shape(   Rs   Rt   Rl   Ru   t   ndenumerate(   Ri   RL   Rj   Rs   Ry   t   idxR;   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR      s    	"N(   R0   R   t   Arrayt   dtypeR   t   TypingErrort   all(   Ri   RL   Rj   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_where_arrays   s    	c         C` sA   t  |  t j  s= | | k r0 t j d   n  d   } | Sd S(   s(   
    Implement where() for scalars.
    s!   x and y should have the same typec         S` s/   |  r | n | } t  j |  } | | d <| S(   s@   
            Scalar where() => return a 0-dim array
            (    (   Rl   Ru   (   Ri   RL   Rj   t   scalt   arr(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR      s    
N(   R0   R   R   R   R   (   Ri   RL   Rj   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_where_scalars   s
    	
c         C` s    t  |  t  r d   } | Sd  S(   Nc         S` s   d S(   Ni   (    (   t   arg(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   len_impl   s    (   R0   R.   (   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_len_dummy   s    	c         C` s;   t  |  t t f  r7 t  | t t f  r7 d   } | Sd  S(   Nc         S` s   d S(   Ni*   (    (   t   arg1t   arg2(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   dummy_add_impl  s    (   R0   R.   RG   (   R   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_add_dummy   s    *	c         C` s2   t  |  t  r. t  | t j  r. d   } | Sd  S(   Nc         S` s   t  d |  |  d  S(   Nt   del(   t   print(   RD   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   dummy_delitem_impl  s    (   R0   R.   R   t   Integer(   RD   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_dummy_delitem	  s    !	c         C` s2   t  |  t  r. t  | t j  r. d   } | Sd  S(   Nc         S` s   | d S(   Ni{   (    (   RD   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   dummy_getitem_impl  s    (   R0   R.   R   R   (   RD   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_dummy_getitem  s    !	c         C` sG   t  t |  t  t | t j  t | t j  g  rC d   } | Sd  S(   Nc         S` s   t  | |  d  S(   N(   R   (   RD   R   R:   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   dummy_setitem_impl   s    (   R   R0   R.   R   R   (   RD   R   R:   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_dummy_setitem  s    	c         C` s   t  j |  |  S(   N(   t   operatort   add(   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_add_operator%  s    c         C` s   |  | S(   N(    (   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_add_binop)  s    c         C` s;   t  |  t t f  r7 t  | t t f  r7 d   } | Sd  S(   Nc         S` s   d S(   Ni*   (    (   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   dummy_iadd_impl0  s    (   R0   R.   RG   (   R   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_iadd_dummy-  s    *	c         C` s   t  j |  |  S(   N(   R   R   (   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_iadd_operator6  s    c         C` s   |  | 7}  |  S(   N(    (   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_iadd_binop:  s    
c         C` s   |  | =d  S(   N(    (   RD   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_delitem@  s    c         C` s   |  | S(   N(    (   RD   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_getitemD  s    c         C` s   | |  | <d  S(   N(    (   RD   R   R:   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_setitemH  s    t   lengthc         C` s   d   } | S(   Nc         S` s
   t  |   S(   N(   t   len(   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   impN  s    (    (   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_method_lengthL  s    	c         C` s
   |  j    S(   N(   R   (   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   cache_overload_method_usecaseS  s    c           C` s   t    S(   N(   RM   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_func1_nullaryW  s    c         C` s
   t  |   S(   N(   RM   (   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_func1_unaryZ  s    c         C` s
   t  |   S(   N(   R   (   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   len_usecase]  s    c         C` s   t  |   d  S(   N(   R   (   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   print_usecase`  s    c         C` s   |  | S(   N(    (   RL   R_   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   getitem_usecasec  s    c         C` s   t  j t  j |    S(   N(   Rl   t   cost   sin(   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   npyufunc_usecasef  s    c         C` s   |  j  S(   N(   t   _data(   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   get_data_usecasei  s    c         C` s   |  j  S(   N(   t   _index(   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   get_index_usecasel  s    c         C` s   |  j  S(   N(   t   is_monotonic_increasing(   RL   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   is_monotonic_usecaseo  s    c         C` s   t  |  |  S(   N(   R*   (   t   datat   index(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   make_series_usecaser  s    c         C` s   |  j  | |  S(   N(   t   clip(   RL   t   lot   hi(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   clip_usecaseu  s    c           C` s   t  S(   N(   Rl   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   return_non_boxable{  s    c          C` s   d   }  |  S(   Nc           S` s   t  S(   N(   Rl   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR     s    (    (   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_return_non_boxable  s    	c         C` s   t    } | j |   S(   N(   R   t   arange(   t   szt   mod(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   non_boxable_ok_usecase  s    	c           C` s   t    S(   N(   R   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   non_boxable_bad_usecase  s    c         C` s   d  S(   N(    (   t   f(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   mk_func_input  s    t   MkFuncTypingc           B` s   e  Z d    Z RS(   c         C` s,   t  | d t j  s t  t t j |  S(   Ni    (   R0   R   t   MakeFunctionLiteralt   AssertionErrorR%   RO   (   R4   RV   t   kws(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   generic  s    (   R,   R-   R   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR     s   c           C` s   t  d    d  S(   Nc         S` s   |  S(   N(    (   t   a(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   <lambda>  t    (   R   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   mk_func_test_impl  s    c         C` s    t  |  t  r d   } | Sd  S(   Nc         S` s   d S(   NIﾭ    (    (   RD   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR     s    (   R0   R.   (   RD   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   overload_np_exp  s    	t   TestLowLevelExtendingc           B` s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s4   
    Test the low-level two-tier extension API.
    c         C` sy   t  } t d t  |  } |  j |   d  t } t d t  |  } |  j | d   d  |  j | d  d  d  S(   Nt   nopythoni*   g      2@g      @(   R   R   t   Truet   assertPreciseEqualR   RN   (   R4   t   pyfunct   cfunc(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   test_func1  s    c         C` sc   t  } t | d  } |  j | j   d  t } t | t j f  } |  j | j d  d  d  S(   Ni*   g      2@g      @(    (   R   R   R   t   entry_pointR   R   t   float64(   R4   R   t   cr(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_func1_isolated  s    c         C` s5   t  } t | d t j  } |  j | j   d  d  S(   Ng      E@(    (   RA   R   R   R   R   R   (   R4   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_cast_mydummy  s    c         C` sj   t  j t  } t j } | j   t  j | | d d  \ } } } |  j t	 d   | j
   D   d S(   sF   make sure make_function is passed to typer class as a literal
        c         s` s!   |  ] } t  | t j  Vq d  S(   N(   R0   R   R   (   Rq   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pys	   <genexpr>  s   N(    (   R
   t   run_frontendR   R   t   typing_contextt   refresht   type_inference_stageRN   t
   assertTruet   anyt   values(   R4   t   test_irt	   typingctxt   typemapt   _(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_mk_func_literal  s    	
(   R,   R-   t   __doc__R   R   R   R   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR     s
   				t   TestPandasLikec           B` s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z e d  d    Z	 e d  d    Z
 d	   Z e d  d
    Z e d  d    Z RS(   se   
    Test implementing a pandas-like Index object.
    Also stresses most of the high-level API.
    c         C` sD   t  t j d   } t d t  t  } |  j | |  d  d  S(   Ni   R   (   R)   Rl   R   R   R   R   R   (   R4   R~   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_index_len  s    c         C` s   t  t j d d d g   } t d t  t  } |  j | | d  d  | | t d d    } |  j	 | t   |  j
 t |  d d g  d  S(   Ni*   i   iR   i   (   R)   Rl   RP   R   R   R   R   t   sliceRN   t   assertIsInstancet   assertEqualt   list(   R4   R~   R   t   ii(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_index_getitem  s    c         C` s{   t  t j d d d g   } t d t  t  } | |  } |  j | t   |  j | j t j	 t j
 | j    d S(   s7   
        Check Numpy ufunc on an Index object.
        i*   i   iR   N(   R)   Rl   RP   R   R   R   R   R   R   R   R   (   R4   R~   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_index_ufunc  s
    c         C` sV   t  t j d d d g   } t d t  t  } | |  } |  j | | j  d  S(   Ni*   i   iR   (   R)   Rl   RP   R   R   R   t   assertIsR   (   R4   R~   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_index_get_data  s    c         C` s   t  d t  t  } xr d d d g t f d d d g t f g  t f g D]= \ } } t t j |   } | |  } |  j | |  qI Wd  S(   NR   i   i*   i   (   R   R   R   t   FalseR)   Rl   RP   R   (   R4   R   R   t   expectedR~   t   got(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_index_is_monotonic  s    t	   importantc         C` sn   t  t j d d d g   } t t j d d d g  |  } t d t  t  } |  j | |  d  d  S(   Ni   i   i   g      ?g      @g      @R   (	   R)   Rl   RP   R*   R   R   R   R   R   (   R4   R~   t   sR   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_series_len  s    !c         C` s   t  t j d d d g   } t t j d d d g  |  } t d t  t  } | |  } |  j | t   |  j	 | j
 | j
  d  S(   Ni   i   i   g      ?g      @g      @R   (   R)   Rl   RP   R*   R   R   R   R   R   R   R   (   R4   R~   R   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_series_get_index
  s    !c         C` s   t  t j d d d g   } t t j d d d g  |  } t d t  t  } | |  } |  j | t  |  j | j	 t   |  j
 | j	 j | j  |  j | j t j t j | j    d S(	   s8   
        Check Numpy ufunc on an Series object.
        i*   i   ii   i   i   R   N(   R)   Rl   RP   R*   t   int64R   R   R   R   R   R   R   R   t   _valuesR   R   (   R4   R~   R   R   t   ss(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_series_ufunc  s    !c         C` s   t  t j d d d g   } t j d d d g  } t d t  t  } | | |  } |  j | t  |  j | j	 t   |  j
 | j	 j | j  |  j
 | j |  d  S(   Ni*   i   ig      ?g      @g      @R   (   R)   Rl   RP   R   R   R   R   R   R*   R   R   R   R   (   R4   R~   t   dR   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_series_constructor   s    c         C` s   t  t j d d d g   } t t j d d d g  |  } t d t  t  } | | d d	  } |  j | t  |  j | j	 t   |  j
 | j	 j | j  |  j | j t j d d	 d g   d  S(
   Ni*   i   ig      ?g      @g      @R   g?g      @(   R)   Rl   RP   R*   R   R   R   R   R   R   R   R   R   R   (   R4   R~   R   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_series_clip+  s    !(   R,   R-   R   R   R   R   R   R   R   R   R   R  R  R  (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR     s   			
				t   TestHighLevelExtendingc           B` s   e  Z d  Z e d  d    Z e d  d    Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z e j e d  d    Z d   Z d   Z d   Z d   Z RS(   s+   
    Test the high-level combined API.
    R   c      	   ` s   t  } t d t  |       f d   } | d d d t d d  | t d d  | t j t t t g  t j d d	 d g  t j d
 d d g    j t j	  2 }   t j g   t j g   t j
 g    Wd QX j d t | j   d S(   s>   
        Test implementing a function with @overload.
        R   c          ` s)   t  |  |   }   |  |   }  j d  S(   N(   Rm   R   (   RV   t   kwargsR   R   (   R   R4   (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   checkD  s    RL   i   Ri   Rj   i   i   i   i   i   Ns"   x and y should have the same dtype(   Rn   R   R   Rl   t   bool_R   RP   t   assertRaisesR   R   R   t   assertInt   strt	   exception(   R4   R   R  t   raises(    (   R   R4   s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   test_where<  s    -1	c         C` sN   t  d t  t  } |  j | t    d  |  j | d d g  d  d S(   sN   
        Test re-implementing len() for a custom type with @overload.
        R   i   i   i   i   N(   R   R   R   R   R+   (   R4   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_lenT  s    c         C` sO   t  d t  t  } t   + | t    |  j t j j   d  Wd QXd S(   sP   
        Test re-implementing print() for a custom type with @overload.
        R   s   hello!
N(	   R   R   R   R   R+   R   t   syst   stdoutt   getvalue(   R4   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   test_print]  s    
c         C` sv   t  } t d t  |  } |  j | d d  d  |  j | t   t    d  |  j | t   t    d  d S(   sW   
        Test re-implementing operator.add() for a custom type with @overload.
        R   i   i   i   i*   iT   N(   R   R   R   R   RF   R+   (   R4   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_add_operatorf  s
    c         C` sv   t  } t d t  |  } |  j | d d  d  |  j | t   t    d  |  j | t   t    d  d S(   sY   
        Test re-implementing '+' for a custom type via @overload(operator.add).
        R   i   i   i   i*   iT   N(   R   R   R   R   RF   R+   (   R4   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_add_binops  s
    c         C` sv   t  } t d t  |  } |  j | d d  d  |  j | t   t    d  |  j | t   t    d  d S(   sW   
        Test re-implementing operator.add() for a custom type with @overload.
        R   i   i   i   i*   iT   N(   R   R   R   R   RF   R+   (   R4   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_iadd_operator  s
    c         C` sv   t  } t d t  |  } |  j | d d  d  |  j | t   t    d  |  j | t   t    d  d S(   sY   
        Test re-implementing '+' for a custom type via @overload(operator.add).
        R   i   i   i   i*   iT   N(   R   R   R   R   RF   R+   (   R4   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_iadd_binop  s
    c      	   C` s   t  } t d t  |  } t   } d  } t   4 } y | | d  Wn t k
 rb } | } n XWd  QX| d  k	 r~ |  n  |  j | j   d  d  S(   NR   iA  s   del hello! 321
(	   R   R   R   R+   RN   R   t	   ExceptionR   R  (   R4   R   R   RD   t   et   outt   exc(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_delitem  s    		c         C` s;   t  } t d t  |  } |  j | t   d  d  d  S(   NR   iA  i{   i  (   R   R   R   R   R+   (   R4   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_getitem  s    c      	   C` s   t  } t d t  |  } t   } d  } t   7 } y | | d d  Wn t k
 re } | } n XWd  QX| d  k	 r |  n  |  j | j   d  d  S(   NR   iA  i{   s   321 123
(	   R   R   R   R+   RN   R   R  R   R  (   R4   R   R   RD   R  R  R  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_setitem  s    		c   	      C` s   t  d t  t  } d } | |  } t |  } t j j | |  t  d t  t  } |  j t   } |   Wd QXt	 | j
  } d } |  j | |  d S(   sW   
        Test overloading whose return value cannot be represented in CPython.
        R   i
   Ns   cannot convert native Module(   R   R   R   Rl   t   testingt   assert_equalR   R	  t	   TypeErrorR  R  R
  (	   R4   t   ok_cfunct   nR   t   expectt	   bad_cfuncR  t   errmsgt	   expectmsg(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_no_cpython_wrapper  s    c         C` s  d	 d  } d } d d  } |  j t j    } | |  d d d d  Wd	 QXt | j  } |  j | |  |  j d
 |  t r |  j d |  |  j d |  n  d	 d  } |  j t j    } | |  d d d d  Wd	 QXt | j  } |  j | |  |  j d |  t rB|  j d |  |  j d |  n  d	 d  } |  j t j    } | |  d d d d  Wd	 QXt | j  } |  j | |  |  j d |  |  j d | k  t r|  j d |  |  j d |  n  t r(d d l	 m
 } m }	 |  j t j    } | |  d d d d  Wd	 QXt | j  } |  j | |  |  j d |  |  j d | k  |  j d |  |  j t j    } | |	  d d d d  Wd	 QXt | j  } |  j | |  |  j d |  |  j d | k  |  j d |  |  j d |  n  d	 d  }
 |  j t j    } | |
  d d d d  Wd	 QXt | j  } |  j | |  |  j d |  |  j d | k  t r|  j d |  |  j d |  n  d	 d  } |  j t j    } | |  d d d d  Wd	 QXt | j  } |  j | |  |  j d |  |  j d | k  t rn|  j d |  n  d	 d	 d  } |  j t j    } | |  d d d d  Wd	 QXt | j  } |  j | |  |  j d |  t r|  j d |  n  d   } |  j t j    } | |  d d d d  Wd	 QXt | j  } |  j | |  |  j d |  t r~|  j d |  n  d	 S(   s}   
        Tests that an overload which has a differing typing and implementing
        signature raises an exception.
        c         ` sL   d  d   t   d    f d   } t d t   f d    } | S(   Nc         S` s   d  S(   N(    (   R   t   bR;   t   kw(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   myoverload  s    c         ` s     S(   N(    (   R   R)  R;   R*  (   t   impl(    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   _myoverload_impl  s    R   c         ` s     |  | | d | d  S(   NR*  (    (   R   R)  R;   R  (   R+  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   foo  s    (   RN   R   R   R   (   R,  R-  R.  (    (   R,  R+  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   gen_ol  s
    	s-   Typing and implementation arguments differ ini   c         S` s   |  d k r d Sd Sd  S(   Ni
   i   i(    (   R   R)  R;   R*  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   impl1  s    i   i   i   i   Ns   keyword argument default valuess   <Parameter "kw=12">s   <Parameter "kw=None">c         S` s   |  d k r d Sd Sd  S(   Ni
   i   i(    (   R   R)  R;   t   kwarg(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   impl2  s    s   keyword argument namess   <Parameter "kwarg=None">c         S` s   t  d k r d Sd Sd  S(   Ni
   i   i(   R   (   t   zR)  R;   R*  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   impl3	  s    s   argument namest   keywords   <Parameter "a">s   <Parameter "z">(   t   impl4t   impl5s   First difference: 'z'c         S` s   |  d k r d Sd Sd  S(   Ni
   i   i(    (   R   R)  R;   R  R  R*  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   impl6.  s    s   <Parameter "d">s   <Parameter "e">c         S` s   |  d k r d Sd Sd  S(   Ni
   i   i(    (   R   R)  R*  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   impl7?  s    s   <Parameter "c">c         S` s   |  d k r d Sd Sd  S(   Ni
   i   i(    (   R   R)  R;   R*  t   extra_kwarg(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   impl8O  s    s   <Parameter "extra_kwarg=None">c         S` s   |  d k r d Sd Sd  S(   Ni
   i   i(    (   R   R)  R;   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   impl9^  s    (   RN   R	  R   R   R  R  R
  t   _IS_PY3t   assertFalset   overload_usecasesR6  R7  (   R4   R/  t   sentinelR0  R  t   msgR2  R4  R6  R7  R8  R9  R;  R<  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt/   test_typing_vs_impl_signature_mismatch_handling  s    	s   Python 3+ only syntaxc         ` s   d d    d d l m } t    |  t d t    f d    } |  j t j   } | d d  Wd QXt	 | j
  } |  j d |  |  j d	 |  d S(
   s   
        Tests that an overload which has a differing typing and implementing
        signature raises an exception and uses VAR_POSITIONAL (*args) in typing
        c         S` s   d  S(   N(    (   R   R*  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR+  r  s    i   (   t   var_positional_implR   c         ` s     |  | d d d S(   Ni	   R*  i   (    (   R   R)  (   R+  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR.  y  s    i   Ns)   VAR_POSITIONAL (e.g. *args) argument kinds-   offending argument name is '*star_args_token'(   RN   R?  RC  R   R   R   R	  R   R   R  R  R
  (   R4   RC  R.  R  RA  (    (   R+  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt>   test_typing_vs_impl_signature_mismatch_handling_var_positionall  s    c         C` s   t  d  } d   } | | t  d d  |  j t j   } | |  d d  Wd QXt | j  } |  j d |  |  j d |  d d	  } |  j t j   } | |  d d  Wd QXt | j  } |  j d |  |  j d |  d S(
   sJ   
        Tests that an overload which uses **kwargs (VAR_KEYWORD)
        c         ` sD   d  d    t   d | |   t d t    f d    } | S(   Nc         S` s   d  S(   N(    (   R   R*  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR+    s    t   strictR   c         ` s     |  d d S(   NR*  i   (    (   R   R)  (   R+  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR.    s    (   RN   R   R   R   (   R,  RE  R.  (    (   R+  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR/    s    c         [` s   d d  } | S(   Ni
   c         S` s   |  S(   N(    (   R   R*  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR,    s    (    (   R   R   R,  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   ol1  s    i   i   Ns1   use of VAR_KEYWORD (e.g. **kwargs) is unsupporteds"   offending argument name is '**kws'i    c         S` s   d   } | S(   Nc         [` s   |  S(   N(    (   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR,    s    (    (   R   R*  R,  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   ol2  s    	(   R   R   R	  R   R   R  R  R
  (   R4   R/  RF  R  RA  RG  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt;   test_typing_vs_impl_signature_mismatch_handling_var_keyword  s    	c         C` sV   t  t j d  d d   } t d    } t j d  } |  j | |  d  d  S(	   NR.  i
   c         S` s   d d  } | S(   Ni
   c         S` s   | S(   N(    (   R   t   a_kwarg(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR,    s    (    (   R   RI  R,  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   fooimpl  s    c         S` s(   |  j    |  j  d  |  j  d d  f S(   Ni   RI  i   (   R.  (   t   A(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   bar  s    i   i   i   (   i
   i   i   (   R   R   R   R   Rl   R   R   (   R4   RJ  RL  t   Z(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_overload_method_kwargs  s
    c         C` s]   t  t j d  d    } t d    } t j d  } | |  |  j | |  d  d  S(   Nt   litfooc         S` s8   t  | t j  r4 t  | t j  s4 d   } | Sn  d  S(   Nc         S` s   | S(   N(    (   R   R:   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR,    s    (   R0   R   R   t   Literal(   R   R:   R,  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRO    s    	c         S` s   |  j  d  S(   Ni  (   RO  (   RK  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRL    s    i   i  (   R   R   R   R   Rl   t   zerosR   (   R4   RO  RL  RK  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt#   test_overload_method_literal_unpack  s
    

c         C` s&   t  d    } |  j |   d  d  S(   Nc           S` s   t  j t  S(   N(   Rl   t   expR8   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test  s    Iﾭ    (   R   R   (   R4   RT  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_overload_ufunc  s    (   R,   R-   R   R   R  R  R  R  R  R  R  R  R  R  R(  RB  t   unittestt
   skipUnlessR=  RD  RH  RN  RR  RU  (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR  7  s$   													+		c         C` sb   |  j  |  j d } | | k r/ t d   n  |  j |  j d } | | k r^ t d   n  d  S(   Ni    s   cache not used(   t   _cache_hitst
   signaturesR   t   _cache_misses(   R   t
   expect_hitt   expect_missest   hitt   miss(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   _assert_cache_stats  s    t   TestOverloadMethodCachingc           B` s    e  Z e Z d    Z d   Z RS(   c         C` s<   t  |  j j  |  _ t d |  j   |  j   Wd  QXd  S(   Nt	   CACHE_DIR(   R   t	   __class__R,   t
   _cache_dirR   t   run_caching_overload_method(   R4   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_caching_overload_method  s    c   	      C` s]  t  d t d t  t  } |  j | t    d  t | d d  | j t f  } g  | j   D]' } | j	 d  rc d | k rc | ^ qc } |  j
 t |  d  y t j d  } Wn t k
 r t } n X| j   } | j d	 t d
 | |  j f  } | j   | j t    | j   |  j
 | j d  | j d d  } |  j
 | d  d  S(   NR   t   cachei   i    i   t   declareR   t   spawnt   targetRV   t   timeout(   R   R   R   R   R+   R_  t   inspect_llvmR9   t
   splitlinest
   startswithR   R   t   multiprocessingt   get_contextt   AttributeErrort   Queuet   ProcessRd  Rc  t   startt   putt   joint   exitcodet   get(	   R4   R   t   llvmirt   lnt   declst   ctxt   qt   pRy   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRd    s(    '


(   R,   R-   R   t   _numba_parallel_test_Re  Rd  (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR`    s   	c      	   C` sj   t  d |  U |  j   } t d t d t  t  } | |  } |  j |  t | d d  Wd QXd S(   sH   
    Used by TestOverloadMethodCaching.test_caching_overload_method
    Ra  R   Rf  i   i    N(   R   Rw  R   R   R   Rt  R_  (   R|  t	   cache_dirR   R   Ry   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRd  
  s    t   TestIntrinsicc           B` s,   e  Z d    Z d   Z d   Z d   Z RS(   c         ` s   t  d     t  d      t d t   f d    } t d t    f d    } |  j |   d  |  j t   } |   Wd QX|  j d | j j  d S(	   s   
        Verify that returning a None from codegen function is handled
        automatically for void functions, otherwise raise exception.
        c         S` s%   t  j t  j  } d   } | | f S(   Nc         S` s   d  S(   N(    (   R5   R>   R%   RV   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   codegen   s    (   R   t   voidRP   (   R   R   RU   R  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt	   void_func  s    	c         S` s%   t  j t  j  } d   } | | f S(   Nc         S` s   d  S(   N(    (   R5   R>   R%   RV   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR  )  s    (   R   RP   (   R   R   RU   R  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   non_void_func&  s    	R   c           ` s     d  d S(   Ni   i    (    (    (   R  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_void_func-  s    
c           ` s     d  d S(   Ni   i    (    (    (   R  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   call_non_void_func2  s    
i    Ns   non-void function returns None(	   R    R   R   R   R	  R   R
  R  RA  (   R4   R  R  R  (    (   R  R  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_void_return  s    	c         ` s"  d d l  m } m } m } m }  f d    d    t  d t  f d    } d   } | d | |  |  } | |    t d t	     f d	    } t
 j d
 d t
 j }	 t   # }
 | |	  |
 j   j   } Wd QX|
 j   t t t |	   }  j | |  d S(   sV   
        Usecase test: custom reinterpret cast to turn int values to pointers
        i    (   t	   CFUNCTYPEt   POINTERt   c_floatt   c_intc         ` s4   t    t j  s t  t    f d    } | S(   Nc         ` sK    j  |  t j  t | t j  rG   t j  } d   } | | f Sd  S(   Nc         S` s1   | \ } | j  } |  j |  } | j | |  S(   N(   RT   t   get_value_typet   inttoptr(   R5   R>   R%   RV   t   srct   rtypet   llrtype(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR  O  s    		(   R   R	   t   ContextR0   R   R   t   uintp(   R   R  RU   R  (   t   result_typeR4   (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   unsafe_castH  s
    	(   R0   R   t   CPointerR   R    (   R  R  (   R4   (   R  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   unsafe_casterE  s    c         S` s   t  d   d  S(   Ns   not callable from python(   RK   (   R  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   unsafe_get_ctypes_pointer[  s    RE  c         ` sA   t  |  t j  r=  t j |  j       f d   } | Sd  S(   Nc         ` s     d |  j  j  S(   NR  (   t   ctypesR   (   R   (   R  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt
   array_implc  s    (   R0   R   R   R  R   (   t   arrtypeR  (   R  (   R  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt$   array_impl_unsafe_get_ctypes_pointer^  s    c         S` s)   x" t  |  D] } t |  |  q Wd  S(   N(   Rw   R   (   t   ptrR#  R~   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   my_c_fun_rawh  s    R   c         ` s     |   }   | |  j   d  S(   N(   Rx   (   R   R  (   t   my_c_funR  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR.  q  s    i
   R   N(   R  R  R  R  R  R   R   RN   R   R   Rl   R   t   float32R   R  Rl  t   closeR   t   mapR  R   (   R4   R  R  R  R  R  R  t	   prototypeR.  R   t   bufR   R$  (    (   R  R4   R  R  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_ll_pointer_cast>  s    "	!
	!

c         ` s&  t  d      t d t    f d    } |  j | d  d  t j } t |  } t j |  } | d 7} |  j | t |   t j	 |  } |  j | t |   |  j | d  | d   t j    } |  j | t |   t j	 |  } |  j
   |  |  j | t |   d S(   s9   
        Test serialization of intrinsic objects
        c         S` s   d   } | |  } | | f S(   Nc         S` s   | d S(   Ni    (    (   R5   R>   R%   RV   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR    s    (    (   R5   RL   R  RU   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   identity  s    	R   c         ` s
     |   S(   N(    (   RL   (   R  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR.    s    i   N(   R    R   R   R   R!   t   _memoR   t   picklet   dumpst   loadsR   (   R4   R.  t   memot	   memo_sizet   serialized_foot   foo_rebuiltt   serialized_identityt   identity_rebuilt(    (   R  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_serialization  s     		
c         C` s   d   } t  j } t |  } t  d |  } |  j | j |  t j |  } | d 7} |  j | t |   ~ |  j | t |   t  j j	   | d 8} |  j | t |   t j
 |  } |  j | j |  t j
 |  } |  j | j | j  d S(   s3   
        Test deserialization of intrinsic
        c         S` s   d   } | |  | f S(   Nc         S` s   | d S(   Ni    (    (   R5   R>   R%   RV   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR    s    (    (   R5   RL   R  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   defn  s    	R.  i   N(   R!   R  R   R   t   _defnR  R  R   t   _recentt   clearR  t   assertIsNot(   R4   R  R  R  t   originalt   pickledt   rebuiltt   second(    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_deserialization  s"    		

(   R,   R-   R  R  R  R  (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR    s   	'	A	.t   TestRegisterJitablec           B` s   e  Z d    Z d   Z RS(   c         ` se   t  d        f d   } t d t  |  } | d d  } | d d  } |  j | |  d  S(   Nc         S` s   |  | S(   N(    (   RL   Rj   (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR.    s    c         ` s     |  |  S(   N(    (   RL   Rj   (   R.  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRL    s    R   i   i   (   R"   R   R   R   (   R4   RL  t   cbarR$  R   (    (   R.  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_no_flags  s    c         ` s   t  d t  d        f d   } |  j | d  j   d d d g  t d t  |  } |  j t j   } | d  Wd  QXd	 } |  j	 | t
 | j   d  S(
   Nt   _nrtc         S` s   t  j |   S(   N(   Rl   R   (   R#  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR.    s    c         ` s
     |   S(   N(    (   R#  (   R.  (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyRL    s    i   i    i   i   R   sC   Only accept returning of array passed into the function as argument(   R"   R   R   t   tolistR   R   R	  R   R   R
  R  R  (   R4   RL  R  R  RA  (    (   R.  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_flags_no_nrt  s    %(   R,   R-   R  R  (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR    s   	t   TestImportCythonFunctionc           B` sS   e  Z e j e d k d   d    Z d   Z e j e d k d   d    Z RS(   s&   Only run if SciPy >= 0.19 is installedc         ` sk   t  d d  } t j t j t j  } | |    t d t    f d    } |  j | d  d  d  S(   Ns   scipy.special.cython_specialt   j0R   c         ` s
     |   S(   N(    (   RL   (   t   _j0(    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR     R   i    i   (   R#   R  R  t   c_doubleR   R   R   (   R4   t   addrt   functypeR  (    (   R  s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_getting_function  s
    c         C` sY   |  j  t   } t d d  } Wd  QXd } t j | t | j   } |  j |  d  S(   Nt
   fakemodulet   fakefunctions   No module named '?fakemodule'?(   R	  t   ImportErrorR#   t   ret   matchR  R  t   assertIsNotNone(   R4   R  R  RA  R  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_missing_module  s
    c         C` sJ   |  j  t   } t d d  } Wd  QXd } |  j | t | j   d  S(   Ns   scipy.special.cython_specialR.  sI   No function 'foo' found in __pyx_capi__ of 'scipy.special.cython_special'(   R	  Rt   R#   R   R  R  (   R4   R  R  RA  (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   test_missing_function  s    N(	   R,   R-   RV  t   skipIft   scRN   R  R  R  (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyR    s   !	t   __main__(   t
   __future__R    R   R   RX   R   R  R  Rn  R  t   distutils.versionR   R  t   numpyRl   t   numbaR   RV  R   R   R   R   R	   R
   t   numba.targets.registryR   t   numba.compilerR   t   supportR   R   R   R   R   t   numba.errorsR   t   numba.extendingR   R   R   R   R   R   R   R   R   R   R   R   R   R    R!   R"   R#   t   numba.typing.templatesR$   R%   R&   R'   R(   t   version_infoR=  t   pdlike_usecaseR)   R*   t   scipyt   __version__RN   R  t   scipy.special.cython_specialt   specialt   cython_specialR  t   objectR+   t   OpaqueR.   R9   R8   t   registerR<   R1   R@   RA   t   OpaqueModelRE   RF   RG   RI   RH   RJ   RM   RS   RO   RW   RQ   R\   R]   Rh   Rk   Rm   Rn   R   R   R   R   R   R   t   delitemR   t   getitemR   t   setitemR   R   R   t   iaddR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   RS  R   R   R   R  R_  R`  Rd  R  R  R  R,   t   main(    (    (    s9   lib/python2.7/site-packages/numba/tests/test_extending.pyt   <module>   s   .(p(	
										-																												*c 		$	 