σ
ξ&]\c           @` s   d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l Z d d g Z d e	 f d     YZ
 d e f d     YZ d	   Z d
   Z d   Z d S(   s   
Generic test utilities.

i    (   t   divisiont   print_functiont   absolute_importNt   PytestTestert   check_free_memoryt   FPUModeChangeWarningc           B` s   e  Z d  Z RS(   s   Warning about FPU mode change(   t   __name__t
   __module__t   __doc__(    (    (    s4   lib/python2.7/site-packages/scipy/_lib/_testutils.pyR      s   c           B` s2   e  Z d  Z d   Z d d d e e d d  Z RS(   s)   
    Pytest test runner entry point.
    c         C` s   | |  _  d  S(   N(   t   module_name(   t   selfR	   (    (    s4   lib/python2.7/site-packages/scipy/_lib/_testutils.pyt   __init__   s    t   fasti   c         C` sl  d d  l  } t j |  j } t j j | j d  }	 d g }
 | rS t d   n  | rl |
 t	 |  7}
 n  | r¦ t
 |  d k r¦ |
 d d t
 |  d g 7}
 n  | rΐ |
 d |	 g 7}
 n  | d k rί |
 d	 d
 g 7}
 n | d k rώ |
 d	 | g 7}
 n  | d  k r|  j g } n  |
 d g t	 |  7}
 y | j |
  } Wn t k
 ra} | j } n X| d k S(   Ni    s   -ls   Doctests not supportedi   t   -t   vs   --cov=R   s   -ms   not slowt   fulls   --pyargs(   t   pytestt   syst   modulesR	   t   ost   patht   abspatht   __path__t
   ValueErrort   listt   intt   Nonet   maint
   SystemExitt   code(   R
   t   labelt   verboset
   extra_argvt   doctestst   coveraget   testsR   t   modulet   module_patht   pytest_argsR   t   exc(    (    s4   lib/python2.7/site-packages/scipy/_lib/_testutils.pyt   __call__   s0    	"N(   R   R   R   R   R   t   FalseR(   (    (    (    s4   lib/python2.7/site-packages/scipy/_lib/_testutils.pyR      s   	c         C` s―   d d l  } y0 t t j d  } d j |  t j d  } WnL t k
 r t   } | d k rq | j d  n  d j |  | d  } n X| |  d k  r« | j |  n  d S(   sJ   
    Check *free_mb* of memory is available, otherwise do pytest.skip
    i    Nt   SCIPY_AVAILABLE_MEMs?   {0} MB memory required, but environment SCIPY_AVAILABLE_MEM={1}sl   Could not determine available memory; set SCIPY_AVAILABLE_MEM variable to free memory in MB to run the test.s,   {0} MB memory required, but {1} MB availableg    .A(	   R   t   _parse_sizeR   t   environt   formatt   KeyErrort   _get_mem_availableR   t   skip(   t   free_mbR   t   mem_freet   msg(    (    s4   lib/python2.7/site-packages/scipy/_lib/_testutils.pyR   D   s    	c         C` sη   i d d 6d d 6d d 6d d 6d d	 6d
 d 6d d 6d d 6d d 6d
 d 6d d 6d d 6d d 6d d 6} t  j d j d j | j     |  t  j  } | s΄ | j d  | k rΓ t d   n  t | j d   | | j d  S(   Ng    .At    g      π?t   bg     @@t   kt   Mg    eΝΝAt   Gg   ’mBt   Tt   kbt   Mbt   Gbt   Tbg      @t   kibi   t   Mibi   t   Gibi   t   Tibs   ^\s*(\d+)\s*({0})\s*$t   |s   Invalid size stringi   g      0Ag      ΠAg      pB(	   t   ret   matchR-   t   joint   keyst   It   groupR   t   float(   t   size_strt   suffixest   m(    (    s4   lib/python2.7/site-packages/scipy/_lib/_testutils.pyR+   Z   s    
!c       	   C` sΪ   y d d l  }  |  j   j SWn t t f k
 r6 n Xt j j d  rΦ i  } t d d  O } xE | D]= } | j	   } t
 | d  d | | d j d  j   <qh WWd QXd	 | k rΓ | d	 S| d
 | d Sn  d S(   sD   
    Get information about memory available, not counting swap.
    i    Nt   linuxs   /proc/meminfot   ri   g     @@t   :t   memavailablet   memfreet   cached(   t   psutilt   virtual_memoryt	   availablet   ImportErrort   AttributeErrorR   t   platformt
   startswitht   opent   splitRI   t   stript   lowerR   (   RS   t   infot   ft   linet   p(    (    s4   lib/python2.7/site-packages/scipy/_lib/_testutils.pyR/   i   s    5(   R   t
   __future__R    R   R   R   RC   R   t   __all__t   RuntimeWarningR   t   objectR   R   R+   R/   (    (    (    s4   lib/python2.7/site-packages/scipy/_lib/_testutils.pyt   <module>   s   /		