ó
íYc           @   s   d  Z  d d l Z d d l Z d d l m Z m Z m Z d d l Z	 d d l
 m Z m Z d   Z d   Z d   Z d	   Z d
   Z d S(   s   Test replace().i˙˙˙˙N(   t   assert_equalt   assert_array_equalt   assert_raisesi   (   t   arrayst   array_orderc          c   s)   x" t  j d  D] }  t |  f Vq Wd S(   s   test nonreduce functionst	   nonreduceN(   t   bnt   get_functionst
   unit_maker(   t   func(    (    s>   lib/python2.7/site-packages/bottleneck/tests/nonreduce_test.pyt   test_nonreduce   s    c         C   s]  d } | d 7} |  j  } t d |  } t j j d d d g  } d d t j t j g } xůt t |   D]ĺ\ } } xÖt	 d  D]Č} | j
 d k r§ d }	 n( | j t | j
 d   } | j | }	 x| D]w}
 t | j j t j  s!t j |	  s	qÖ n  t j |
  s!qÖ q!n  | j   } t j   " t j d  |  | |	 |
  Wd	 QX| j   } t j   " t j d  | | |	 |
  Wd	 QX| d
 t |  t | j  t | j  |	 |
 t |  | f } | | } t | | d | | d 7} t | d  st | d  rÖ | j } | j } t | | | | | f  qÖ qÖ Wq Wqp Wd	 S(   s1   Test that bn.xxx gives the same output as np.xxx.sA   
func %s | input %s (%s) | shape %s | old %f | new %f | order %s
s   
Input array:
%s
s
   bn.slow.%si   i   i   i    t   ignoreNt   at   err_msgs   
 dtype mismatch %s %st   dtype(   t   __name__t   evalt   npt   randomt   RandomStatet   nant   inft	   enumerateR   t   ranget   sizet   randintt   maxt   flatt
   issubclassR   t   typet   inexactt   isfinitet   copyt   warningst   catch_warningst   simplefiltert   strt   shapeR   R   t   hasattrR    (   R	   t   msgt   namet   func0t   rst   newst   it   arrt   idxt   oldt   newt   actualt   desiredt   tupR   t   dat   dd(    (    s>   lib/python2.7/site-packages/bottleneck/tests/nonreduce_test.pyR      sF    
			$

		c          C   s¸   d d g }  xĽ |  D] } t  j d d | } t t t j | j   d d  t t t j | j   d d  t t t j j | j   d d  t t t j j | j   d d  q Wd S(   s   Test replace for unsafe castst   int32t   int64i   R   gš?i    N(   R   t   zerosR   t
   ValueErrorR   t   replaceR    t   slow(   t   dtypesR   R   (    (    s>   lib/python2.7/site-packages/bottleneck/tests/nonreduce_test.pyt   test_replace_unsafe_cast>   s    "c          C   sK   d d d g }  t  t t j |  d d  d }  t  t t j |  d d  d S(   s    Test that non-array input raisesi   i   i   i    N(   i   i   i   (   R   t	   TypeErrorR   R:   (   R   (    (    s>   lib/python2.7/site-packages/bottleneck/tests/nonreduce_test.pyt   test_non_arrayI   s    c          C   s§   t  j d
  j d d d  }  |  j   } t j | t  j d  |  j   } d } t | | d | |  j   } t j j | t  j d  d } t | | d | d S(   s'   Test replace, int array, old=nan, new=0i   i   i   i    s,   replace failed on int input looking for nansR   s1   slow.replace failed on int input looking for nansNi   i   (	   R   t   aranget   reshapeR    R   R:   R   R   R;   (   R   R1   R2   R'   (    (    s>   lib/python2.7/site-packages/bottleneck/tests/nonreduce_test.pyt   test_replace_nan_intU   s    (   t   __doc__R!   t   numpyR   t   numpy.testingR    R   R   t
   bottleneckR   t   utilR   R   R
   R   R=   R?   RB   (    (    (    s>   lib/python2.7/site-packages/bottleneck/tests/nonreduce_test.pyt   <module>   s   		-		