3
Kd                @   s  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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mZ d dljj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)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> dd Z?d	d
 Z@G dd dZAG dd dZBG dd dZCG dd dZDG dd dZEG dd dZFG dd dZGG dd dZHG dd dZIG dd dZJG dd  d ZKG d!d" d"ZLG d#d$ d$ZMG d%d& d&ZNG d'd( d(ZOG d)d* d*ZPG d+d, d,ZQG d-d. d.ZRG d/d0 d0ZSG d1d2 d2ZTdkd4d5ZUdld7d8ZVG d9d: d:ZWG d;d< d<ZXG d=d> d>ZYG d?d@ d@ZZG dAdB dBZ[G dCdD dDZ\G dEdF dFZ]G dGdH dHZ^G dIdJ dJZ_G dKdL dLZ`G dMdN dNZaG dOdP dPZbG dQdR dRZcG dSdT dTZdG dUdV dVZeG dWdX dXZfG dYdZ dZZgG d[d\ d\Zhd]d^ ZiG d_d` d`ZjG dadb dbZkG dcdd ddZlG dedf dfZmG dgdh dhZnG didj djZodS )m    N)Fraction)ma)assert_assert_equalassert_array_equalassert_almost_equalassert_array_almost_equalassert_raisesassert_allcloseIS_PYPYassert_warnsassert_raises_regexsuppress_warningsHAS_REFCOUNT)rand) add_newdoc_ufuncangleaveragebartlettblackmancorrcoefcovdeletediffdigitizeextractflipudgradienthamminghanningi0insertinterpkaisermeshgridmsort	piecewiseplacerot90selectsetxor1dsinctrapz
trim_zerosunwrapunique	vectorizec             C   s   t j| }t jj||}|S )N)nparangeaddouter)ndata r7   V/var/www/html/virt/lib64/python3.6/site-packages/numpy/lib/tests/test_function_base.pyget_mat   s    
r9   c             C   s(   t jt j| |jt j}| |_||_|S )za
    Like real + 1j * imag, but behaves as expected when imag contains non-finite
    values
    )r1   zeros	broadcastshapecomplex_realimag)r>   r?   retr7   r7   r8   _make_complex    s    rA   c               @   s$   e Zd Zdd Zdd Zdd ZdS )	TestRot90c             C   s  t tttjd t tttjddd t tttjddd t tttjddd t tttjddd dddgdddgg}ddgddgddgg}dddgdddgg}ddgddgddgg}dddgdddgg}x(tdddD ]}tt||d	|  qW x(tdddD ]}tt||d	| q
W x(tdddD ]}tt||d	| q4W x(tdddD ]}tt||d	| q^W ttt|dddd| tt|ddd
t|ddd
 d S )N      r      )axes         )k)rJ   rF   )rD   rD   rD   )r   rE   rD   )rD   rD   )r   rD   )rD   rD   )rE   rE   )rD   rD   rD   )rK   rE   rK   )r   rE   )rE   r   )rE   r   rM   )r   rE   )r	   
ValueErrorr(   r1   onesranger   )selfaZb1Zb2Zb3Zb4rJ   r7   r7   r8   
test_basic,   s6    

zTestRot90.test_basicc             C   sR   t jd}tt|jd	 tt|d
dt|dd tt|ddt|dd d S )N2   (   rG   r   rD   )rF   rE   )rT   rU   rG   )rU   rT   rG   )r   rD   rM   )r   rM   )rE   rD   rK   rM   )rK   rM   )r1   rO   r   r(   r<   )rQ   rR   r7   r7   r8   	test_axesL   s    
zTestRot90.test_axesc             C   s   t jdjd}ddgddggddgdd	ggg}ddgddggd	dgddggg}ddgddggd	dgddggg}dd	gddggddgddggg}tt|dd
| tt|dd
| tt|dd
| x4tdd	D ]&}tt||ddt||d dd qW d S )N   rD   rG         r   rE   rC   rH   )rF   )rJ   rF   )rD   rD   rD   )r   rE   )rE   r   )rE   rD   )rD   r   )rD   r   )r1   r2   reshaper   r(   rP   )rQ   rR   Z
a_rot90_01Z
a_rot90_12Z
a_rot90_20Z
a_rot90_10rJ   r7   r7   r8   test_rotation_axesR   s.    zTestRot90.test_rotation_axesN)__name__
__module____qualname__rS   rV   r[   r7   r7   r7   r8   rB   +   s    rB   c               @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )TestFlipc             C   sl   t tjtjtjddd t tjtjtjddd t tjtjtjdd	d t tjtjtjd
dd d S )NrC   rE   )axisrD   rG   r   )rC   rC   )rC   rC   rL   )rC   rC   )r   rG   )r	   r1   	AxisErrorfliprO   )rQ   r7   r7   r8   rV   q   s    zTestFlip.test_axesc             C   sn   t d}|d d d d df }ttj|d| dddgdddgg}dddgdddgg}ttj|d| d S )NrC   rE   r   rD   rG   rH   rM   )r9   r   r1   rb   )rQ   rR   br7   r7   r8   test_basic_lrw   s    zTestFlip.test_basic_lrc             C   sn   t d}|d d dd d f }ttj|d| dddgdddgg}dddgdddgg}ttj|d| d S )NrC   rE   r   rD   rG   rH   rM   )r9   r   r1   rb   )rQ   rR   rc   r7   r7   r8   test_basic_ud   s    zTestFlip.test_basic_udc             C   sb   t jddgddggddgddggg}t jddgddggddgddggg}tt j|d| d S )	Nr   rE   rD   rG   rC   rH   rX   rY   )r1   arrayr   rb   )rQ   rR   rc   r7   r7   r8   test_3d_swap_axis0   s    

zTestFlip.test_3d_swap_axis0c             C   sb   t jddgddggddgddggg}t jddgddggddgddggg}tt j|d| d S )	Nr   rE   rD   rG   rC   rH   rX   rY   )r1   rf   r   rb   )rQ   rR   rc   r7   r7   r8   test_3d_swap_axis1   s    

zTestFlip.test_3d_swap_axis1c             C   sb   t jddgddggddgddggg}t jddgddggddgddggg}tt j|d| d S )	Nr   rE   rD   rG   rC   rH   rX   rY   )r1   rf   r   rb   )rQ   rR   rc   r7   r7   r8   test_3d_swap_axis2   s    

zTestFlip.test_3d_swap_axis2c             C   sV   t jdjdddd}x:t|jD ],}tt j||t j|jd|j|d q"W d S )	NrD   rG   rC   rH   r   rX      x   )	r1   r2   rZ   rP   ndimr   rb   r   swapaxes)rQ   rR   ir7   r7   r8   test_4d   s    zTestFlip.test_4dc             C   sH   t jdddgdddgg}t jdddgdddgg}tt j|| d S )NrE   rD   rG   rC   rH   rX   )r1   rf   r   rb   )rQ   rR   rc   r7   r7   r8   test_default_axis   s
    zTestFlip.test_default_axisc             C   s   t jddgddggddgddggg}tt j|f d	| t jddgddggddgddggg}tt j|d
d	| t jddgddggddgddggg}tt j|dd	| d S )Nr   rE   rD   rG   rC   rH   rX   rY   )r`   )r   rD   )rE   rD   )r1   rf   r   rb   )rQ   rR   rc   cr7   r7   r8   test_multiple_axes   s    


zTestFlip.test_multiple_axesN)r\   r]   r^   rV   rd   re   rg   rh   ri   ro   rp   rr   r7   r7   r7   r8   r_   o   s   

r_   c               @   s   e Zd Zdd Zdd ZdS )TestAnyc             C   sT   ddddg}ddddg}ddddg}t tj| t tj| t tj|  d S )Nr   rE   )r   r1   any)rQ   y1y2y3r7   r7   r8   rS      s    zTestAny.test_basicc             C   sb   dddgdddgdddgg}t tj| ttj|dddddg ttj|dddddg d S )Nr   rE   )r`   )r   r1   rt   r   Zsometrue)rQ   ru   r7   r7   r8   test_nd   s    zTestAny.test_ndN)r\   r]   r^   rS   rx   r7   r7   r7   r8   rs      s   rs   c               @   s   e Zd Zdd Zdd ZdS )TestAllc             C   sl   ddddg}ddddg}ddddg}t tj|  t tj| t tj|  t tjtj|  d S )Nr   rE   )r   r1   allrf   )rQ   ru   rv   rw   r7   r7   r8   rS      s    zTestAll.test_basicc             C   sd   dddgdddgdddgg}t tj|  ttj|dddddg ttj|dddddg d S )Nr   rE   )r`   )r   r1   rz   r   Zalltrue)rQ   ru   r7   r7   r8   rx      s    zTestAll.test_ndN)r\   r]   r^   rS   rx   r7   r7   r7   r8   ry      s   	ry   c               @   s$   e Zd Zdd Zdd Zdd ZdS )TestCopyc             C   sR   t jddgddgg}t j|}t|| d|d< t|d d t|d	 d d S )
NrE   rD   rG   rC   
   r   )r   r   )r   r   )r   r   )r1   rf   copyr   r   )rQ   rR   a_copyr7   r7   r8   rS      s    

zTestCopy.test_basicc             C   s   t jddgddgg}t|jj t|jj  t jddgddggdd}t|jj  t|jj t j|}t|jj t|jj  t j|}t|jj  t|jj d S )NrE   rD   rG   rC   F)order)r1   rf   r   flagsc_contiguousf_contiguousr}   )rQ   rR   Za_fortr~   Za_fort_copyr7   r7   r8   
test_order  s    

zTestCopy.test_orderc             C   sV   t jd}tt jtj|dd  tt jtj|dd tt jtj|  d S )NrH   F)ZsubokT)r   rO   r   ZisMaskedArrayr1   r}   )rQ   Zmxr7   r7   r8   
test_subok  s    
zTestCopy.test_subokN)r\   r]   r^   rS   r   r   r7   r7   r7   r8   r{      s   r{   c               @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestAveragec             C   s   t jdddg}tt|dddk t jdddg}tt|dddk d	d	d	g}tt|ddd	k t jd}d|d< d|d< t|jdt|d t|jdt|d tdd}t|jdt|d t|jdt|d d S )NrE   rD   rG   r   )r`   g       @g      ?g      @g        rC   rH   )rC   rC   )r   rE   )rE   r   )r1   rf   r   r   rO   r   meanr   )rQ   ru   rv   rw   Zy4Zy5r7   r7   r8   rS     s    


zTestAverage.test_basicc             C   sT  t jd}t jd}t||d}t jdd j d t jdj  }t|| t jdddgddd	gg}ddg}t||d
d}t jdddg}t|| d
d
dg}t||dd}t jddg}t|| d
d
dgd
d
dgg}t jddg}tt||dd| tt||dd tdj	t j
}	tdj	t j}
tt j|	|
djt j|	|
k d S )Nr|   )weightsrD   g      ?rE   rG   rC   rH   rX   r   )r   r`   g      @g      @g      @g      @)r1   r2   r   sumr   rf   r   r   r   astypefloat32float64r   dtypeZresult_type)rQ   ywactualdesiredru   w0w1w2rw   Zw3r7   r7   r8   test_weights0  s*    

$



zTestAverage.test_weightsc             C   s&  t jdddgdddgg}t|dd\}}t|d	 t|d
dd\}}t|t jdddg t|ddd\}}t|t jddg ddg}t||d
dd\}}t|t jdddg dddg}t||ddd\}}t|t jd	d	g d
d
dgdddgg}t||ddd\}}t|t jdd	g d S )NrE   rD   rG   rC   rH   rX   T)returnedg      @r   g       @g      @)r   r`   r   g      ?)r1   rf   r   r   r   )rQ   r   avgZsclr   r   r   r7   r7   r8   test_returnedP  s     

zTestAverage.test_returnedc             C   sz   G dd dt j}t jddgddggj|}t jddgddggj|}ttt j|| ttt j||d| d S )Nc               @   s   e Zd ZdS )z-TestAverage.test_subclasses.<locals>.subclassN)r\   r]   r^   r7   r7   r7   r8   subclassk  s   r   rE   rD   rG   rC   )r   )r1   ndarrayrf   viewr   typer   )rQ   r   rR   r   r7   r7   r8   test_subclassesj  s
    zTestAverage.test_subclassesc             C   sv   d
ddddg}xb|D ]Z\}}}t jddgddgg|d}t jddgddgg|d}tt j||d	jt j| qW d S )Ni4f8f4rE   rD   rG   rC   )r   )r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r1   rf   r   r   r   )rQ   ZtypsZatwtrtrR   r   r7   r7   r8   test_upcastings  s    zTestAverage.test_upcastingc             C   sX   t jdd tdD }t jdd tdD }||j  }t|jdt||d d S )Nc             S   s   g | ]}t j|qS r7   )decimalDecimal).0xr7   r7   r8   
<listcomp>|  s    z1TestAverage.test_object_dtype.<locals>.<listcomp>r|   c             S   s   g | ]}t jd qS )rE   )r   r   )r   _r7   r7   r8   r   }  s    r   )r   )r1   rf   rP   r   r   r   r   )rQ   rR   r   r7   r7   r8   test_object_dtype{  s    zTestAverage.test_object_dtypeN)	r\   r]   r^   rS   r   r   r   r   r   r7   r7   r7   r8   r     s    	r   c               @   s   e Zd Zejdddgejdddgejddd	ggZejd
d
d
gejd
dd
gejd
d
dggZdddZdd Zdd Z	dd Z
dd Zdd Zdd ZdS )
TestSelectrE   rD   rG   rC   rH   rX   rY   rW   	   FTr   c                s@   g }x6t t|D ]& | fddt||D p4|g7 }qW |S )Nc                s    g | ]\}}|  r|  qS r7   r7   )r   VC)mr7   r8   r     s    z&TestSelect._select.<locals>.<listcomp>)rP   lenzip)rQ   Zcondvaluesdefaultoutputr7   )r   r8   _select  s    &zTestSelect._selectc             C   sL   | j }| j}tt||dd| j||dd tt|d tt|d d S )N   )r   rG   )choices
conditionsr   r)   r   r   r   )rQ   r   r   r7   r7   r8   rS     s    zTestSelect.test_basicc             C   sf   t jdt jdddgg}dt jdjddg}tt||t jd	 ttdgdgdgdjd
 d S )NTFrE      rC   rG   r   )r   )rC   rG   )rE   )	r1   rf   r2   rZ   r   r)   rO   r   r<   )rQ   r   r   r7   r7   r8   test_broadcasting  s    zTestSelect.test_broadcastingc             C   s   t t| j| jdjtj dd | jD }t t| j|jtj tjdddtj	ddg}tj
|}t t|g|gd	d	d	tj	d	d	g d S )
Ny              ?c             S   s   g | ]}|j tjqS r7   )r   r1   int8)r   choicer7   r7   r8   r     s    z0TestSelect.test_return_dtype.<locals>.<listcomp>rE   rD   rG   rH   rY   r   )r   r)   r   r   r   r1   r=   r   rf   nanisnan)rQ   r   dr   r7   r7   r8   test_return_dtype  s    
zTestSelect.test_return_dtypec             C   s"   t ttg g d t ttg g  d S )Ny              @)r	   rN   r)   )rQ   r7   r7   r8   test_deprecated_empty  s    z TestSelect.test_deprecated_emptyc             C   sj   | j }| jd d  }|d jtj|d< ttt|| |d jtj|d< ttt|| ttt|| d S )Nr   )	r   r   r   r1   int_r	   	TypeErrorr)   uint8)rQ   r   r   r7   r7   r8   test_non_bool_deprecation  s    z$TestSelect.test_non_bool_deprecationc             C   s2   t jdggd }t jdggd }t|| d S )NFd   rE   )r1   rf   r)   )rQ   r   r   r7   r7   r8   test_many_arguments  s    zTestSelect.test_many_argumentsN)r   )r\   r]   r^   r1   rf   r   r   r   rS   r   r   r   r   r   r7   r7   r7   r8   r     s   
		r   c               @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )
