ó
\K]c           @` sŹ   d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l j	 Z
 d d l m Z d d l m Z d d l m Z d e f d	     YZ e d
 k rš e
 j   n  d S(   s<   
Tests issues or edge cases for producing invalid NRT refct
i    (   t   divisiont   absolute_importt   print_functionN(   t   njit(   t   rtsysi   (   t   TestCaset   TestNrtRefCtc           B` s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C` s   t  j   d  S(   N(   t   gct   collect(   t   self(    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt   setUp   s    c         C` so   t  d    } d } t j   } | |  t j   } |  j | j | j |  |  j | j | j |  d S(   s"   
        Test issue #1291
        c         S` s*   x# t  |   D] } t j d  } q Wd S(   Ni   i    (   t   ranget   npt   zeros(   t   nt   it   temp(    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt   foo   s    i
   N(   R   R   t   get_allocation_statst   assertEqualt   alloct   free(   R	   R   R   t
   init_statst	   cur_stats(    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt   test_no_return   s    
c         C` si   t  d    } t j   } | d  t j   } |  j | j | j d  |  j | j | j d  d S(   s"   
        Test issue #1297
        c         S` s[   t  j |  d f  } x t |   D] } | | } q" Wx t |   D] } | | } qC Wd S(   Ni   i    (   R   R   R   (   R   t   xR   t   y(    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt   g.   s    i
   i   N(   R   R   R   R   R   R   (   R	   R   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt   test_escaping_var_init_in_loop)   s    
c         C` sn   t  d    } t j j d  } t j   } | | t  t j   } |  j | j | j | j | j  d S(   s"   
        Test issue #1573
        c         S` sG   t  j |   } x t | j d  D] } q# W| rC t  j |   n  | S(   Ni    (   R   t
   zeros_likeR   t   shape(   t   arr1t   test1t   tmp_arrR   (    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt%   if_with_allocation_and_initializationE   s    i   N(   i   i   (	   R   R   t   randomR   R   t   FalseR   R   R   (   R	   R"   t   arrR   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt$   test_invalid_computation_of_lifetimeA   s    c         C` sh   t  d    } t j d  } t j   } | |  t j   } |  j | j | j | j | j  d S(   s"   
        Test issue #1734
        c         S` sF   d } x9 d D]1 } |  | } | | d k r | | | 7} q q W| S(   Ni    i   (   i    i   (    (   R%   t   resR   t   t(    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt   f]   s    
i   N(   i   i   (   R   R   t   onesR   R   R   R   R   (   R	   R)   R%   R   R   (    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt   test_del_at_beginning_of_loopY   s    
(   t   __name__t
   __module__R
   R   R   R&   R+   (    (    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyR      s
   				t   __main__(   t   __doc__t
   __future__R    R   R   R   t   numpyR   t   numba.unittest_supportt   unittest_supportt   unittestt   numbaR   t   numba.runtimeR   t   supportR   R   R,   t   main(    (    (    s9   lib/python2.7/site-packages/numba/tests/test_nrt_refct.pyt   <module>   s   a