TestInsertc             C   s  dddg}t t|ddddddg t t|ddddddg t t|dddgdddgddddddg t t|ddddgddddddg t t|dddgdddddddg t t|tdd ddddddddg t t|dddgdddgddddddg tjddgtjd}t t|d|d d	d	d
g t t|g g | tjddR}tjddt	 t t|tjdgd ddddddddg t
|d jt	k W d Q R X d S )NrE   rD   rG   r   r   rY   rW   )r   g        g      ?T)recordalways rC   rM   rM   rM   rM   )r   r!   slicer1   rf   r   warningscatch_warningsfilterwarningsFutureWarningr   category)rQ   rR   rc   r   r7   r7   r8   rS     s     
*$$&**zTestInsert.test_basicc          
   C   s  dddgg}dddgdddgg}t t|ddgddddg t t|ddddgdd| t t|dddd| t t|ddddddddgg tjddgddgddgg}tjddjdjdd}tj|d d ddf tjddjdjddj|d d ddf fdd}t t|dgdgdgdggdd| t t|dgdddgdd| t t|ddddgdd| t t|ddgdgdggdd| tjdjdd}t t|d d d df d|d d df dd| t t|d dd d f d|dd d f dd| tjdjd}t t|d|d d d d df d	dt|d|d d d d df dd t t|d|d d dd d f d
dt|d|d d dd d f dd t	tj
t|d|d d dd d f dd t	tj
t|d|d d dd d f dd tjdjd}t t|d|d d d d df ddt|d|d d d d df dd t t|d|d d dd d f ddt|d|d d dd d f dd d S )NrE   rD   r   )r`   rG   rC   rj   )rD   rG   rC   rM   rK   )rD   rG   rC   rM   rK   )r   r!   r1   rf   r2   repeatrZ   ZconcatenateTr	   ra   )rQ   rR   rrc   rq   r7   r7   r8   test_multidim  s>     ,$"22"$"$(("$"zTestInsert.test_multidimc             C   s\   t jd}tjt j t|g ddd W d Q R X tjt t|g ddd W d Q R X d S )NrE   rD   r   )r`   nonsense)r1   rf   pytestraisesra   r!   r   )rQ   rR   r7   r7   r8   test_0d  s
    
zTestInsert.test_0dc             C   s   G dd dt j}t jdj|}ttt j|ddg| ttt j|g g | ttt j|ddgddg| ttt j|tddddg| ttt j|tdddg | t jdj|}ttt j|ddg| d S )	Nc               @   s   e Zd ZdS )z*TestInsert.test_subclass.<locals>.SubClassN)r\   r]   r^   r7   r7   r7   r8   SubClass  s   r   r|   r   rE   rD   rK   rM   )	r1   r   r2   r   r   
isinstancer!   r   rf   )rQ   r   rR   r7   r7   r8   test_subclass  s     " zTestInsert.test_subclassc             C   sD   t jdddg}t jdddg|dddg t|t jdddg d S )NrE   r   rD   rG   rC   rH   )r1   rf   r!   r   )rQ   r   r7   r7   r8   test_index_array_copied  s    z"TestInsert.test_index_array_copiedc             C   s   t jdddgddgd}d}t j|d|}t|d t j||jd dgd }t j|ddg|}t|ddg t j||jd d S )NrE   rR   rD   rc   rG   rq   foorn   bara1)r   rC   r   r   )rE   rR   )rD   rc   )rG   rq   )r   rn   )r   r   )rC   r   )rC   r   )r1   rf   r!   r   r   )rQ   rR   valrc   r7   r7   r8   test_structured_array  s    
z TestInsert.test_structured_arrayc             C   sp   t jt( tjdddgtjddgddg W d Q R X t jt$ tjdddgtjg tdg  W d Q R X d S )	Nr   rE   rD   g      ?g       @r|      )r   )r   r   
IndexErrorr1   r!   rf   float)rQ   r7   r7   r8   test_index_floats"  s    ,zTestInsert.test_index_floatsN)
r\   r]   r^   rS   r   r   r   r   r   r   r7   r7   r7   r8   r     s   *
r   c               @   s   e Zd Zdd ZdS )TestAmaxc             C   sv   dddddddg}t tj|d dddgdddgd	d
dgg}t tj|dddddg t tj|dddddg d S )NrG   rC   rH   r|   g      @g      $@g      "@g      @rW   g      @g       @r   )r`   g       @rE   rL   )r   r1   Zamax)rQ   rR   rc   r7   r7   r8   rS   +  s    zTestAmax.test_basicN)r\   r]   r^   rS   r7   r7   r7   r8   r   )  s   r   c               @   s   e Zd Zdd ZdS )TestAminc             C   sv   dddddddg}t tj|d dddgdddgd	d
dgg}t tj|ddd
d
dg t tj|ddd
ddg d S )NrG   rC   rH   r|   g      @g      @g      "@g      $@rW   g      @g       @r   )r`   rE   g      @rL   r   g      )r   r1   Zamin)rQ   rR   rc   r7   r7   r8   rS   7  s    zTestAmin.test_basicN)r\   r]   r^   rS   r7   r7   r7   r8   r   5  s   r   c               @   s   e Zd Zdd ZdS )TestPtpc             C   s   t jdddddddg}t|jddd t jddd	gdd
dgdddgg}t|jdddddg t|jdddddg t|jddddddgg t|jddddgg d S )NrG   rC   rH   r|   g      @r   )r`   g      .@g      "@g      $@g      @rW   g      @g       @g      @rE   T)r`   keepdimsg       @rL   r   rM   )r   rE   )r1   rf   r   Zptp)rQ   rR   rc   r7   r7   r8   rS   C  s    zTestPtp.test_basicN)r\   r]   r^   rS   r7   r7   r7   r8   r   A  s   r   c               @   s   e Zd Zdd ZdS )
TestCumsumc          
   C   s0  dddddddg}ddddgddd	d
gddddgg}xt jt jt jt jt jt jt jt jt j	t j
g
D ]}t j||}t j||}t jdddddddg|}tt j|dd| t jddddgddddgddddgg|}tt j|dd| t jddddgddddgddddgg|}tt j|dd| qbW d S )NrE   rD   r|      rX   rH   rC   rG   rY   r   rI   rj      #   '   r   )r`   rW                     )r1   r   r   int16uint16int32uint32r   r   	complex64
complex128rf   r   cumsum)rQ   baba2ctyperR   a2tgtr7   r7   r8   rS   R  s    "&&zTestCumsum.test_basicN)r\   r]   r^   rS   r7   r7   r7   r8   r   P  s   r   c               @   s   e Zd Zdd ZdS )TestProdc             C   s   dddddddg}ddddgddd	d
gddddgg}xt jt jt jt jt jt jt jt jgD ]}t j	||}t j	||}|dkrt
tt j| t
tt j|d qZt|jddd t|jddt j	ddddg| t|jddt j	dddg| qZW d S )NrE   rD   r|   r   rX   rH   rC   rG   rY   r   1rc   r   )r`   i g  rT   $   T      rj   ib  iX  )r  rc   rM   )r1   r   r   r   r   r   r   r   r   rf   r	   ArithmeticErrorprodr   r   )rQ   r   r   r  rR   r  r7   r7   r8   rS   i  s    "zTestProd.test_basicN)r\   r]   r^   rS   r7   r7   r7   r8   r  g  s   r  c               @   s   e Zd Zdd ZdS )TestCumprodc             C   sT  dddddddg}ddddgddd	d
gddddgg}xt jt jt jt jt jt jt jt jgD ]}t j	||}t j	||}|d krt
tt j| t
tt j|d t
tt j| q\tt j|d!dt j	dddddddg| tt j|ddt j	ddddgddddgddddgg| tt j|d"dt j	ddddgddddgddddgg| q\W d S )#NrE   rD   r|   r   rX   rH   rC   rG   rY   r   r  rc   )r`   r      i(  i  i g  r   r      r  rT   r  r  rj   r      ib  rk   iX  )r  rc   rM   rM   )r1   r   r   r   r   r   r   r   r   rf   r	   r	  Zcumprodr   )rQ   r   r   r  rR   r  r7   r7   r8   rS   }  s*    "

zTestCumprod.test_basicN)r\   r]   r^   rS   r7   r7   r7   r8   r  {  s   r  c               @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )TestDiffc             C   s   dddddg}t jddddg}t jdddg}t jd	dg}tt|| tt|dd
| tt|dd
| dddddg}t jddddg}tt|| ddddg}t jdddg}t jddg}tt|| tt|dd
| d S )NrE   rC   rX   rY   r   rG   rD   rH   r   )r5   g?g@g      @g?g?g?g	@TFrM   rM   gɿgg	)r1   rf   r   r   r   )rQ   r   outout2out3r7   r7   r8   rS     s    zTestDiff.test_basicc             C   s   t jd}d|d d dd dd d f< t jd}d|d d dd dd d f< tt|t jd tt|ddt jd tt|d	dt jd tt|dd| tt|dd| tt jt|dd tt jt|dd t jdt j}tt	t| d S )Nr|   r   r   rE   rD         )r`   r   r   rG   rC   gq?)r|   r   r   )r|   r  r   rM   )r|   r   r  rM   )r|   r   r  )r   r   r   rK   r   )
r1   r:   rO   r   r   r	   ra   rf   r   rN   )rQ   r   expr7   r7   r8   	test_axis  s    

zTestDiff.test_axisc             C   s*  dt ddd }|d d d d dd f |d d d d d d
f  }|d d d d dd f |d d d d d df  }|dd d d d d f |d dd d d d f  }|dd d d d d f |d dd d d d f  }tt|| tt|dd| tt|dd| tt|ddd	| d S )Nr   r|   r   rE   rD   )r5   r   )r`   )r5   r`   rM   rM   rM   rM   )r   r   r   )rQ   r   Zout1r  r  Zout4r7   r7   r8   rx     s    4444zTestDiff.test_ndc                s   t td ttt d	d  fddtddD }ddgdgg g g}tt dd k xhtt||ddD ]R\}\}}tt|t	j
k t|| t|jt	j tt|tdt |  qnW d S )
NrG   rE   )r5   c                s   g | ]}t  |d qS ))r5   )r   )r   r5   )r   r7   r8   r     s    z#TestDiff.test_n.<locals>.<listcomp>rH   r   )startrM   )listrP   r	   rN   r   r   	enumerater   r   r1   r   r   r   r   r   r   max)rQ   r   expectedr5   r  r7   )r   r8   test_n  s     
zTestDiff.test_nc             C   s   t jddt jd}t jddgddt jdgddg}|jt jg ddgd  x<t|ddD ],\}}t||d	}t|| t|j	|j	 q\W d S )
Nz
1066-10-13z
1066-10-16)r   rE   ztimedelta64[D]r   rG   )r  )r5   )
r1   r2   Z
datetime64rf   extendr  r   r   r   r   )rQ   r   r  r5   r  r  r7   r7   r8   
test_times  s    
zTestDiff.test_timesc             C   s   t jddgddgddgddgd	d
ggddgddgddgddgddggd}t|}t|jdgdgdgdgdgg t|jdgdgdgdgdgg tt|t|k t|dd}t|jg g g g g g t|jg g g g g g tt|t|k d S )NrE   rD   rG   rC   rH   rX   rY   rW   r   r|   FT)mask)r5   )r   rf   r   r   r6   r  r   r   )rQ   r   r  r  r7   r7   r8   r     s    $ zTestDiff.test_subclassc             C   sN  t jdd }tt|ddt jd tt|dgdt jd tt jt j|dd| tt|ddgdt jd t jdjdd}t j|ddd}ddgddgg}t|| t j|ddgdggd}t|| t j|ddd}ddgddgg}t|| t j|dddggd}t|| ttt j|t j	dd tt j
t|dd	d
 d S )NrH   rE   r   )prependrX   rC   rD   )r`   r   rG   )r   r`   rM   )rG   rG   )r1   r2   r   r   rO   r   rZ   r	   rN   r:   ra   )rQ   r   resultr  r7   r7   r8   test_prepend  s$    



zTestDiff.test_prependc             C   sB  t jd}t|dd}ddddd
g}t|| t|dgd}t|| t|ddgd}|dg }t|| t jdjdd}t j|ddd}ddgddgg}t|| t j|ddgdggd}t|| t j|ddd}ddgddgg}t|| t j|dddggd}t|| ttt j|t jdd tt jt|ddd	 d S )NrH   r   )appendrE   rC   rD   )r`   r#  rG   )r#  r`   r   rM   rL   rK   rL   )rG   rG   )	r1   r2   r   r   rZ   r	   rN   r:   ra   )rQ   r   r!  r  r7   r7   r8   test_append  s,    








zTestDiff.test_appendN)r\   r]   r^   rS   r  rx   r  r  r   r"  r$  r7   r7   r7   r8   r    s   r  c               @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )
TestDeletec             C   s,   t jd| _t jdjdjddd| _d S )NrH   rD   rE   )r1   r2   rR   r   rZ   nd_a)rQ   r7   r7   r8   setup$  s    zTestDelete.setupc             C   s   t | j|}t | j|dd}d| }tt|| j|f | j|d t|dd d df | jd|df }t|| jdd d df |d d S )NrE   )r`   zDelete failed for obj: %r)err_msgr   )r   rR   r&  r   r*   )rQ   indicesZa_delZnd_a_delmsgxorr7   r7   r8   _check_inverse_of_slicing(  s    $z$TestDelete._check_inverse_of_slicingc             C   sb   dd	dddddg}d
dddg}x>|D ]6}x0|D ](}x"|D ]}t |||}| j| q8W q.W q$W d S )NrX   rD   r   rE   rC   rH   rG   irK   rL   rM   )r   r,  )rQ   ZlimsZstepsr  stopstepsr7   r7   r8   test_slices1  s    


zTestDelete.test_slicesc          '   C   s   | j tjddgddgg tjt t| jdg W d Q R X tjt t| jdg W d Q R X | j dd	ddg | j dddddg tjt t| jd W d Q R X tjt t| jd W d Q R X tjt t| jdgd  W d Q R X d S )
Nr   rE   rD   r   TFrC   irM   )	r,  r1   rf   r   r   r   r   rR   rN   )rQ   r7   r7   r8   
test_fancy:  s    zTestDelete.test_fancyc             C   s   | j d | j d d S )Nr   rC   r   )r,  )rQ   r7   r7   r8   test_singleO  s    
zTestDelete.test_singlec             C   sX   t jd}tjt j t|g dd W d Q R X tjt t|g dd W d Q R X d S )NrE   r   )r`   r   )r1   rf   r   r   ra   r   r   )rQ   rR   r7   r7   r8   r   S  s
    
zTestDelete.test_0dc             C   s   G dd dt j}| jj|}ttt|d| ttt|g | ttt|ddg| ttt|tdd| ttt|tdd| d S )Nc               @   s   e Zd ZdS )z*TestDelete.test_subclass.<locals>.SubClassN)r\   r]   r^   r7   r7   r7   r8   r   [  s   r   r   rE   rD   rK   )r1   r   rR   r   r   r   r   r   )rQ   r   rR   r7   r7   r8   r   Z  s    zTestDelete.test_subclassc             C   sR   t jdjdddd}t|tdd dd}t|jj|jj t|jj|jj d S )	Nr|   rD   rH   r   )r   <   rE   )r`   )	r1   r2   rZ   r   r   r   r   r   r   )rQ   rJ   r   r7   r7   r8   test_array_order_preserved  s    z$TestDelete.test_array_order_preservec             C   sh   t jt" tjdddgtjddg W d Q R X t jt" tjdddgtjg td W d Q R X d S )Nr   rE   rD   g      ?g       @)r   )r   r   r   r1   r   rf   r   )rQ   r7   r7   r8   r   n  s    &zTestDelete.test_index_floatsN)r\   r]   r^   r'  r,  r0  r1  r2  r   r   r4  r   r7   r7   r7   r8   r%  "  s   		

r%  c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zejjdejejejejgdd Zejjdejejejejgdd Zejjdejejejejgdd Zejjdejejejejgdd  Zd!S )"TestGradientc             C   sf   ddgddgg}t j|}t jddgddggt jddgddggg}tt|| tt|| d S )NrE   rG   rC   g       @g      @g        g      ?)r1   rf   r   r   )rQ   vr   dxr7   r7   r8   rS   w  s    
zTestGradient.test_basicc          	   C   s   t jt jd}dddddg}t jdjdd}tt jdd tt jdt jd tt jd| t|d	 t|t jd	 t||| t||d
 t||dd ttdt|t j	|gd
 ddd d S )NrH   g      ?g       @g      @g      "@g      &@   g      @g      ?rD   rE   )r`   z.*scalars or 1drM   )
r1   r   rO   r2   rZ   r   rf   r   rN   stack)rQ   r7  Z	dx_unevenf_2dr7   r7   r8   	test_args  s    
zTestGradient.test_argsc             C   s   t jdjdd}t jt jd}ttt||t jd ttt|dt jd ttt|t jdt jd ttt|| ttt||dd ttt|||| ttt|ddd ttt|||dd ttt|dddd d S )Nr8  rH   rD   rE   r   )r`   )r   rE   )	r1   r2   rZ   r   rO   r	   rN   r   r   )rQ   r:  r   r7   r7   r8   test_badargs  s    zTestGradient.test_badargsc             C   s^   t jdddddddgdd	}t jdddddddgdd	}tt|| t|jt jdk d S )Nz
1910-08-16z
1910-08-11z
1910-08-10z
1910-08-12z
1910-10-12z
1910-12-12z
1912-12-12zdatetime64[D])r   rH   rG   r      =   i  i  ztimedelta64[D]r   rL   )r1   rf   r   r   r   r   )rQ   r   r7  r7   r7   r8   test_datetime64  s    zTestGradient.test_datetime64c             C   s   t jjddgddggddgddggd}t|d }tt|t| t|j|jk	 t jjd}t jj	|d< t j|dd	 t
|jddd
ddg d S )NrE   rG   rC   F)r  r   rH   rD   )
edge_orderT)r1   r   rf   r   r   r   r   Z_maskr2   maskedr   r  )rQ   r   r  x2r7   r7   r8   test_masked  s    zTestGradient.test_maskedc             C   s  t jddd}|d |d  }d|d  d|d   d|  }d|d  d|  d }t jt j||dd	| d }tt j|d
k dk t jjd t jt jjd}d|d  d|d   d|  }d|d  d|  d }t jt j||dd	| d }tt j|d
k dk d S )Nr   rE   r|   rD   rG   rC   rX   rW   )r@  gQ?T)	r1   linspaceabsr   r   rz   randomseedsort)rQ   r   r7  r   Z
analyticalZ	num_errorr7   r7   r8   test_second_order_accurate  s      z'TestGradient.test_second_order_accuratec             C   s  t jddddddg}t j|d|jdd }t jdd	d
dddg}t jd}t jddd
d
d	dgd}t jddd
d
d	dgd}t jdddd	ddgd}t jdddd	ddgd} xd|fd|fgD ]\}}	t|d
d|d}
t|||d|d}t|||d |d}t|
| t|| t|
d |	j t|
d |	 t|d
d|d}
t||d|d}t	|
j
|j
k t||	j t|d
d|d}
t||d|d}t	|
j
|j
k t||	 qW xd|fd|fgD ]\}}	t|||d|d}
t|||d |d}t|
| t|
d |	j t|
d |	 t||d|d}
t|
|	j t||d|d}
t|
|	 qW t|||ddd}
t|||ddd}t|
d |d  t|
d |d  t|
d |j t|
d | t|||d dd}
t|||d!dd}t|
d |d  t|
d |d  t|
d |j t|
d | d S )"Nr   g       @g      @g      @g      @rX   rE   g        g      ?g      ?g      @g      @g      ?g      @g333333?g      ?rD   )r`   r@  )rX   rE   rM   )rX   rE   g      )rX   rE   )rX   rE   g      п)rX   rE   )r   rE   )r   rE   )r   rE   )r   rE   )rE   r   )r   rE   )rE   r   )r1   rf   ZtilerZ   r2   r   r   r   r   r   r<   )rQ   fZx_unevenZx_evenZfdx_even_ord1Zfdx_even_ord2Zfdx_uneven_ord1Zfdx_uneven_ord2r@  Zexp_resres1res2res3r7   r7   r8   test_spacing  sd    







zTestGradient.test_spacingc             C   s@  ddgddgg}t j|}t jddgddggt jddgddggg}tt|dd	|d  tt|dd	|d  tt|dd	|d  tt|dd	|d |d g tt|d d	|d |d g tt|d d	t| tt|d
ddd	|d d |d d g ttt|dd
dd	 tt jt|dd	 tt jt|dd	 d S )NrE   rG   rC   g       @g      @g        g      ?r   )r`   rD   rM   )rE   r   )rE   r   rL   )r1   rf   r   r   r   r	   r   ra   )rQ   r6  r   r7  r7   r7   r8   test_specific_axes  s    
zTestGradient.test_specific_axesc             C   s^   t jdddddddgdd	}t jd
ddddddgdd	}tt|| t|jt jdk d S )NrH   rG   r|   r   r>  iA  i,  ztimedelta64[D])r   rD   rY   r8     w   r  r   rL   i)r1   rf   r   r   r   r   )rQ   r   r7  r7   r7   r8   test_timedelta641  s    zTestGradient.test_timedelta64c             C   sJ   xDt jt jt jgD ]0}t jdddg|d}tt|jt j|j qW d S )NrE   rD   rG   )r   )	r1   Zfloat16r   r   rf   r   r   r   r   )rQ   dtr   r7   r7   r8   test_inexact_dtypes<  s    z TestGradient.test_inexact_dtypesc             C   s   t tjddd t tjddd ttt tjddd ttt tjddd ttt tjddd ttt tjddd ttt tjddd d S )NrD   rE   )r@  rG   r   )r   r1   r2   r	   rN   )rQ   r7   r7   r8   test_valuesB  s    zTestGradient.test_valuesf_dtypec             C   s8   t jdddddg|d}t|}t|dgt|  d S )NrH   rC   rG   rD   rE   )r   rM   )r1   rf   r   r   r   )rQ   rV  rJ  gr7   r7   r8   test_f_decreasing_unsigned_intN  s    z+TestGradient.test_f_decreasing_unsigned_intc             C   sR   t j|j}t jddg}t jd|g|d}t||}t||d d gd  d S )NrE   rG   )r   rD   rM   )r1   iinfor  rf   r   r   )rQ   rV  maxintr   rJ  dfdxr7   r7   r8   test_f_signed_int_big_jumpU  s
    
z'TestGradient.test_f_signed_int_big_jumpx_dtypec             C   sF   t jdddg|d}t jdddg}t||}t|dgt|  d S )NrG   rD   rE   )r   r   rC   rK   )r1   rf   r   r   r   )rQ   r]  r   rJ  r[  r7   r7   r8   test_x_decreasing_unsigned^  s    
z'TestGradient.test_x_decreasing_unsignedc             C   sX   t j|j}t j|j}t jd|g|d}t j|d dg}t||}t|ddg d S )NrE   )r   rD   r   g      ?rM   )r1   rY  minr  rf   r   r   )rQ   r]  ZminintrZ  r   rJ  r[  r7   r7   r8   test_x_signed_int_big_jumpf  s    
z'TestGradient.test_x_signed_int_big_jumpN)r\   r]   r^   rS   r;  r<  r?  rC  rI  rN  rO  rR  rT  rU  r   markparametrizer1   r   r   r   Zuint64rX  r   r   r   Zint64r\  r^  r`  r7   r7   r7   r8   r5  u  s&   @r5  c               @   s   e Zd Zdd Zdd ZdS )	TestAnglec             C   s   dt jdd dt jd d  ddddddg}t|}t jdt jddt jd t jt j d t jd t jt jd g}t|d	d
}t j|d t j }t||d t||d d S )NrE   y              @rD   g       @y              ?g      @g      ?r   T)degr  r   y      ?      @rM   y             y      ?      rM   y            @g      @g      @g      @)r1   sqrtr   arctanpirf   r   )rQ   r   r   ZyozZzor7   r7   r8   rS   s  s      zTestAngle.test_basicc             C   s   t jjddt jdd d	 g}t jj|d< t jjt jd
dt jdg}t jj|d< t|}tt|t| t|j	|j	 t|| d S )NrE   y              @rD   y              ?g      @g      ?r   y      ?      @y      ?      ?g      @)
r1   r   rf   re  rA  rf  r   r   r   r  )rQ   r   r  r   r7   r7   r8   r     s     zTestAngle.test_subclassN)r\   r]   r^   rS   r   r7   r7   r7   r8   rc  q  s   rc  c               @   s(   e Zd ZdZdd Zdd Zdd ZdS )	TestTrimZerosz+
    Only testing for integer splits.

    c             C   s<   t jdddddddg}t|}t|t jddddg d S )Nr   rE   rD   rG   rC   )r1   rf   r-   r   )rQ   rR   resr7   r7   r8   rS     s    zTestTrimZeros.test_basicc          	   C   s@   t jddddddddg}t|}t|t jdddddg d S )Nr   rE   rD   rG   rC   )r1   rf   r-   r   )rQ   rR   rj  r7   r7   r8   test_leading_skip  s    zTestTrimZeros.test_leading_skipc          
   C   sD   t jdddddddddg	}t|}t|t jddddddg d S )Nr   rE   rD   rG   rC   )r1   rf   r-   r   )rQ   rR   rj  r7   r7   r8   test_trailing_skip  s    z TestTrimZeros.test_trailing_skipN)r\   r]   r^   __doc__rS   rk  rl  r7   r7   r7   r8   ri    s   ri  c               @   s$   e Zd Zdd Zdd Zdd ZdS )
TestExtinsc             C   s>   t jdddddddg}t|dk|}t|dddddg d S )NrE   rG   rD   )r1   rf   r   r   )rQ   rR   rc   r7   r7   r8   rS     s    zTestExtins.test_basicc          	      s  t ttdddgddgddg tjdddddd	d
g t dddddddgdddg t ddddddd
g t tjd
g  t tjdd	 t dddddddgd	dg t d	dddd	ddg tt	d fdd tjddg t ddgd t ddg d S )NrE   rD   rG   TFr   rC   rH   rW   rY   rX   r   z!Cannot insert from an empty arrayc            	      s   t  dddddddgg S )Nr   rE   )r'   r7   )rR   r7   r8   <lambda>  s    z'TestExtins.test_place.<locals>.<lambda>Z12Z349)
r	   r   r'   r1   rf   r   r:   r2   r   rN   )rQ   r7   )rR   r8   
test_place  s     zTestExtins.test_placec             C   sH   t d}|dk}|j }t||}t||d t||| t|| d S )Nr|   g      ?r   )r   r}   r   r'   r   )rQ   rR   r  acrq   r7   r7   r8   	test_both  s    
zTestExtins.test_bothN)r\   r]   r^   rS   rq  rs  r7   r7   r7   r8   rn    s   rn        ?c             C   s   |t j|  S )N)mathfloor)r   r   r7   r7   r8   _foo1  s    rw          c             C   s   |t j|  | S )N)ru  rv  )r   r   rh  r7   r7   r8   _foo2  s    ry  c               @   s  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dES )FTestVectorizec             C   s@   dd }t |}|ddddgdddd	g}t|dddd
g d S )Nc             S   s   | |kr| | S | | S d S )Nr7   )rR   rc   r7   r7   r8   addsubtract  s    z.TestVectorize.test_simple.<locals>.addsubtractr   rG   rX   r   rE   rH   rY   rD   )r0   r   )rQ   r{  rJ  r   r7   r7   r8   test_simple  s    zTestVectorize.test_simplec             C   s8   dd }t |}|ddddgd}t|ddd	d
g d S )Nc             S   s   | |kr| | S | | S d S )Nr7   )rR   rc   r7   r7   r8   r{    s    z.TestVectorize.test_scalar.<locals>.addsubtractr   rG   rX   r   rH   rW   rE   rC   )r0   r   )rQ   r{  rJ  r   r7   r7   r8   test_scalar  s    zTestVectorize.test_scalarc             C   s0   t jddd}tdd }||}t|| d S )NrG   rD   i'  c             S   s   | S )Nr7   )r   r7   r7   r8   ro    s    z*TestVectorize.test_large.<locals>.<lambda>rL   )r1   rD  r0   r   )rQ   r   rJ  r   r7   r7   r8   
test_large  s    zTestVectorize.test_largec             C   sR   t tj}tjddtj tjdtj dtj g}||}tj|}t|| d S )Nr   g      ?g      ?rD   )r0   ru  cosr1   rf   rg  r   )rQ   rJ  argsr1r2r7   r7   r8   
test_ufunc  s
    
(
zTestVectorize.test_ufuncc             C   sl   ddd}t |}tjdddg}||}tjdddg}t|| ||d}tjdddg}t|| d S )	NrE   c             S   s   | | S )Nr7   )rR   rc   r7   r7   r8   r     s    z(TestVectorize.test_keywords.<locals>.foorD   rG   rC   rH   )rE   )r0   r1   rf   r   )rQ   r   rJ  r  r  r  r7   r7   r8   test_keywords  s    


zTestVectorize.test_keywordsc             C   s:   t ttgd}|tjdd}|tjd}t|| d S )N)otypesg      @g      ?)r0   rw  r   r1   r2   r   )rQ   rJ  r  r  r7   r7   r8    test_keywords_with_otypes_order1  s    z.TestVectorize.test_keywords_with_otypes_order1c             C   s:   t ttgd}|tjd}|tjdd}t|| d S )N)r  g      @g      ?)r0   rw  r   r1   r2   r   )rQ   rJ  r  r  r7   r7   r8    test_keywords_with_otypes_order2  s    z.TestVectorize.test_keywords_with_otypes_order2c             C   sT   t ttgd}|tjd}|tjddd}|tjd}t|| t|| d S )N)r  g      @g      ?)r   )r0   rw  r   r1   r2   r   )rQ   rJ  r  r  r3r7   r7   r8    test_keywords_with_otypes_order3  s    
z.TestVectorize.test_keywords_with_otypes_order3c             C   sd   t ttgd}|ddd}|ddd}|d}t|tddd t|tddd t|td d S )	N)r  g$@r   )rh  rE   )r   rM   rM   )r0   ry  r   r   )rQ   rJ  r  r  r  r7   r7   r8   +test_keywords_with_otypes_several_kwd_args1'  s    z9TestVectorize.test_keywords_with_otypes_several_kwd_args1c             C   sR   t ttgd}|dddd}|ddd}t|tddd	d t|tddd d S )
N)r  r   g$@rE   )rh  r   r   rD   rG   rM   rM   )r0   ry  r   r   )rQ   rJ  r  r  r7   r7   r8   +test_keywords_with_otypes_several_kwd_args24  s
    z9TestVectorize.test_keywords_with_otypes_several_kwd_args2c             C   s6   dd l }yt|j W n tk
r0   t Y nX d S )Nr   )rF  r0   	randrange	ExceptionAssertionError)rQ   rF  r7   r7   r8   test_keywords_no_func_code?  s
    z(TestVectorize.test_keywords_no_func_codec             C   s   ddd}t |}tjdddg}||d}tjdddg}t|| |d|d}t|| ||dd	}tjddd
g}t|| d S )NrE   c             S   s   | | S )Nr7   )rR   rc   r7   r7   r8   r   L  s    z5TestVectorize.test_keywords2_ticket_2100.<locals>.foorD   rG   )rR   rC   )rc   rR   )rc   rH   )rE   )r0   r1   rf   r   )rQ   r   rJ  r  r  r  r7   r7   r8   test_keywords2_ticket_2100I  s    



z(TestVectorize.test_keywords2_ticket_2100c             C   sx   dd }t j|ddgd}ddg}t||ddgdd	dgd
 t||ddgdd	dgd t||ddgdd	dg d S )Nc             S   s2   t |}|jd}x|r,||  |jd }qW |S )Nr   )r  pop)r   p_prj  r7   r7   r8   	mypolyval\  s
    
z;TestVectorize.test_keywords3_ticket_2100.<locals>.mypolyvalr  rE   )excludedrG   rX   r   rD   )r   r  )r  )r1   r0   r   )rQ   r  ZvpolyvalZansr7   r7   r8   test_keywords3_ticket_2100Z  s    z(TestVectorize.test_keywords3_ticket_2100c             C   s.   t dd }t|ddgddgdddg d S )	Nc              [   s"   d}x| D ]}|| | 9 }q
W |S )Ng      ?r7   )kwrj  Z_kr7   r7   r8   rJ  k  s    
z3TestVectorize.test_keywords4_ticket_2100.<locals>.frE   rD   rG   rC   )rR   rc   rW   )r0   r   )rQ   rJ  r7   r7   r8   test_keywords4_ticket_2100i  s    z(TestVectorize.test_keywords4_ticket_2100c             C   s,   t dd }t|ddgddgddg d S )Nc              W   s
   t j| S )N)r1   r
  )r6  r7   r7   r8   rJ  v  s    z3TestVectorize.test_keywords5_ticket_2100.<locals>.frE   rD   rG   rC   rW   )r0   r   )rQ   rJ  r7   r7   r8   test_keywords5_ticket_2100t  s    z(TestVectorize.test_keywords5_ticket_2100c             C   s    dd }t |}t| d d S )Nc               S   s   dS )NrE   r7   r7   r7   r7   r8   r   }  s    z5TestVectorize.test_coverage1_ticket_2100.<locals>.foorE   )r0   r   )rQ   r   rJ  r7   r7   r8   test_coverage1_ticket_2100|  s    z(TestVectorize.test_coverage1_ticket_2100c             C   s>   dd }t |}t|j|j d}t ||d}t|j| d S )Nc             S   s   | S )zOriginal documentationr7   )r   r7   r7   r8   r     s    z3TestVectorize.test_assigning_docstring.<locals>.foozProvided documentation)doc)r0   r   rm  )rQ   r   rJ  r  r7   r7   r8   test_assigning_docstring  s    z&TestVectorize.test_assigning_docstringc             C   s`   G dd d}t t| jtjdtjdd  t t|j| tjdtjdd  d S )Nc               @   s   e Zd ZdZdd ZdS )z9TestVectorize.test_UnboundMethod_ticket_1156.<locals>.FoorD   c             S   s
   || j  S )N)rc   )rQ   rR   r7   r7   r8   r     s    z=TestVectorize.test_UnboundMethod_ticket_1156.<locals>.Foo.barN)r\   r]   r^   rc   r   r7   r7   r7   r8   Foo  s   r  r   rD   )r   r0   r   r1   r2   )rQ   r  r7   r7   r8   test_UnboundMethod_ticket_1156  s
    z,TestVectorize.test_UnboundMethod_ticket_1156c             C   sl   t dd }|tjd}|tjdd}t dd }|tjdd}|tjd}t|| t|| d S )Nc             S   s   | S )Nr7   )r   r7   r7   r8   ro    s    z@TestVectorize.test_execution_order_ticket_1487.<locals>.<lambda>rG   g?c             S   s   | S )Nr7   )r   r7   r7   r8   ro    s    )r0   r1   r2   r   )rQ   f1Zres1aZres1bf2Zres2bZres2ar7   r7   r8    test_execution_order_ticket_1487  s    
z.TestVectorize.test_execution_order_ticket_1487c             C   s(   t jdd }dd }t||| d S )Nc             S   s   | S )Nr7   )r   r7   r7   r8   ro    s    z7TestVectorize.test_string_ticket_1892.<locals>.<lambda>
0123456789r|   )r1   r0   r   )rQ   rJ  r/  r7   r7   r8   test_string_ticket_1892  s    z%TestVectorize.test_string_ticket_1892c                sN   dg t  fdd}d|_tjd}t||||  t d t| d S )Nr   c                s    d  d7  < | d S )Nr   rE   rD   r7   )r   )_callsr7   r8   rJ    s    z#TestVectorize.test_cache.<locals>.fTrH   )r0   cacher1   r2   r   r   r   )rQ   rJ  r   r7   )r  r8   
test_cache  s    
zTestVectorize.test_cachec             C   s0   t jdd }d|_t jd}t||| d S )Nc             S   s   | S )Nr7   )r   r7   r7   r8   ro    s    z+TestVectorize.test_otypes.<locals>.<lambda>rn   rH   )r1   r0   r  r2   r   )rQ   rJ  r   r7   r7   r8   test_otypes  s    
zTestVectorize.test_otypesc             C   s   t tjddgf gf t tjddgf gf t tjdddgf gf t tjddgdgf t tjddgdf gf t tjdf ddgdgf tt tjd W d Q R X tt tjd W d Q R X tt tjd W d Q R X d S )Nz(x)->()r   z	(x,y)->()r   z(x),(y)->()z(x)->(y)z(x)->(y),()z(),(a,b,c),(d)->(d,e)rR   rc   rq   r   ez
(x)(y)->()z	(x),(y)->z
((x))->(x))r   )r   r   )r   )r   )r   )r   )r   )r   )rR   rc   rq   )r   )r   r  )r   nfbZ_parse_gufunc_signaturer	   rN   )rQ   r7   r7   r8   test_parse_gufunc_signature  s"    







z)TestVectorize.test_parse_gufunc_signaturec             C   sD   dd }t |dd}|ddddgd	dd
dg}t|d	dd	dg d S )Nc             S   s   | |kr| | S | | S d S )Nr7   )rR   rc   r7   r7   r8   r{    s    z8TestVectorize.test_signature_simple.<locals>.addsubtractz	(),()->())	signaturer   rG   rX   r   rE   rH   rY   rD   )r0   r   )rQ   r{  rJ  r   r7   r7   r8   test_signature_simple  s    z#TestVectorize.test_signature_simplec             C   s:   dd }t |dd}|ddgddgg}t|ddg d S )	Nc             S   s   | j  S )N)r   )rR   r7   r7   r8   r     s    z4TestVectorize.test_signature_mean_last.<locals>.meanz(n)->())r  rE   rG   rD   rC   )r0   r   )rQ   r   rJ  r   r7   r7   r8   test_signature_mean_last  s    z&TestVectorize.test_signature_mean_lastc             C   sB   dd }t |dd}|ddgddgg}t|d	dgd
dgg d S )Nc             S   s   | | j   S )N)r   )rR   r7   r7   r8   center  s    z3TestVectorize.test_signature_center.<locals>.centerz(n)->(n))r  rE   rG   rD   rC   rM   rM   )r0   r   )rQ   r  rJ  r   r7   r7   r8   test_signature_center  s    z#TestVectorize.test_signature_centerc             C   sd   t dd dd}|dddg}tt|to4t|dk t|d dddg t|d dddg d S )	Nc             S   s   | | fS )Nr7   )r   r7   r7   r8   ro    s    z:TestVectorize.test_signature_two_outputs.<locals>.<lambda>z	()->(),())r  rE   rD   rG   r   )r0   r   r   tupler   r   )rQ   rJ  r   r7   r7   r8   test_signature_two_outputs  s
    z(TestVectorize.test_signature_two_outputsc             C   s  t tjdd}|ddgdddg}t|dddgdddgg |ddgggdddg}t|dddgdddgggg |ddgddggdddg}t|dddgdddggdddgdddggg |ddgdddgdddgg}t|dddgdddggdddgdddggg d S )	Nz(a),(b)->(a,b))r  rE   rD   rG   rC   rX   r   )r0   r1   r4   r   )rQ   rJ  r   r7   r7   r8   test_signature_outer  s    z"TestVectorize.test_signature_outerc             C   s^   t dd dd}|dddg}t|ddg |dddgdddgg}t|ddgddgg d S )	Nc             S   s   | d d S )NrE   rM   r7   )r   r7   r7   r8   ro    s    z<TestVectorize.test_signature_computed_size.<locals>.<lambda>z(n)->(m))r  rE   rD   rG   rC   )r0   r   )rQ   rJ  r   r7   r7   r8   test_signature_computed_size  s
    z*TestVectorize.test_signature_computed_sizec             C   sV   ddd}t |ddhd}t|dddgddd	g t|dddgd
ddddg d S )NrE   c             S   s   | | S )Nr7   )rR   rc   r7   r7   r8   r     s    z2TestVectorize.test_signature_excluded.<locals>.fooz()->()rc   )r  r  rD   rG   rC   r   )rc   )rE   )r0   r   )rQ   r   rJ  r7   r7   r8   test_signature_excluded  s    
z%TestVectorize.test_signature_excludedc             C   sH   t dd ddgd}|dddg}t|jtjd t|dddg d S )	Nc             S   s   | S )Nr7   )r   r7   r7   r8   ro    s    z5TestVectorize.test_signature_otypes.<locals>.<lambda>z(n)->(n)r   )r  r  rE   rD   rG   )r0   r   r   r1   r   )rQ   rJ  r   r7   r7   r8   test_signature_otypes  s    z#TestVectorize.test_signature_otypesc             C   s   t tjdd}ttd |ddg W d Q R X ttd |dd W d Q R X ttd |ddgdddg W d Q R X t tjd	d}ttd |dd W d Q R X d S )
Nz(n),(n)->(n))r  zwrong number of positionalrE   rD   zdoes not have enough dimensionsz$inconsistent size for core dimensionrG   z()->())r0   operatorr3   r   r   rN   )rQ   rJ  r7   r7   r8   test_signature_invalid_inputs  s    

z+TestVectorize.test_signature_invalid_inputsc             C   s   t dd dd}ttd |dddg W d Q R X t d	d d
d}ttd |d W d Q R X t dd dd}ttd |ddg W d Q R X d S )Nc             S   s   | d d S )NrE   rM   r7   )r   r7   r7   r8   ro  .  s    z>TestVectorize.test_signature_invalid_outputs.<locals>.<lambda>z(n)->(n))r  z$inconsistent size for core dimensionrE   rD   rG   c             S   s   | S )Nr7   )r   r7   r7   r8   ro  3  s    z	()->(),()zwrong number of outputsc             S   s   | | fS )Nr7   )r   r7   r7   r8   ro  7  s    z()->())r0   r   rN   )rQ   rJ  r7   r7   r8   test_signature_invalid_outputs,  s    
z,TestVectorize.test_signature_invalid_outputsc             C   s   t jdd }t jddgtd}ttd || W d Q R X d|_t||| t jdd d	d
}ttd || W d Q R X t jdd d	dd}t||| t jdd ddd}t||| t jdd dd
}t||j|j t jdd ddd}ttd || W d Q R X d S )Nc             S   s   | S )Nr7   )r   r7   r7   r8   ro  =  s    z5TestVectorize.test_size_zero_output.<locals>.<lambda>r   rH   )r   r  rn   c             S   s   | S )Nr7   )r   r7   r7   r8   ro  E  s    z()->())r  c             S   s   | S )Nr7   )r   r7   r7   r8   ro  I  s    )r  r  c             S   s   | S )Nr7   )r   r7   r7   r8   ro  L  s    z(n)->(n)c             S   s   | S )Nr7   )r   r7   r7   r8   ro  O  s    c             S   s   | gS )Nr7   )r   r7   r7   r8   ro  R  s    z()->(n)znew output dimensions)	r1   r0   r:   intr   rN   r  r   r   )rQ   rJ  r   r7   r7   r8   test_size_zero_output;  s$    z#TestVectorize.test_size_zero_outputN)%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  r  r  r  r  r  r  r  r  r  r  r  r  r7   r7   r7   r8   rz    sD   

	rz  c               @   sL   e Zd ZG dd dZejje ddejjddej	fdgd	d
 Z
dS )	TestLeaksc               @   s$   e Zd ZdZdd Zedd ZdS )zTestLeaks.Ar   c             G   s   dS )Nr   r7   )rQ   r  r7   r7   r8   bound[  s    zTestLeaks.A.boundc              G   s   dS )Nr   r7   )r  r7   r7   r8   unbound^  s    zTestLeaks.A.unboundN)r\   r]   r^   itersr  staticmethodr  r7   r7   r7   r8   AX  s   r  zPython lacks refcounts)reasonz
name, incrr  r  r   c       	      C   s   dd l }t| j|}|j  ztj|}xBt| jjD ]2}| j }tj	t||dd|_
|j
tjd}q6W d }ttj|||  xtdD ]}|j  qW ttj|| W d |j  X d S )Nr   rE   r|   rH   )gcgetattrr  disablesysgetrefcountrP   r  r1   Z
frompyfuncrJ  r2   r   Zcollectenable)	rQ   nameincrr  ZA_funcrefcountrn   rR   r  r7   r7   r8   test_frompyfunc_leaksb  s    
zTestLeaks.test_frompyfunc_leaksN)r  r   )r\   r]   r^   r  r   ra  skipifr   rb  r  r  r7   r7   r7   r8   r  W  s
   
r  c               @   sz   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zejjdddd ZdS )TestDigitizec             C   s2   t jdd}t jdd}tt||t jd d S )NrX   rH   r   ir   )r1   r2   r   r   )rQ   r   binsr7   r7   r8   test_forward  s    zTestDigitize.test_forwardc             C   s6   t jddd}t jddd}tt||t jd d S )	NrH   rX   rE   r   irM   r   rM   )r1   r2   r   r   )rQ   r   r  r7   r7   r8   test_reverse  s    zTestDigitize.test_reversec             C   s:   t d}tj|j |j d}ttjt||dk d S )Nr|   r   )r   r1   rD  r_  r  r   rz   r   )rQ   r   binr7   r7   r8   test_random  s    zTestDigitize.test_randomc             C   sf   dddddddg}dddg}dddd	dd	dg}t t||| dddddd	dg}t t||d
| d S )NrE   rH   rC   r|   rW   r   r   rD   rG   T)r   r   )rQ   r   r  Zdefault_answerZright_answerr7   r7   r8   test_right_basic  s    
zTestDigitize.test_right_basicc             C   s4   t jdd}t jdd}tt||dt jd d S )NrX   rH   rC   Tr   ii)r1   r2   r   r   )rQ   r   r  r7   r7   r8   test_right_open  s    zTestDigitize.test_right_openc             C   s8   t jddd}t jdd	d
}tt||dt jd d S )NrH   rX   rE   rC   Tr   irM   irM   )r1   r2   r   r   )rQ   r   r  r7   r7   r8   test_right_open_reverse  s    z$TestDigitize.test_right_open_reversec             C   s<   t d}tj|j |j d}ttjt||ddk d S )Nr|   T)r   r1   rD  r_  r  r   rz   r   )rQ   r   r  r7   r7   r8   test_right_open_random  s    z#TestDigitize.test_right_open_randomc             C   s   ddddg}dddg}t t||dddddg t t||dddddg dddg}t t||dddddg t t||dddddg ddddg}t t||dddddg t t||dddddg ddddg}ttt|| ddddg}ttt|| d S )	NrE   r   rD   FrG   TrC   rM   )r   r   r	   rN   )rQ   r   r  r7   r7   r8   test_monotonic  s    

zTestDigitize.test_monotonicc             C   s>   dddg}dddg}t tt|| || }}t tt|| d S )NrE   rD   rG   y              ?y      @      ?)r	   r   r   )rQ   r   r  r7   r7   r8   test_casting_error  s
    


zTestDigitize.test_casting_errorc             C   sh   G dd dt j}t jdj|}t jddj|}ttt||d|  ttt||d|  d S )Nc               @   s   e Zd ZdS )z(TestDigitize.test_return_type.<locals>.AN)r\   r]   r^   r7   r7   r7   r8   r    s   r  rH   rE   rG   FT)r1   r   r2   r   r   r   r   )rQ   r  rR   rc   r7   r7   r8   test_return_type  s
    zTestDigitize.test_return_typec             C   s&   d}t tj||d |d gd d S )NrD   6   rE   l          )r   r1   r   )rQ   r   r7   r7   r8   test_large_integers_increasing  s    z+TestDigitize.test_large_integers_increasingz8gh-11022: np.core.multiarray._monoticity loses precision)r  c             C   s&   d}t tj||d |d gd d S )NrD   r  rE   l          )r   r1   r   )rQ   r   r7   r7   r8   test_large_integers_decreasing  s    z+TestDigitize.test_large_integers_decreasingN)r\   r]   r^   r  r  r  r  r  r  r  r  r  r  r  r   ra  xfailr  r7   r7   r7   r8   r    s   	r  c               @   s   e Zd Zdd ZdS )
TestUnwrapc             C   sH   t tdddtj  gddg ttjtttdd tjk  d S )NrE   rD   r|   r   )r   r.   r1   rg  r   rz   r   r   )rQ   r7   r7   r8   r|    s     zTestUnwrap.test_simpleN)r\   r]   r^   r|  r7   r7   r7   r8   r    s   r  c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestFilterwindowsc             C   s2   t d}t|t|d ttj|dddd d S )Nr|   rY   r   )r`   g      @rC   )r   r   r   r   r1   r   )rQ   r   r7   r7   r8   test_hanning  s    zTestFilterwindows.test_hanningc             C   s2   t d}t|t|d ttj|dddd d S )Nr|   rY   r   )r`   g(\@rC   )r   r   r   r   r1   r   )rQ   r   r7   r7   r8   test_hamming  s    zTestFilterwindows.test_hammingc             C   s2   t d}t|t|d ttj|dddd d S )Nr|   rY   r   )r`   g^)@rC   )r   r   r   r   r1   r   )rQ   r   r7   r7   r8   test_bartlett  s    zTestFilterwindows.test_bartlettc             C   s2   t d}t|t|d ttj|dddd d S )Nr|   rY   r   )r`   g=
ףp=@rC   )r   r   r   r   r1   r   )rQ   r   r7   r7   r8   test_blackman  s    zTestFilterwindows.test_blackmanN)r\   r]   r^   r  r  r  r  r7   r7   r7   r8   r    s   r  c               @   s$   e Zd Zdd Zdd Zdd ZdS )	TestTrapzc             C   sH   t jddd}tt jd	|d  t jdt j  dd}t|dd d S )
Nr|   g?g      ?rD   )r7  rE   rY   ig      )r1   r2   r,   r  re  rg  r   )rQ   r   r   r7   r7   r8   r|    s    *zTestTrapz.test_simplec             C   s&  t jddd}t jddd}t jddd}t j||d |d   }|d  d  < |d	  d  < t j||d |d   }|d  d  < |d
  d  < t j||d |d   }|d  d  < |d  d  < |d d d d f |d d d d f  |d d d d f  }||d d d d f  jdd}||d d d d f  jdd}	||d d d d f  jdd}
t||d d d d f dd}t|| t||d d d d f dd}t||	 t||d d d d f dd}t||
 t||dd}t|| t||dd}t||	 t||dd}t||
 d S )Nr   rE   rG   rD   rW   rI   )r`   )r   r`   rM   rM   rM   )r1   rD  Z	ones_liker   r,   r   )rQ   r   r   rh  ZwxZwyZwzqZqxZqyZqzr   r7   r7   r8   	test_ndim  s8    6




zTestTrapz.test_ndimc             C   s   t jd}|| }|dk}t jj||d}d}tt||| t jj||d}tt||| t jj||d}tt||| d S )NrH   rD   )r  g      *@)r1   r2   r   rf   r   r,   )rQ   r   r   r  Zymr   Zxmr7   r7   r8   rC  )  s    
zTestTrapz.test_maskedN)r\   r]   r^   r|  r  rC  r7   r7   r7   r8   r    s   %r  c               @   s   e Zd Zdd Zdd ZdS )TestSincc             C   s6   t tddk ttjddd}t|t|d d S )Nr   rE   r   rY   rM   )r   r+   r1   rD  r   r   )rQ   r   r7   r7   r8   r|  <  s    zTestSinc.test_simplec             C   sF   ddg}t tj|}t t|}t t|}t|| t|| d S )Nr   g      ?)r+   r1   rf   r  r  r   )rQ   r   ru   rv   rw   r7   r7   r8   test_array_likeB  s    
zTestSinc.test_array_likeN)r\   r]   r^   r|  r  r7   r7   r7   r8   r  :  s   r  c               @   s   e Zd Zdd ZdS )
TestUniquec          
   C   s   t jdddddddddg	}tt jt|dddddgk ttt jdddddgt jdgk dddd	ddg}tt jt|d	dddgk t jdddddg}tt jt|ddddgk d S )NrC   rG   rD   rE   r   ZwidgetZhamr   r   rH   y              @y              ?y              $@r|   y      @      @y      ?      ?y      ?      $@y      @      @y      ?      ?y      ?      $@y      @      @)r1   rf   r   rz   r/   )rQ   r   r7   r7   r8   r|  M  s     (zTestUnique.test_simpleN)r\   r]   r^   r|  r7   r7   r7   r8   r  K  s   r  c               @   s   e Zd Zdd Zdd ZdS )TestCheckFinitec             C   sR   dddg}ddt jg}ddt jg}t jj| ttt jj| ttt jj| d S )NrE   rD   rG   )r1   infr   libasarray_chkfiniter	   rN   )rQ   rR   rc   rq   r7   r7   r8   r|  Y  s    
zTestCheckFinite.test_simplec             C   s2   dddg}t jj|dt jd}t|jt jk d S )NrE   rD   rG   r   )r   r   )r1   r  r  r   r   r   )rQ   rR   r7   r7   r8   test_dtype_ordera  s    
z TestCheckFinite.test_dtype_orderN)r\   r]   r^   r|  r  r7   r7   r7   r8   r  W  s   r  c               @   s  e Zd Zejdddgdddgddd	ggZejd
ddgdddgdddggZejddd4gdddgd5ddggZejddd6dddgdddd7ddgd8ddd9ddgdd:d;dd<d=gdddd>dd"gdddd?d"dggZd#d$ Z	d%d& Z
d'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3S )@TestCorrCoefg^?g.{<?g$,?g4?gp)?gJG?gY?g?gވ0v?gة?gBFU?g G)t?g3TB?gL\?gA?g>
?gqFE`?g5?g      ?gޛ?gr@?gp]4?g?'L?g(8?g4V}?gw{?g,H5?gjS,?g?g)h?g5#A?gto?gBC,?g@02v?c             C   s.   t tjdddgdddgddgddgg d S )Nr   rE   g      ?g      g      )r   r1   r   )rQ   r7   r7   r8   test_non_array}  s    zTestCorrCoef.test_non_arrayc             C   sd   t | j}t|| j ttjtj|dk t | j| j}t|| j	 ttjtj|dk d S )Ng      ?)
r   r  r   rK  r   r1   rz   rE  BrL  )rQ   Ztgt1Ztgt2r7   r7   r8   r|    s    
zTestCorrCoef.test_simplec             C   s   t  }tjd ttt| jdd |jt tt| jdd| j	 tt| j| j
dd| j tt| jdd| j	 tt| j| j
dd| j W d Q R X d S )Nr   rE   )ddofrG   rM   rM   rM   )r   r   simplefilterr   DeprecationWarningr   r  filterr   rK  r  rL  )rQ   supr7   r7   r8   	test_ddof  s    

zTestCorrCoef.test_ddofc             C   sh   t  X}tjd ttt| j| jdd ttt| jdd |jt t	t| jdd| j
 W d Q R X d S )Nr   rE   r   )Zbias)r   r   r  r   r  r   r  r  r  r   rK  )rQ   r  r7   r7   r8   	test_bias  s    

zTestCorrCoef.test_biasc             C   s^   t jdddgdddgg}t|}t jddgddgg}t|| tt jt j|dk d S )	NrE   rD   rG   y              ?y               @y              @g      ?y             )r1   rf   r   r
   r   rz   rE  )rQ   r   rj  r  r7   r7   r8   test_complex  s
    
zTestCorrCoef.test_complexc             C   sL   t jdddgg}t jdddgg}tt j||t jddgddgg d S )	NrE   rD   rG   y              ?y               @y              @g      ?y             )r1   rf   r
   r   )rQ   r   r   r7   r7   r8   test_xy  s    zTestCorrCoef.test_xyc             C   s   t jdd t jdt tttjg tj tttjg j	ddtjg j	dd tttjg j	ddtjtjtjgtjtjgg W d Q R X d S )NT)r   r   r   rD   )
r   r   r  RuntimeWarningr   r   r1   rf   r   rZ   )rQ   r7   r7   r8   
test_empty  s    zTestCorrCoef.test_emptyc             C   sh   ddgddgg}t jdd t|}W d Q R X t|t jddgddgg tt jt j|dk d S )Ng0.++g}Ô%ITraise)rz   g      ?g      g      )r1   Zerrstater   r   rf   r   rz   rE  )rQ   r   rq   r7   r7   r8   test_extreme  s
    zTestCorrCoef.test_extremeNgr@gr@gr@gw{gr@ggw{ggtogBC,gtogBC,)r\   r]   r^   r1   rf   r  r  rK  rL  r  r|  r  r  r  r  r  r  r7   r7   r7   r8   r  h  s6   	
	r  c               @   sB  e Zd ZejddgddgddggjZejdd(gd)dggZejdddgddZejdddgZ	ejdgdgdgdgdgdggjZ
ejd	d*gd+d	ggZejd
ejdZejdddgZejd,d.gd0d1ggZejd
ZejdddddgZdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'S )2TestCovr   rD   rE   g      ?g        g       @)ndminrC   g?rG   )r   g      @g      @g&S:?go_?g#~j?gZӼ?gQ|?c             C   s   t t| j| j d S )N)r
   r   x1rK  )rQ   r7   r7   r8   rS     s    zTestCov.test_basicc             C   sZ   t jdddgdddgg}t jdd	gddgg}tt|| tt|t jdd| d S )
NrE   rD   rG   y              ?y               @y              @g      ?)aweightsy             )r1   rf   r
   r   rO   )rQ   r   rj  r7   r7   r8   r    s    zTestCov.test_complexc             C   sJ   t jdddgg}t jdddgg}tt||t jddgddgg d S )	NrE   rD   rG   y              ?y               @y              @g      ?y             )r1   rf   r
   r   )rQ   r   r   r7   r7   r8   r    s    zTestCov.test_xyc             C   s   t jdd t jdt tttjg tj tttjg j	ddtjg j	dd tttjg j	ddtjtjtjgtjtjgg W d Q R X d S )NT)r   r   r   rD   )
r   r   r  r  r   r   r1   rf   r   rZ   )rQ   r7   r7   r8   r    s    zTestCov.test_emptyc             C   sZ   t jddD t jdt tt| jddtjtj	tj	 gtj	 tj	gg W d Q R X d S )NT)r   r   rH   )r  )
r   r   r  r  r   r   r  r1   rf   r  )rQ   r7   r7   r8   test_wrong_ddof  s
    zTestCov.test_wrong_ddofc             C   sP   t t| jt| jdd tjdddddg}t t| j|t| j|dd d S )NF)Zrowvarg+?g4@?g&S?go_?gJ4?)r
   r   x3r1   rf   )rQ   r   r7   r7   r8   test_1D_rowvar  s    zTestCov.test_1D_rowvarc             C   s$   t t| jddtj| jdd d S )NrE   )r  )r
   r   r  r1   var)rQ   r7   r7   r8   test_1D_variance  s    zTestCov.test_1D_variancec             C   s   t t| j| jdt| j t t| j| jd| j t t| j| jd| j | jd }t	t
t| j|d tjdtjd}t	tt| j|d tjdtjd}t	tt| j|d dtjdtjd }t	tt| j|d d S )	N)fweightsg      ?rD   rG   )r   rE   )rD   rG   rM   )r
   r   rB  frequencies
x2_repeatsr  rL  unit_frequenciesrK  r	   r   r1   rO   r   RuntimeErrorrN   )rQ   ZnonintrJ  r7   r7   r8   test_fweights  s    
zTestCov.test_fweightsc             C   s   t t| j| jd| j t t| jd| j dt| j| jd t t| j| jd| j tjd}t	t
t| j|d tjd}t	t
t| j|d dtjd }t	tt| j|d d S )N)r  g      @rD   rG   g      ?)rD   rG   g      )r
   r   r  r   rM  unit_weightsrK  r1   rO   r	   r  rN   )rQ   r   r7   r7   r8   test_aweights   s    

zTestCov.test_aweightsc             C   s   t t| j| j| jdt| j t t| j| j| jd| j t t| j| j| jd| j	 t t| j| j| j
d| j t t| j| jd| j
 dt| j| j
d t t| j| j| jd| j	 d S )N)r  r  g      @)r  )r
   r   rB  r	  r  r
  r  rL  r  rK  r   rM  )rQ   r7   r7   r8   test_unit_fweights_and_aweights  s$    z'TestCov.test_unit_fweights_and_aweightsNg      g      gٿgٿgUUUUUU?g       gUUUUUUg       gUUUUUUgUUUUUU?)r\   r]   r^   r1   rf   r   r  rK  rB  r	  r
  rL  rO   r   r  r   rM  r  r  rS   r  r  r  r  r  r  r  r  r  r7   r7   r7   r8   r    s*   $
	r  c               @   s   e Zd Zdd Zdd ZdS )Test_I0c          	   C   s   t tdtjd tjddddg}tjddd	d
g}t t|| t t| | tjddgddgddgddgddgg}t t|tjddgddgddgddgddgg tjdg}t|jd" ttjdgtjd!g d S )#Ng      ?gǒ#?gC7?gmM?g3a,?g$WV?ۏ?gֿN^?gE ?g閡1?g%m? ?g>@v?guͥ?gVX˳?gua&?gB-sJ?g-^?g_V?gX.?gVaX?gj?gp?g~-@?gD/b?gݦ?g,Y1ؔ?g[!?gQL?gWsU+?g@?gfxw?g        rE   g      ?)rE   )r   r    r1   rf   r   r<   r   )rQ   r  r  r  Zi0_0r7   r7   r8   r|  #  s,    

zTest_I0.test_simplec                sV   t jd G  fddd}tt j| |s2tt j }t j| }t|| d S )NrC   c                   s   e Zd Z jZdd ZdS )z*Test_I0.test_non_array.<locals>.array_likec             S   s   | S )Nr7   )rQ   Zarrr7   r7   r8   __array_wrap__D  s    z9Test_I0.test_non_array.<locals>.array_like.__array_wrap__N)r\   r]   r^   Z__array_interface__r  r7   )rR   r7   r8   
array_likeA  s   r  )r1   r2   r   rE  r  r    r   )rQ   r  r  rj  r7   )rR   r8   r  >  s    

zTest_I0.test_non_arrayN)r\   r]   r^   r|  r  r7   r7   r7   r8   r  !  s   r  c               @   s   e Zd Zdd Zdd ZdS )
TestKaiserc             C   s   t tjtdd ttddtjg  ttddtjddg ttddtjdddddg ttddtjd	d
dd
d	g d S )NrE   g      ?r   rD   g oF?rH   gvT=?gg?g?gYJ?)r   r1   isfiniter#   r   rf   )rQ   r7   r7   r8   r|  Q  s    





zTestKaiser.test_simplec             C   s   t dd d S )NrG   rC   )r#   )rQ   r7   r7   r8   test_int_beta^  s    zTestKaiser.test_int_betaN)r\   r]   r^   r|  r  r7   r7   r7   r8   r  O  s   r  c               @   s   e Zd Zdd ZdS )	TestMsortc             C   sR   t jdddgdddgddd	gg}tt|t jddd	gdddgdddgg d S )
Ng\?gbCQ?gהs?gw?gkl?g*dta?gӯ?g6H?gܘC?)r1   rf   r   r%   )rQ   r  r7   r7   r8   r|  d  s    zTestMsort.test_simpleN)r\   r]   r^   r|  r7   r7   r7   r8   r  b  s   r  c               @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )TestMeshgridc          	   C   s   t dddgddddg\}}t|tjdddgdddgdddgdddgg t|tjdddgdddgdddgdddgg d S )NrE   rD   rG   rC   rH   rX   rY   )r$   r   r1   rf   )rQ   XYr7   r7   r8   r|  q  s    zTestMeshgrid.test_simplec             C   s.   t ddddg\}t|tjddddg d S )NrE   rD   rG   rC   )r$   r   r1   rf   )rQ   r  r7   r7   r8   test_single_input|  s    zTestMeshgrid.test_single_inputc             C   s*   g }t g t|  t g t|ddi d S )Nr}   F)r   r$   )rQ   r  r7   r7   r8   test_no_input  s    zTestMeshgrid.test_no_inputc          	   C   s  dddg}ddddg}t ||dd	\}}t|tjddddgddddgddddgg t|tjddddgddddgddddgg d
dg}tt ||d jdk tt ||dd	d jdk tt |||d jdk tt |||dd	d jdk ttt ||dd	 d S )NrE   rD   rG   rC   rH   rX   rY   ij)ZindexingrW   r   r   Znotvalid)rC   rG   )rG   rC   )rC   rG   rD   )rG   rC   rD   )r$   r   r1   rf   r   r<   r	   rN   )rQ   r   r   r  r  rh  r7   r7   r8   test_indexing  s    


zTestMeshgrid.test_indexingc             C   s\   t dddgddddgdd	\}}t|tjdddgg t|tjdgdgdgdgg d S )
NrE   rD   rG   rC   rH   rX   rY   T)sparse)r$   r   r1   rf   )rQ   r  r  r7   r7   r8   test_sparse  s     zTestMeshgrid.test_sparsec             C   s$   t ttdddgddddgdd	 d S )
NrE   rD   rG   rC   rH   rX   rY   r  )r)  )r	   r   r$   )rQ   r7   r7   r8   test_invalid_arguments  s    z#TestMeshgrid.test_invalid_argumentsc             C   s   t jddt jd}t jddt jd}t j||\}}t|j|jk t|j|jk t j||dd\}}t|j|jk t|j|jk t j||dd\}}t|j|jk t|j|jk d S )Nr   r|   )r   r   T)r}   )r  )r1   r2   r   r   r$   r   r   )rQ   r   r   r  r  r7   r7   r8   r    s    zTestMeshgrid.test_return_typec             C   sr   t jddg}t jddg}t j||ddd\}}d|dd d f< t|dd d f d t|d	d d f | d S )
Ng?g@gffffff
@g@FT)r  r}   r   rE   )r1   rf   r$   r   )rQ   r  r  r   r   r7   r7   r8   test_writeback  s    zTestMeshgrid.test_writebackN)r\   r]   r^   r|  r  r  r  r   r!  r  r"  r7   r7   r7   r8   r  o  s   r  c               @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )TestPiecewisec          	   C   s6  t ddgddgdg}t|ddg t ddgddggdg}t|ddg t ddgtjddgdg}t|ddg t ddgtjddgdg}t|ddg t ddgtjddggdg}t|ddg t ddgddggdd g}t|dd
g ttdt ddgddggg  ttdt ddgddggddd	g d S )Nr   TFrE   c             S   s   dS )NrE   rM   r7   )r   r7   r7   r8   ro    s    z+TestPiecewise.test_simple.<locals>.<lambda>z1 or 2 functions are expectedrD   rG   rM   )r&   r   r1   rf   r   rN   )rQ   r   r7   r7   r8   r|    s     zTestPiecewise.test_simplec             C   s2   t ddgddgddggddg}t|ddg d S )NrE   rD   TFrG   rC   )r&   r   )rQ   r   r7   r7   r8   test_two_conditions  s     z!TestPiecewise.test_two_conditionsc             C   s&   t ddddgdddg}t|d d S )NrG   TFrC   rD   r   )r&   r   )rQ   r   r7   r7   r8   $test_scalar_domains_three_conditions  s    z2TestPiecewise.test_scalar_domains_three_conditionsc             C   sN   t ddgddgdg}t|ddg t ddgddgddg}t|ddg d S )NrE   rD   TFr   rG   )r&   r   )rQ   r   r7   r7   r8   test_default  s    zTestPiecewise.test_defaultc             C   s   t jd}t||dkddg}t|jdk t|dk d}t|ddgddg}t|jdk t|dk t|dddgdddg}t|d d S )	NrG   rC   r   rH   TFrE   rD   )r1   rf   r&   r   rl   r   )rQ   r   r   r7   r7   r8   r     s    
zTestPiecewise.test_0dc          
   C   s   d}t ||dk|dkgddg}t|d d}t ||dk|dk|dk |dkgdddg}t|d ttdt ||dk|dkgdg ttdt ||dk|dkgddddg d S )NrG   rC   r   rH   rE   rD   z2 or 3 functions are expected)r&   r   r   r   rN   )rQ   r   r   r7   r7   r8   test_0d_comparison	  s    
,
z TestPiecewise.test_0d_comparisonc             C   s8   t jd}t j|dk}t||gddg}t|d d S )NrG   rE   rD   )r1   rf   r&   r   )rQ   r   rq   r   r7   r7   r8   test_0d_0d_condition	  s    
z"TestPiecewise.test_0d_0d_conditionc             C   s\   t jd
ddgdddgg}t||dk |dkgdddg}t|t jdddgd	d	dgg d S )Ng      @g      ?g      ?r   rD   rE   rG   g      ?g      @g      g      g      rM   g      g      g      )r1   rf   r&   r   )rQ   r   r   r7   r7   r8   test_multidimensional_extrafunc	  s
    z-TestPiecewise.test_multidimensional_extrafuncN)r\   r]   r^   r|  r$  r%  r&  r   r'  r(  r)  r7   r7   r7   r8   r#    s   	r#  c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zejje dddd Zejjdddggdgdd ZdS )TestBincountc             C   s$   t jt jd}t|t jd d S )NrC   )r1   bincountr2   r   rO   )rQ   r   r7   r7   r8   r|  &	  s    zTestBincount.test_simplec          	   C   s:   t jt jdddddg}t|t jddddddg d S )NrE   rH   rD   rC   r   )r1   r+  rf   r   )rQ   r   r7   r7   r8   test_simple2*	  s    zTestBincount.test_simple2c             C   s6   t jd}t jddddg}t j||}t|| d S )NrC   g?g333333?g      ?g?)r1   r2   rf   r+  r   )rQ   r   r   r   r7   r7   r8   test_simple_weight.	  s    
zTestBincount.test_simple_weightc          	   C   sT   t jdddddg}t jdddddg}t j||}t|t jd	ddd	ddg d S )
NrE   rD   rC   rH   g?g333333?g      ?g?r   )r1   rf   r+  r   )rQ   r   r   r   r7   r7   r8   test_simple_weight24	  s    z TestBincount.test_simple_weight2c             C   s^   t jdddddg}t j|dd}t|t jdddg g }t j|dd}t|t jg  d S )Nr   rE   rG   )	minlengthrD   )r1   rf   r+  r   )rQ   r   r   r7   r7   r8   test_with_minlength:	  s    z TestBincount.test_with_minlengthc             C   sh   t jdddddddg}t j|dd}t|t jddddg t j|dd}t|t jddddg d S )Nr   rE   rD   rG   )r/  )r1   rf   r+  r   )rQ   r   r   r7   r7   r8   )test_with_minlength_smaller_than_maxvalueB	  s
    z6TestBincount.test_with_minlength_smaller_than_maxvaluec             C   sZ   t jdddddg}t jdddddg}t j||d	}t|t jd
ddd
ddd
d
g d S )NrE   rD   rC   rH   g?g333333?g      ?g?rW   r   )r1   rf   r+  r   )rQ   r   r   r   r7   r7   r8   test_with_minlength_and_weightsI	  s    z,TestBincount.test_with_minlength_and_weightsc             C   s&   t jg td}t j|}t|| d S )N)r   )r1   rf   r  r+  r   )rQ   r   r   r7   r7   r8   r  O	  s    
zTestBincount.test_emptyc             C   s4   t jg td}t j|dd}t|t jdtd d S )N)r   rH   )r/  )r1   rf   r  r+  r   r:   )rQ   r   r   r7   r7   r8   test_empty_with_minlengthT	  s    z&TestBincount.test_empty_with_minlengthc                sl   t jg td ttd fdd ttd fdd t jd ttd fdd ttd fd	d d S )
N)r   z"'str' object cannot be interpretedc                  s   t j ddS )Nfoobar)r/  )r1   r+  r7   )r   r7   r8   ro  ]	  s    z<TestBincount.test_with_incorrect_minlength.<locals>.<lambda>zmust not be negativec                  s   t j ddS )NrE   )r/  rM   )r1   r+  r7   )r   r7   r8   ro  `	  s    rH   c                  s   t j ddS )Nr4  )r/  )r1   r+  r7   )r   r7   r8   ro  e	  s    c                  s   t j ddS )NrE   )r/  rM   )r1   r+  r7   )r   r7   r8   ro  h	  s    )r1   rf   r  r   r   rN   r2   )rQ   r7   )r   r8   test_with_incorrect_minlengthY	  s    
z*TestBincount.test_with_incorrect_minlengthzPython lacks refcounts)r  c             C   s   t jtjtj}t jtjtj}x tdD ]}tjdddg q.W tt jtjtj| tt jtjtj| x(tdD ]}tjdddgdddg qW tt jtjtj| tt jtjtj| d S )Nr|   rE   rD   rG   rC   rH   rX   )	r  r  r1   r   ZintpdoublerP   r+  r   )rQ   Zintp_refcountZdouble_refcountjr7   r7   r8   test_dtype_reference_leaksj	  s    z'TestBincount.test_dtype_reference_leaksvalsrD   c             C   sJ   t j|}tt t j| W d Q R X tt t j| W d Q R X d S )N)r1   asarrayr	   rN   r+  )rQ   r9  Zvals_arrr7   r7   r8   test_error_not_1dz	  s
    


zTestBincount.test_error_not_1dN)r\   r]   r^   r|  r,  r-  r.  r0  r1  r2  r  r3  r5  r   ra  r  r   r8  rb  r;  r7   r7   r7   r8   r*  $	  s   r*  c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zej	dd dd dd dd gddddgddd Z
dd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)S )*
TestInterpc             C   st   t ttdg g  t ttddgddg t ttdddgddgdd t ttdg g dd t ttddgddgdd d S )Nr   rE   rD   )periodih  )r	   rN   r"   )rQ   r7   r7   r8   test_exceptions	  s
    zTestInterp.test_exceptionsc             C   sB   t jddd}t jddd}t jddd}tt j|||| d S )Nr   rE   rH   rT   )r1   rD  r   r"   )rQ   r   r   x0r7   r7   r8   rS   	  s    zTestInterp.test_basicc       
      C   s  xt ddD ]}tj|tjd}tj|tjd}tjd	d|d |gtjd}|d d d
 }t|||}t|||}tjddddgtd}|d d d }	t|| t||	 t|||dd}t|||dd}tjddddgtd}|d d d }	t|| t||	 t|||dd}t|||dd}tjddddgtd}|d d d }	t|| t||	 t|||ddd}t|||ddd}tjddddgtd}|d d d }	t|| t||	 qW d S )NrE   r|   )r   r   )leftrD   )right)r@  rA  rM   rM   rM   rM   rM   rM   )	rP   r1   r2   r6  rO   rf   r"   r   r   )
rQ   sizexpZypZincptsZdecptsZincresZdecresZinctgtZdectgtr7   r7   r8   test_right_left_behavior	  s:    






z#TestInterp.test_right_left_behaviorc             C   s   t jddd}t jddd}d}tt j|||| d}tt j|||| t jd}tt j|||| t jd}tt j|||| t j}tt j|||| d S )Nr   rE   rH   g333333?)r1   rD  r   r"   r   r   r   )rQ   r   r   r?  r7   r7   r8   test_scalar_interpolation_point	  s    

z*TestInterp.test_scalar_interpolation_pointc             C   s~   dddddg}ddddg}ddt jdg}tt j|||ddt jt jdg ddt jdg}tt j|||ddt jt jdg d S )NrE   rD   g      @rG   rC   )r1   r  r   r"   r   )rQ   r   rC  fpr7   r7   r8    test_non_finite_behavior_exact_x	  s    "z+TestInterp.test_non_finite_behavior_exact_xc             C   s
   t j| S )N)r1   Zfloat_)r   r7   r7   r8   ro  	  s    zTestInterp.<lambda>c             C   s
   t | dS )Nr   )rA   )r   r7   r7   r8   ro  	  s    c             C   s
   t d| S )Nr   )rA   )r   r7   r7   r8   ro  	  s    c             C   s   t | tj| dS )NrD   rK   )rA   r1   multiply)r   r7   r7   r8   ro  	  s    r>   zcomplex-realzcomplex-imagzcomplex-both)paramsidsc             C   s   |j S )z( scale function used by the below tests )param)rQ   requestr7   r7   r8   sc	  s    zTestInterp.scc             C   s   t tjdtjdg|ddg|tj t tjddtjg|ddg|tj t tjdddg|tjdg|tj t tjdddg|dtjg|tj dS )z test that nans are propagated g      ?rE   r   r|   N)r   r1   r"   r   )rQ   rM  r7   r7   r8   test_non_finite_any_nan	  s    (((z"TestInterp.test_non_finite_any_nanc             C   s   t tjdtj tj
 g|ddg|tj t tjdddg|tj tj
 g|tj t tjdddg|tj
 tj g|tj t tjdtj tj
 g|ddg|d dS )z2 Test that interp between opposite infs gives nan g      ?r   r|   rE   N)r   r1   r"   r  r   )rQ   rM  r7   r7   r8   test_non_finite_inf	  s    ...zTestInterp.test_non_finite_infc             C   st  t tjdtj dg|tj dg|tj t tjdtj dg|tj
 dg|tj t tjdtj dg|dtj g|tj t tjdtj dg|dtj
 g|tj t tjddtj
 g|tj dg|tj t tjddtj
 g|tj
 dg|tj t tjddtj
 g|dtj g|tj t tjddtj
 g|dtj
 g|tj dS )z@ Test that interp where both axes have a bound at inf gives nan g      ?rE   r|   r   N)r   r1   r"   r  r   )rQ   rM  r7   r7   r8   test_non_finite_half_inf_xf	  s    .......z&TestInterp.test_non_finite_half_inf_xfc             C   s   t tjdtj tj g|ddg|d t tjdtj dg|ddg|d t tjddtj
 g|ddg|d t tjdtj
 tj
 g|ddg|d dS )z1 Test interp where the x axis has a bound at inf g      ?r   r|   rE   N)r   r1   r"   r  )rQ   rM  r7   r7   r8   test_non_finite_half_inf_x	  s    ,((z%TestInterp.test_non_finite_half_inf_xc             C   s  t tjdddg|dtj g|tj  t tjdddg|dtj
 g|tj
  t tjdddg|tj dg|tj  t tjdddg|tj
 dg|tj
  t tjdddg|tj tj g|tj  t tjdddg|tj
 tj
 g|tj
  dS )z1 Test interp where the f axis has a bound at inf g      ?r   rE   r|   N)r   r1   r"   r  )rQ   rM  r7   r7   r8   test_non_finite_half_inf_f 
  s    ,,,,0z%TestInterp.test_non_finite_half_inf_fc       	   	   C   sH  t jddd}t jddddt jddd d  }d}|d| d  }tt j|||| d(}d)}tt j||||d| d	}d*}tt j||||d
| dddddg}ddddg}dd+t jdg}dd,t jd t jdg}tt j|||| d-d.d/dd0d1ddg}dd2dd3g}d4d5d6d7g}d8d9d:d;d<d=d>d?g}tt j|||d&d'| d S )@Nr   rE   rH   y              ?g333333?rD   y              @)r@  g       @)rA  g      @rG   rC   y              ?r        r|   im     i^  y               @y              @g      @y              ?g      @g     !@y              ?g      @y              ?g      @g      
@y              
@g      @y              @g      @y              @ih  )r=  rM   y       @      @y       @      @y       @      ?y       @      ?iLiViGir   iBiy      @      ?y      $@       @y      @      @y      @      @y      @      ?y      @      ?y     !@      ?y      @      ?y      @      @y      
@      
@y      @      @y      @      @)r1   rD  r   r"   r  )	rQ   r   r   r?  Zy0r@  rA  rC  rF  r7   r7   r8   test_complex_interp	
  s,    $zTestInterp.test_complex_interpc             C   s   t jddd}t jddd}t jd}tt j|||| t jdddg}t jdd
dg}t jt jd||}t|d tt|t j t jt jd||dd}t|d	 tt|t j d S )Nr   rE   rH   g333333?rD   rC   g      @)r=  g      ?rM   )	r1   rD  rf   r   r"   r   r   r   r   )rQ   r   r   r?  rC  rF  r   r7   r7   r8   )test_zero_dimensional_interpolation_point%
  s    


z4TestInterp.test_zero_dimensional_interpolation_pointc             C   s2   t jddd}t j|}tt jt j||d d S )Nr   r|   g-C6?g        )r1   r2   sinr   r"   rg  )rQ   rC  rF  r7   r7   r8   test_if_len_x_is_small6
  s    
z!TestInterp.test_if_len_x_is_smallc             C   s   ddddddddg}dd d	d!g}ddd
dg}ddddddddg}t tj|||dd| tj|ddjdd"}tj|ddjdd#}t tj|||dd| d S )$Nr  rS  rT  r|   rH   r   im  rU  i^  rG   rC   g      @g      @g     !@g      @g      @g      
@g      @g      @ih  )r=  r   )r   rD   rE   r   iLiViGir   iBirM   rM   )r   r1   r"   rf   rZ   )rQ   r   rC  rF  r   r7   r7   r8   test_period;
  s    zTestInterp.test_periodN)r\   r]   r^   r>  rS   rD  rE  rG  r   ZfixturerM  rN  rO  rP  rQ  rR  rV  rW  rY  rZ  r7   r7   r7   r8   r<  	  s.   &		r<  c             C   s,   x&t t|D ]}t| | ||  qW d S )N)rP   r   r   )rj  r   rn   r7   r7   r8   compare_resultsF
  s    r[  c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1S )2TestPercentilec             C   s~   t jdd }tt j|dd tt j|dd tt j|dd t j|d	< tt j|dt j tt j|dd
dt j d S )NrW   g      ?r   g        r   g      @rT   g      ?rE   nearest)interpolation)r1   r2   r   
percentiler   )rQ   r   r7   r7   r8   rS   M
  s    
zTestPercentile.test_basicc             C   s   dd t dD }tj|td}t|td tt|t tj|td}t|tdd tt|t tj|td}t|tdd	 tt|t d S )
Nc             S   s   g | ]}t |d qS )rD   )r   )r   rn   r7   r7   r8   r   W
  s    z0TestPercentile.test_fraction.<locals>.<listcomp>rW   r   r   rY   rD   rT   rC   )rP   r1   r_  r   r   r   )rQ   r   r  r7   r7   r8   test_fractionV
  s    zTestPercentile.test_fractionc             C   sR   t jd}t j|dd d d t j|dd d dd t jd}t j|dd |dd d S )NrH   FlinearrE   )rE   )r1   rO   r_  )rQ   r   or7   r7   r8   test_apie
  s
    

zTestPercentile.test_apic             C   sR   t jdddgdddgdddgdddgdddgg}tt j|ddddddg d S )NrE   rC   rG   rT   r   )r`   )r1   rf   r   r_  )rQ   r   r7   r7   r8   test_2Dl
  s    zTestPercentile.test_2Dc             C   s4   t tjtddd t tjtddddd d S )Nr|   rT   g      @ra  )r^  )r   r1   r_  rP   )rQ   r7   r7   r8   test_lineart
  s    zTestPercentile.test_linearc             C   s8   t tjtddddd t tjtddddd d S )Nr|   rT   lower)r^  rC   higherrH   )r   r1   r_  rP   )rQ   r7   r7   r8   test_lower_higher}
  s    z TestPercentile.test_lower_higherc             C   sR   t tjtddddd t tjtddddd t tjtddddd	 d S )
Nr|   3   midpoint)r^  g      @r   g      @rT   rH   )r   r1   r_  rP   )rQ   r7   r7   r8   test_midpoint
  s    zTestPercentile.test_midpointc             C   s8   t tjtddddd t tjtddddd d S )Nr|   ri  r]  )r^  rH   1   rC   )r   r1   r_  rP   )rQ   r7   r7   r8   test_nearest
  s    zTestPercentile.test_nearestc             C   s0   t jdd }tt j|dddgdddg d S )NrW   g      ?r   r   rT   g      @g      ?)r1   r2   r   r_  )rQ   r   r7   r7   r8   test_sequence
  s    zTestPercentile.test_sequencec             C   s  t jdjdd}tt j|dddd	g d
dddgddddgddddgg}tt j|ddd| dddgdddgdddgg}tt j|d ddt j|j t jd#jdddd}tt j|d$jd% tt j|d&jd' tt j|d(ddjd) tt j|d*ddjd+ tt j|d,d
djd- tt j|d.ddjd/ tt j|d0ddjd1 tt j|d2ddjd3 tt j|d4ddjd5 tt j|d6dddjd7 tt j|d8dddjd9 tt j|d:d
ddjd; tt j|d<dddjd= tt j|d>dddjd? d S )@Nr   rG   rC   r8  rT   r   g      @g      @g      &@rD   rH   rX   rY   rW   r   r|   r   r   )r`   g      ?g      ?g      @g     !@g      #@rE   K   rg  )r^  )r`   r^  )r8  rT   r   )r8  rT   r   )r8  rT   r   r   r3  ih  )r8  rT   )rD   )r8  rT   ro  )rG   )r8  rT   )rD   rC   rH   rX   )r8  rT   )rD   rG   rH   rX   )r8  rT   )rD   rG   rC   rX   )r8  rT   )rD   rG   rC   rH   )r8  rT   ro  )rG   rG   rH   rX   )r8  rT   )rD   )r8  rT   ro  )rG   )r8  rT   )rD   rC   rH   rX   )r8  rT   )rD   rG   rH   rX   )r8  rT   )rD   rG   rC   rX   )r8  rT   )rD   rG   rC   rH   )r8  rT   ro  )rG   rG   rH   rX   )r1   r2   rZ   r   r_  rf   r   r<   )rQ   r   r0r  r7   r7   r8   r  
  s:    "

zTestPercentile.test_axisc             C   s  t jdjdd}tt j|dd tt jt j|d t jdddd	g}tt j|dd
d| tt j|dd
dj|j t jdddg}t	t j|ddd| tt j|dddj|j t j
d}tt j|d|dd t|d t j
d}tt j|dd
|d| t|| t j
d}tt j|dd|d| t|| t jdjdd}tt j|dddd tt jt j|d t jdddd	g}t j|ddd
d}t|| t|j|j t jdddg}t j|dddd}t	|| t|j|j t j
f |jd}t j|dd|d}t|d t|d t j
d|jd}t j|ddd
|d}t|| t|| t j
d|jd}t j|ddd|d}t|| t|| d S )Nr   rG   rC   rT   g      @g      @g      @g      @g      @r   )r`   g      ?g      #@rE   )r  )r`   r  rf  )r^  )r^  r`   g      ?g      "@)r   )r^  r  rH   )r^  r`   r  )r1   r2   rZ   r   r_  r   Zisscalarrf   r<   r   emptyr   )rQ   r   rp  r  r  Zc0c1rq   r7   r7   r8   test_scalar_q
  sR    












zTestPercentile.test_scalar_qc             C   s   t ttjddgddd t ttjdgd t ttjdgd	 t ttjdgttddg  t ttjdgttdd
g  d S )NrE   rD   8   r4  )r^  e   rT   g?rM   g)r	   rN   r1   r_  r  rP   )rQ   r7   r7   r8   test_exception
  s     zTestPercentile.test_exceptionc             C   s   t tjdddgdd d S )NrE   rD   rG   r   )r   r1   r_  )rQ   r7   r7   r8   test_percentile_list
  s    z#TestPercentile.test_percentile_listc             C   s  t jdddg}t jd }d!}t j|||d t|t j|| t jdddgdddgg}t jd"}t j||d|d	 t|t j||dd
 t jd#}t j||d|d	 t|t j||dd
 t jdjdd}t jddddgddddgg}t jd$}tt j|d%d|d	| t|| t jdddgdddgg}t jd&}tt j|d'd|d	| t|| t jddddgddddgg}t jd(|jd}t j|d)dd|d}t|| t|| t jdddgdddgg}t jd*|jd}t j|d+dd|d}t|| t|| d S ),NrE   rD   rG   )r  rC   rH   rX   r   )r`   r  )r`   r   g       @g      @g      @g      @g      @g      @r8  rT   g      ?g      @g     !@g      ?g      @g      #@rY   )r   rf  )r^  r`   r  rW   r   )rG   )rE   rD   rG   )rG   rG   )rG   rD   )rD   rC   )r8  rT   )rD   rG   )r8  rT   )rD   rC   )r8  rT   )rD   rG   )r8  rT   )	r1   rf   r:   r_  r   r2   rZ   rq  r   )rQ   r   r   r  rp  r  r  rq   r7   r7   r8   test_percentile_out
  s@    









z"TestPercentile.test_percentile_outc             C   s  t jdjdddd}tt j|dddjd tt j|dddjd tt j|dddjd tt j|dddjd tt j|dddjd tt j|dddjd tt j|dddjd tt j|dddjd tt j|ddd	d
jd tt j|ddd	d
jd tt jt j|ddgddjd tt jt j|ddgddjd tt jt j|ddgddjd tt jt j|ddgddjd d S ) Nr   rD   rE   rT   r   )r`   rG   rC   rj  )r`   r^  r|   r   )rE   rD   rE   )r   rD   rE   )r   rE   rE   )r   rE   rD   rM   )r   rE   rD   rK   )r   rE   rE   rL   )r   rD   rE   r   )rE   rD   rE   )r   rE   rE   rK   )r   rE   rE   )rD   rE   rD   rE   )rD   r   rD   rE   )rD   r   rE   rE   )rD   r   rE   rD   )r1   r2   rZ   r   r_  r<   rf   )rQ   r   r7   r7   r8   test_percentile_empty_dim  s.    z(TestPercentile.test_percentile_empty_dimc             C   sx   t jddddg}t j|dgdd t|t jddddg t jddddg}t j|dg t|t jddddg d S )NrD   rG   rC   rE   rT   F)overwrite_input)r1   rf   r_  r   )rQ   rR   r7   r7   r8   test_percentile_no_overwrite;  s    z+TestPercentile.test_percentile_no_overwritec             C   s   t jdddd}t jt jd|dd t|t jdddd t jddddj }t jt jd|dd t|t jddddj  d S )Ng        g      Y@rH   )numrj  )r^  )r1   rD  r_  r2   r   tolist)rQ   r  r7   r7   r8   test_no_p_overwriteD  s    z"TestPercentile.test_no_p_overwritec             C   sf   t jddddg}t j|dgdd}t|t jdg t jddddgdgdd}t|t jdg d S )	NrD   rG   rC   rE   rT   T)rz  g      @)r1   rf   r_  r   )rQ   rR   rc   r7   r7   r8   test_percentile_overwriteL  s
    z(TestPercentile.test_percentile_overwritec          	   C   s  t jjdd}t j|gd }tt j|dddt j|d t j|dd}tt j|dddt j|d |jddj }tt j|dddt j|d |jddj }tt j|d
dgddt j|d
dgd d tt j|d
dgddt j|d
dgdd t j	dj
d}t jj|j  tt j|d
d dd t j|d d d d d d df j d
 tt j|ddgd!dd d df t j|d d d d dd d f j ddg tt j|d
d#dd	 t j|d d d d d	d d f j d
 tt j|d
d$dd	 t j|d	d d d d d d f j d
 tt j|d
d%dd& t j|d	dd d d d f j d
 tt j|d
d(dd) t j|d	d d d d df j d
 tt j|d
d*dd+ t j|d	d d d	d d f j d
 d S ),NG      )rB  r|   r   r   rE   )r`   rD   r8  r3  rG   rH   rY   r   Z   rC   )r  r  )r   rE   rM   rK   rM   )rK   rM   rM   )r   rM   )r   rE   rD   )r   r   i   i  )rG   rH   rY   r   )r   rE   rD   )r   rE   rG   r   )rG   rE   r   )rG   rE   rD   )rG   rD   )rD   rE   rK   )rE   rK   )rD   rE   )rE   rG   )rD   rD   )r1   rF  normaldstackr   r_  moveaxisrm   r}   r2   rZ   shuffleravelflatten)rQ   rb  r   r   r7   r7   r8   test_extended_axisT  s8    * .**&&z!TestPercentile.test_extended_axisc             C   s   t jd
}tt jt j|ddd tt jt j|ddd tt jt j|ddd tt jt j|ddd ttt j|ddd ttt j|ddd ttt j|ddd d S )NrG   rH   rY   r   r8  )r`   r  r   rC   rE   )rG   rH   rY   r   r   r   )r   r   )r   rC   )rE   rE   rM   rM   )rM   rM   rM   )rG   rM   )r1   rO   r	   ra   r_  rN   )rQ   r   r7   r7   r8   test_extended_axis_invalidt  s    
z)TestPercentile.test_extended_axis_invalidc             C   s   t jd}tt j|dd ddjd tt j|ddddjd tt j|ddddjd tt j|ddddjd tt j|dddd
jd tt j|ddddjd tt j|ddgdddjd tt j|ddgdddjd d S )NrG   rH   rY   r   T)r`   r   rE   r   rD   )r   )rG   rH   rY   r   )rE   rE   rE   rE   )r   rE   )rE   rE   rY   r   )r   rG   )rE   rH   rY   rE   )rE   )rG   rE   rY   r   )r   rE   rD   rG   )rE   rE   rE   rE   )r   rE   rG   )rE   rE   rY   rE   )r   rE   rG   )rD   rE   rE   rY   rE   )r   rG   )rD   rE   rH   rY   rE   )r1   rO   r   r_  r<   )rQ   r   r7   r7   r8   test_keepdims  s"    
zTestPercentile.test_keepdimsc             C   s   t jd	}t jd
}tt j|dd|d| tt j|ddd|d| t jd}tt j|dd|d| tt j|ddd|d| t jf }tt j|d|d| tt j|dd|d| d S )NrC   rG   r   )r  r]  )r^  r  rE   rD   )rC   )rG   rC   )rG   )r1   r:   rO   r   r_  )rQ   rb  r   r7   r7   r8   test_out  s    



zTestPercentile.test_outc             C   s   t jdd t jddt tjd}tjd}tj|d< ttj	|d	d	|d
| ttj	|d	d	d|d| tjd}ttj	|dd|d
| ttj	|ddd|d| tjf }ttj	|d|d
| ttj	|dd|d| W d Q R X d S )NT)r   r   r   rC   rG   rD   rE   r   )r  r]  )r^  r  )rC   )rG   rC   )rD   rE   )rG   )
r   r   r   r  r1   r:   rO   r   r   r_  )rQ   rb  r   r7   r7   r8   test_out_nan  s     




zTestPercentile.test_out_nanc             C   s:  t jdtd}t j|d< tt j|dt j tt j|dddt j tt j|ddgddt jt jgd  t jdtdjddd	}t j|d< t j|d< tt j|dt j tt j|djd t jt jdtdjddd	dd}t j|d< t j|d< tt j|dd| t jt jdtdjddd	ddgd}t j|d d ddf< t j|d d d
df< tt j|ddgd| t jt jdtdjddd	dd
}t j|d< t j|d< tt j|dd
| t jt jdtdjddd	ddgd
}t j|d d d
df< t j|d d d
df< tt j|ddgd
| t jt jdtdjddd	dd}t j|d
< t j|d< tt j|dd| t jt jdtdjddd	ddgd}t j|d d d
f< t j|d d df< tt j|ddgd| t jt jdtdjddd	ddgddd}t j|d d d
f< t j|d d df< tt j|ddgddd| d S )Nrj   )r   rD   g333333?r   )r`   g333333?rG   rC   rE   r]  )r^  )rE   rD   rG   )rE   rE   rD   )rD   rG   )rE   rD   )rE   rG   )rE   rD   )r   rD   )r   rD   )r   rD   )r   rD   )r   rD   )r   rD   )	r1   r2   r   r   r   r_  rf   rZ   rl   )rQ   rR   rc   r7   r7   r8   test_nan_behavior  sZ    


"

"

"

z TestPercentile.test_nan_behaviorN)r\   r]   r^   rS   r`  rc  rd  re  rh  rk  rm  rn  r  rs  rv  rw  rx  ry  r{  r~  r  r  r  r  r  r  r  r7   r7   r7   r8   r\  K
  s0   		$0)	 r\  c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestQuantilec             C   sH   t jdd }tt j|dd tt j|dd tt j|dd d S )NrW   g      ?r   g        rE   g      @g      ?)r1   r2   r   quantile)rQ   r   r7   r7   r8   rS     s    zTestQuantile.test_basicc             C   sn   t jdg}t jdd}t||d  tt||j t jdddg}t j||}t|| t|j|j d S )NTFr   )r1   rf   r  r   r   r   r   )rQ   rR   Ztf_quantZ	quant_resr7   r7   r8   test_correct_quantile_value  s    
z(TestQuantile.test_correct_quantile_valuec             C   s   dd t dD }tj|d}t|d tt|t tj|d}t|tdd tt|t tj|tdd}t|tdd tt|t tjd}ttj|tddtdd d S )	Nc             S   s   g | ]}t |d qS )rD   )r   )r   rn   r7   r7   r8   r     s    z.TestQuantile.test_fraction.<locals>.<listcomp>rW   r   rE   rY   rD   rC   )rP   r1   r  r   r   r   r2   )rQ   r   r  r7   r7   r8   r`    s    

zTestQuantile.test_fractionc             C   sp   t jdddddg}|j }t jt jd|dd t|| |j }|j }t jt jd|dd t|| d S )	Nr   g      ?g      ?g      ?g      ?g      Y@rj  )r^  )r1   rf   r}   r  r2   r   r}  )rQ   Zp0r  r7   r7   r8   r~    s    
z TestQuantile.test_no_p_overwriteN)r\   r]   r^   rS   r  r`  r~  r7   r7   r7   r8   r    s   
r  c               @   st   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd ZdS )
TestMedianc             C   sH  t jd}t jd}t jdjdd}tt j|d tt j|d tt j|d tt j|ddd	dd
g tt j|ddddg tt j|d dd t jddddg}t|d |d  d t j| t jdddg}t|d t j| t jdddg}t|d t j| tt j|jd t j	|d< tt j|jd d S )NrE   rD   rX   rG   g      ?g      @r   )r`   g      ?g      @rC   g6-¦?g0?g}r?g4?g       @rM   )
r1   rf   r2   rZ   r   medianr
   r   rl   r   )rQ   a0r   r  rR   r7   r7   r8   rS   &  s$    

 
zTestMedian.test_basicc             C   s   t jddgddgddgddgg}x`|t jjdd	dd
gD ]F}|j }t j|d d x t|jD ]}t j||d q`W t|| q:W t	t j|ddddg t	t j|j
ddddg t	t j|d t	t j|d dd t	t j|j
d d S )NrD   rG   r   rE   rX   rY   rC   rH   r   )rB  )r`   g      @)rD   rG   rC   )r1   rf   rF  randintr}   r  rP   rl   r   r
   r   )rQ   a3rR   origZaxr7   r7   r8   test_axis_keyword<  s    
zTestMedian.test_axis_keywordc             C   s  t jddgddgddgddgg}t jd}t jd}t jdjdd}tt j|j d	d
d tt j|j d	d
d tt j|j d	d
d tt j|j d	dddddg tt j|j d	ddddg tt j|j d	d dd tt j|j d	ddddg tt j|jj d	ddddg t jdt jdjd}t j	j
|j  tt j|d dt j|j d d	d tt j|ddt j|j dd	d tt j|ddt j|j dd	d tt j|ddt j|j dd	d d S )NrD   rG   r   rE   rX   rY   rC   rH   T)rz  g      ?g      @)rz  r`   g      ?g      @)r   )r`   )r`   rz  r   r3  )rG   rC   rH   )r1   rf   r2   rZ   r
   r  r}   r   r   rF  r  r  )rQ   r  r  r   r  Za4r7   r7   r8   test_overwrite_keywordN  s<    



z!TestMedian.test_overwrite_keywordc             C   sH   dddg}t tj|d |g}t tj|d ttj|dd| d S )NrE   rD   rG   r   )r`   )r   r1   r  r
   )rQ   r   rB  r7   r7   r8   r  o  s
    
zTestMedian.test_array_likec             C   s4   G dd dt j}|dddg}tt j|d d S )Nc               @   s    e Zd ZdddZdddZdS )z,TestMedian.test_subclass.<locals>.MySubClassNc             S   s   t j|j| }||_|S )N)r1   r:  r   info)clsZinput_arrayr  objr7   r7   r8   __new__z  s    z4TestMedian.test_subclass.<locals>.MySubClass.__new__c             S   s   dS )NrY   ir7   )rQ   r`   r   r  r7   r7   r8   r     s    z1TestMedian.test_subclass.<locals>.MySubClass.mean)N)NNN)r\   r]   r^   r  r   r7   r7   r7   r8   
MySubClassx  s   
r  rE   rD   rG   rY   i)r1   r   r   r  )rQ   r  rR   r7   r7   r8   r   v  s    
zTestMedian.test_subclassc             C   sl   t jd}t jd}tt j|d|d| t jd}tt j|d|d| t jf }tt j||d| d S )	NrC   rG   r   )r  rE   )rC   )rG   rC   )rG   )r1   r:   rO   r   r  )rQ   rb  r   r7   r7   r8   r    s    



zTestMedian.test_outc             C   s   t jdd t jddt tjd}tjd}tj|d< ttj	|d	|d
| tjd}ttj	|d|d
| tjf }ttj	||d
| W d Q R X d S )NT)r   r   r   rC   rG   rD   rE   r   )r  )rC   )rG   rC   )rD   rE   )rG   )
r   r   r   r  r1   r:   rO   r   r   r  )rQ   rb  r   r7   r7   r8   r    s    




zTestMedian.test_out_nanc             C   sf  t jdtd}t j|d< tt j|t j tt j|ddt j t jdtdjddd}t j|d	< t j|d
< tt j|t j tt j|jd t jt jdtdjdddd}t j|d< t j|d< tt j|d| t jt jdtdjdddd}t j|d< t j|d< tt j|d| t jt jdtdjdddd}t j|d< t j|d< tt j|d| d S )Nrj   )r   rD   r   )r`   rG   rC   rE   )rE   rD   rG   )rE   rE   rD   )rD   rG   )rE   rD   )rE   rG   )rE   rD   )r   rD   )r   rD   )r1   r2   r   r   r   r  rZ   rl   )rQ   rR   rc   r7   r7   r8   r    s*    


 

 

 

zTestMedian.test_nan_behaviorc             C   sZ  t jg td}tjddF}tjddt tt j|t j	 t
|d jtk tt|d W d Q R X t jg tdd	}tjdd8}tjddt tt j|t j	 t
|d jtk W d Q R X t jg tdd	}tt j|dd
| tt j|dd
| t jt j	tdd	}tjdd:}tjddt tt j|dd
| t
|d jtk W d Q R X d S )N)r   T)r   r   r   r   rD   rG   )r   r   )r`   rE   )r1   rf   r   r   r   r   r  r   r  r   r   r   r   )rQ   rR   r   rc   r7   r7   r8   r    s&    zTestMedian.test_emptyc             C   sL   t jd}ttt j|jtt t j|d< ttt j|jtt d S )Ng      @rD   )	r1   r2   r   r   r  r   objectr   r   )rQ   rb  r7   r7   r8   test_object  s    

zTestMedian.test_objectc          	   C   s  t jjdd}t j|gd }tt j|ddt j| t j|dd}tt j|ddt j| |jddj }tt j|ddt j| tt j|ddt j|d d tt j|ddt j|dd tt j|ddt j|dd t j	dj
d}t jj|j  tt j|ddd t j|d d d d d d df j  tt j|d dd t j|d d d d dd d f j  tt j|d"dd t j|d d d d dd d f j  tt j|d#dd t j|dd d d d d d f j  tt j|d$dd% t j|ddd d d d f j  tt j|d'dd( t j|dd d d d df j  tt j|d)dd* t j|dd d dd d f j  d S )+Nr  r  )rB  r|   r   rE   )r`   rD   rG   rH   rY   r   rC   )r  r  )r   rE   rM   rK   rM   )rK   rM   rM   )r   rM   )r   rE   rD   )r   rM   )rM   rM   r   r  i  )rG   rH   rY   r   )r   rE   rD   )r   rE   rG   r   )rG   rE   r   )rG   rE   rD   )rG   rD   )rD   rE   rK   )rE   rK   )rD   rE   )rE   rG   )rD   rD   )r1   rF  r  r  r   r  r  rm   r}   r2   rZ   r  r  r  )rQ   rb  r   r   r7   r7   r8   r    s4    (((($$zTestMedian.test_extended_axisc             C   sp   t jd	}tt jt j|d
d tt jt j|dd tt jt j|dd tt jt j|dd ttt j|dd d S )NrG   rH   rY   r   )r`   r   rC   rE   )rG   rH   rY   r   r   r   )r   r   )r   rC   )rE   rE   )r1   rO   r	   ra   r  rN   )rQ   r   r7   r7   r8   r    s    
z%TestMedian.test_extended_axis_invalidc             C   s   t jd
}tt j|d ddjd tt j|dddjd tt j|dddjd tt j|dddjd tt j|dddjd tt j|dddjd d S )NrG   rH   rY   r   T)r`   r   rE   r   rD   )rG   rH   rY   r   )rE   rE   rE   rE   )r   rE   )rE   rE   rY   r   )r   rG   )rE   rH   rY   rE   )rE   )rG   rE   rY   r   )r   rE   rD   rG   )rE   rE   rE   rE   )r   rE   rG   )rE   rE   rY   rE   )r1   rO   r   r  r<   )rQ   r   r7   r7   r8   r    s    
zTestMedian.test_keepdimsN)r\   r]   r^   rS   r  r  r  r   r  r  r  r  r  r  r  r  r7   r7   r7   r8   r  $  s   !	 r  c               @   s   e Zd Zdd Zdd ZdS )TestAdd_newdoc_ufuncc             C   s"   t ttdd t tttjd d S )NrD   Zblah)r	   r   r   rN   r1   r3   )rQ   r7   r7   r8   test_ufunc_arg  s    z#TestAdd_newdoc_ufunc.test_ufunc_argc             C   s   t tttjd d S )NrG   )r	   r   r   r1   r3   )rQ   r7   r7   r8   test_string_arg  s    z$TestAdd_newdoc_ufunc.test_string_argN)r\   r]   r^   r  r  r7   r7   r7   r8   r    s   r  c               @   s<   e Zd Zejjejjdkddejj	e
dddd ZdS )TestAdd_newdocrD   zPython running -OO)r  zPyPy does not modify tp_docc             C   sV   d}t tjjjjd t| | tttjjj	jdk tttj
jjjdk d S )Nz"Current flat index into the array.i,  )r   r1   coreZflatiterindexrm  r   r   Zufuncidentityr  Zindex_tricksZmgrid)rQ   r  r7   r7   r8   test_add_doc  s    zTestAdd_newdoc.test_add_docN)r\   r]   r^   r   ra  r  r  r   optimizer  r   r  r7   r7   r7   r8   r    s   r  c            	   @   s6   e Zd Zejjdddddddgdd Zdd ZdS )TestSortComplexztype_in, type_outlDhr   Hrc   r  rW  Gc             C   sN   t jdddddg|d}t j|}t j|j|}t|| t|j|j d S )NrH   rG   rX   rD   rE   )r   )r1   rf   sort_complexrH  r   r   r   )rQ   Ztype_inZtype_outrR   r   r  r7   r7   r8   test_sort_real*  s
    


zTestSortComplex.test_sort_realc             C   sR   t jdd	d
dgdd}t jddddgdd}t j|}t|| t|j|j d S )NrD   y              @rE   y               @y              ?r  )r   y       @      @y      ?       y      ?      y       @      ?y      ?      y      ?       y       @      ?y       @      @)r1   rf   r  r   r   )rQ   rR   r  r   r7   r7   r8   test_sort_complex:  s
    

z!TestSortComplex.test_sort_complexN)r  r  )r  r   )r  r   )rc   r   )r  r   )rW  r  )r\   r]   r^   r   ra  rb  r  r  r7   r7   r7   r8   r  (  s   
r  )rt  )rt  rx  )pr  r   r  r   Z	fractionsr   ru  r   Znumpyr1   r   Znumpy.testingr   r   r   r   r   r	   r
   r   r   r   r   r   Znumpy.lib.function_baser  Zfunction_baser  Znumpy.randomr   Z	numpy.libr   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*   r+   r,   r-   r.   r/   r0   r9   rA   rB   r_   rs   ry   r{   r   r   r   r   r   r   r   r  r  r  r%  r5  rc  ri  rn  rw  ry  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r#  r*  r<  r[  r\  r  r  r  r  r  r7   r7   r7   r8   <module>   s   8Dg#e>j S })

   (U	>Ud.Y\` C   (4 p
