o
    ʩZhh                    @   sR  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 d dlm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m Z  d dl!m"  m#Z$ d dl%m&Z& d dl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZG d d	lHmIZI d
d ZJd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d dZSG dd dZTG d d! d!ZUG d"d# d#ZVG d$d% d%ZWG d&d' d'ZXG d(d) d)ZYG d*d+ d+ZZG d,d- d-Z[G d.d/ d/Z\G d0d1 d1Z]G d2d3 d3Z^G d4d5 d5Z_dwd7d8Z`dxd:d;ZaG d<d= d=ZbG d>d? d?ZcG d@dA dAZdG dBdC dCZeejfgdDdEejhdF  ejhdG  ejfgdHg dIG dJdK dKZiG dLdM dMZjG dNdO dOZkG dPdQ dQZlG dRdS dSZmG dTdU dUZnG dVdW dWZoG dXdY dYZpG dZd[ d[ZqG d\d] d]ZrG d^d_ d_ZsG d`da daZtG dbdc dcZuG ddde deZvG dfdg dgZwg dhZxG didj djZyG dkdl dlZzG dmdn dnZ{G dodp dpZ|G dqdr drZ}G dsdt dtZ~G dudv dvZdS )y    NFraction)arrays)partial)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IS_WASM)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	vectorize)normalize_axis_tuplec                 C   s   t | }t j||}|S N)nparangeaddouter)ndata r=   Y/var/www/html/lang_env/lib/python3.10/site-packages/numpy/lib/tests/test_function_base.pyget_mat   s   
r?   c                 C   s(   t t | |jt j}| |_||_|S )za
    Like real + 1j * imag, but behaves as expected when imag contains non-finite
    values
    )r7   zeros	broadcastshapecomplex_realimag)rD   rE   retr=   r=   r>   _make_complex%   s   rG   c                   @   $   e Zd Zdd Zdd Zdd ZdS )	TestRot90c                 C   s  t tttd t tttddd t tttddd t tttddd t tttddd g dg d	g}d
dgddgddgg}g dg dg}ddgddgdd
gg}g dg d	g}tdddD ]}tt||d| qitdddD ]}tt||d| q{tdddD ]}tt||d| qtdddD ]}tt||d| qttt|dddd| tt|dddt|ddd d S )N      rL   rL   r      rL   axesrL   rL   r   rL   rN   rN   )rN      rJ      rL   rW   rN   r   rV   rW   rJ   rV   rL   rN   r      )krT   r   rN   rN   r   r\   rP   )r   
ValueErrorr,   r7   onesranger   )selfab1b2Zb3Zb4r\   r=   r=   r>   
test_basic1   s@   "zTestRot90.test_basicc                 C   sR   t d}tt|jd tt|ddt|dd tt|ddt|dd d S )N)2   (   rV   )rj   ri   rV   rR   rO   r   r]   rN   rL   rT   r]   )r7   rb   r   r,   rB   rd   re   r=   r=   r>   	test_axesQ   s   
zTestRot90.test_axesc                 C   s   t d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| tdd
D ]}tt||ddt||d dd qhd S )N   rK   rL   rV         r   rN   rJ   rW   r^   rO   r_   rl   )rL   r   r`   )r7   r8   reshaper   r,   rc   )rd   re   Z
a_rot90_01Z
a_rot90_12Z
a_rot90_20Z
a_rot90_10r\   r=   r=   r>   test_rotation_axesW   sJ   zTestRot90.test_rotation_axesN)__name__
__module____qualname__rh   ro   rt   r=   r=   r=   r>   rI   0   s     rI   c                   @   T   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ddd t tjtjtddd t tjtjtddd t tjtjtddd d S )NrJ   rN   axisrJ   rJ   rL   rZ   r   rV   )r   r7   	AxisErrorfliprb   rd   r=   r=   r>   ro   v   s   zTestFlip.test_axesc                 C   sf   t d}|d d d d df }tt|d| g dg dg}g dg dg}tt|d| d S )NrJ   r]   rN   rM   rU   rY   rX   r?   r   r7   r   rd   re   br=   r=   r>   test_basic_lr|      zTestFlip.test_basic_lrc                 C   sf   t d}|d d dd d f }tt|d| g dg dg}g dg dg}tt|d| d S )NrJ   r]   r   rM   rU   r   r   r=   r=   r>   test_basic_ud   r   zTestFlip.test_basic_udc                 C   sb   t ddgddggddgddggg}t ddgddggddgddggg}tt |d| d S 	Nr   rN   rL   rV   rJ   rW   rq   rr   r7   arrayr   r   r   r=   r=   r>   test_3d_swap_axis0      

zTestFlip.test_3d_swap_axis0c                 C   sb   t ddgddggddgddggg}t ddgddggddgddggg}tt |d| d S r   r   r   r=   r=   r>   test_3d_swap_axis1   r   zTestFlip.test_3d_swap_axis1c                 C   sb   t ddgddggddgddggg}t ddgddggddgddggg}tt |d| d S r   r   r   r=   r=   r>   test_3d_swap_axis2   r   zTestFlip.test_3d_swap_axis2c              	   C   sR   t ddddd}t|jD ]}tt ||t |d||d qd S )Nx   rL   rV   rJ   rW   r   )	r7   r8   rs   rc   ndimr   r   r    swapaxes)rd   re   ir=   r=   r>   test_4d   s   zTestFlip.test_4dc                 C   s@   t g dg dg}t g dg dg}tt || d S )NrN   rL   rV   rJ   rW   rq   )rq   rW   rJ   rV   rL   rN   r   r   r=   r=   r>   test_default_axis   s   

zTestFlip.test_default_axisc                 C   s   t ddgddggddgddggg}tt j|d	d
| t ddgddggddgddggg}tt j|dd
| t ddgddggddgddggg}tt j|dd
| d S )Nr   rN   rL   rV   rJ   rW   rq   rr   r=   rz   rR   rl   r   rd   re   r   cr=   r=   r>   test_multiple_axes   s0   


zTestFlip.test_multiple_axesN)ru   rv   rw   ro   r   r   r   r   r   r   r   r   r=   r=   r=   r>   ry   t   s    

ry   c                   @      e Zd Zdd Zdd ZdS )TestAnyc                 C   sH   g d}g d}g d}t t| t t| t t|  d S )Nr   r   rN   r   r   r   r   r   )rN   r   rN   r   )r   r7   anyrd   y1y2y3r=   r=   r>   rh      s   zTestAny.test_basicc                 C   sX   g dg dg dg}t t| ttj|ddg d ttj|ddg d d S )Nr   r   r   r   rN   r   rN   rN   r   r   rz   rN   r   rN   rN   )r   r7   r   r	   rd   r   r=   r=   r>   test_nd   s   zTestAny.test_ndNru   rv   rw   rh   r   r=   r=   r=   r>   r          r   c                   @   r   )TestAllc                 C   s`   g d}g d}g d}t t|  t t| t t|  t tt|  d S )N)r   rN   rN   r   r   rN   rN   rN   rN   )r   r7   allr   r   r=   r=   r>   rh      s   zTestAll.test_basicc                 C   sZ   g dg dg dg}t t|  ttj|ddg d ttj|ddg d d S )Nr   r   rN   r   rN   rN   rN   r   rz   rN   )r   r7   r   r	   r   r=   r=   r>   r      s   zTestAll.test_ndNr   r=   r=   r=   r>   r      s    	r   c                   @   rH   )TestCopyc                 C   sR   t ddgddgg}t |}t|| d|d< t|d d t|d d d S )NrN   rL   rV   rJ   
   )r   r   )r7   r   copyr	   r   )rd   re   a_copyr=   r=   r>   rh      s   

zTestCopy.test_basicc                 C   s   t 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 |}t|jj t|jj  t |}t|jj  t|jj d S )NrN   rL   rV   rJ   Forder)r7   r   r   flagsc_contiguousf_contiguousr   )rd   re   Za_fortr   Za_fort_copyr=   r=   r>   
test_order  s   

zTestCopy.test_orderc                 C   sV   t d}tt tj|dd  tt tj|dd tt t|  d S )NrW   F)ZsubokT)r   rb   r   ZisMaskedArrayr7   r   )rd   Zmxr=   r=   r>   
test_subok  s   
zTestCopy.test_subokN)ru   rv   rw   rh   r   r   r=   r=   r=   r>   r      s    r   c                   @   s   e Zd Zdd Zejdg dddgg ddgd	gfg d
g dgdg dgddgg dgg dgfgd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 g d}tt|dddk t g d}tt|dddk g d}tt|dddk t d}d|d	< d
|d< t|dt|d t|dt|d tdd}t|dt|d t|dt|d d S )Nr   r   rz          @      ?r         @)        r   r   r   r|   r^   rL   r_   rN   rW   )r7   r   r   r   rb   r
   meanr   )rd   r   r   r   Zy4Zy5r=   r=   r>   rh   #  s   

zTestAverage.test_basicz<x, axis, expected_avg, weights, expected_wavg, expected_wsumr   Nr   )rV   rJ   rN         ?       @)rN   rL   rW   )rN   rq      r   )r         @r   rN   rV   )r         @      #@rJ   rJ   rJ   c           
      C   s   t j||dd}|jt |ksJ t|| t j|||dd}|jt |ks*J t|| t j|||ddd\}}	|jt |ksEJ t|| |	jt |ksTJ t|	| d S )NTr{   keepdims)r{   weightsr   )r{   r   returnedr   )r7   r   rB   r	   )
rd   xr{   Zexpected_avgr   Zexpected_wavgZexpected_wsumavgZwavgZwsumr=   r=   r>   test_basic_keepdims5  s   



zTestAverage.test_basic_keepdimsc                 C   s  t d}t d}t||d}t dd  d t d  }t|| t g dg dg}ddg}t||dd	}t g d
}t|| g d}t||dd	}t ddg}t|| g dg dg}t ddg}tt||dd	| tt||dd td	t j
}	td	t j}
tt j|	|
djt |	|
k t g ddd}t g ddd}t j||ddd}t g d}t|| t j||ddd}t dgdgdgg}t|| d S )Nr   r   rL   r   r   r   rN   r   )r   r{   )r   r   r   r   r         @)r   r   rL   r   rW   rL   rV   rJ   rV   F)r   r{   r   )r   r   r   Tr   r   )r7   r8   r   sumr
   r   r	   r   r   astypefloat32float64r   dtyperesult_typers   )rd   ywactualZdesiredr   w0w1w2r   Zw3r   r=   r=   r>   test_weightsL  s:   

$


 
zTestAverage.test_weightsc                 C   s  t g dg dg}t|dd\}}t|d t|ddd\}}t|t g d t|ddd\}}t|t d	d	g dd
g}t||ddd\}}t|t g d g d}t||ddd\}}t|t ddg g dg dg}t||ddd\}}t|t ddg d S )Nr   r   T)r   r   r   )r   r   r   rN   r   rL   )r   r{   r   )r   r   r   r   r   )r7   r   r   r   r	   )rd   r   r   Zsclr   r   r   r=   r=   r>   test_returnedx  s    
zTestAverage.test_returnedc                 C   sz   G dd dt j}t ddgddgg|}t ddgddgg|}ttt || ttt j||d| d S )Nc                   @      e Zd ZdS )z-TestAverage.test_subclasses.<locals>.subclassNru   rv   rw   r=   r=   r=   r>   subclass      r   rN   rL   rV   rJ   r   )r7   ndarrayr   viewr   typer   )rd   r   re   r   r=   r=   r>   test_subclasses  s
   zTestAverage.test_subclassesc                 C   sl   g d}|D ]-\}}}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 | qd S )N))i4r   f8)r   f4r   )r   r   r   )r   r   r   )r   r   r   rN   rL   rV   rJ   r   r   )r7   r   r   r   r   )rd   Ztypsatwtrtre   r   r=   r=   r>   test_upcasting  s   zTestAverage.test_upcastingc                 C   sX   t dd tdD }t dd tdD }||  }t|dt||d d S )Nc                 S   s   g | ]}t |qS r=   decimalDecimal).0r   r=   r=   r>   
<listcomp>      z1TestAverage.test_object_dtype.<locals>.<listcomp>r   c                 S   s   g | ]}t d qS rN   r   )r   _r=   r=   r>   r     r   r   r   )r7   r   rc   r   r
   r   r   )rd   re   r   r=   r=   r>   test_object_dtype  s   zTestAverage.test_object_dtypec                 C   s4   t tddtddg}tt |tdd d S )NrN   rW   rV   rL   )r7   r   r   r   r   rn   r=   r=   r>    test_average_class_without_dtype  s   z,TestAverage.test_average_class_without_dtype)ru   rv   rw   rh   pytestmarkparametrizer   r   r   r   r   r   r   r=   r=   r=   r>   r   !  s"    
,	r   c                   @   s   e Zd Zeg deg deg dgZeg deg deg d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 )
TestSelectr   r   rr   rp   	   )FFFFTFFFTr   c                    s<   g }t t|D ] | fddt||D p|g7 }q|S )Nc                    s    g | ]\}}|  r|  qS r=   r=   )r   VCmr=   r>   r     s     z&TestSelect._select.<locals>.<listcomp>)rc   lenzip)rd   Zcondvaluesdefaultoutputr=   r  r>   _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  rV   )choices
conditionsr	   r-   r  r   r  rd   r  r  r=   r=   r>   rh     s   zTestSelect.test_basicc                 C   sd   t dt g dg}dt dddg}tt||t d ttdgdgdgd	jd
 d S )NTr  rN      rJ   rV   rJ   rV   r   r  r   )	r7   r   r8   rs   r	   r-   rb   r   rB   rd   r  r  r=   r=   r>   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dddtj	ddg}t
|}t t|g|gd	d	d	tj	d	d	g d S )
N              ?c                 S   s   g | ]}| tjqS r=   )r   r7   int8)r   choicer=   r=   r>   r         z0TestSelect.test_return_dtype.<locals>.<listcomp>rN   rL   rV   rW   rr   r   )r   r-   r  r  r   r7   rC   r  r   nanisnan)rd   r  dr  r=   r=   r>   test_return_dtype  s   
&zTestSelect.test_return_dtypec                 C   s"   t ttg g d t ttg g  d S )N              @)r   ra   r-   r   r=   r=   r>   test_deprecated_empty  s   z TestSelect.test_deprecated_emptyc                 C   sj   | j }| jd d  }|d tj|d< ttt|| |d tj|d< ttt|| ttt|| d S Nr   )	r  r  r   r7   int_r   	TypeErrorr-   uint8r  r=   r=   r>   test_non_bool_deprecation  s   z$TestSelect.test_non_bool_deprecationc                 C   s2   t dggd }t dggd }t|| d S )NFd   rN   )r7   r   r-   r  r=   r=   r>   test_many_arguments  s   zTestSelect.test_many_argumentsNr   )ru   rv   rw   r7   r   r  r  r  rh   r  r  r   r%  r'  r=   r=   r=   r>   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	e
jdddgdd ZdS )
TestInsertc                 C   sv  g d}t t|ddg d t t|ddg d t t|g dg dg d t t|dg dg d t t|g d	d
g d t t|tdd dd
g d t t|g dg dg d tjddgtjd}t t|d|d g d t t|g g | tjdd*}tddt	 t t|tdgd d
g d t
|d jt	u  W d    d S 1 sw   Y  d S )Nr   r   rN   )rN   rN   rL   rV   rV   )rN   rL   rV   rN   r   )rN   rN   rL   rV   rL   rV   )rN   r]   rV   r  )rN   r  rL   r  rV   r  r]   )r  rN   r  rL   r  rV   r]   rN   rV   r   )rN   rp   rL   rr   rV   r  r   r   r   r   Trecordalways rJ   )rN   r  r  r  r  rL   rV   )r   r%   slicer7   r   r   warningscatch_warningsfilterwarningsFutureWarningr   category)rd   re   r   r   r=   r=   r>   rh     s$   "zTestInsert.test_basicc              
   C   s~  g dg}g dg dg}t t|ddgg d t t|dg ddd| t t|dddd| t t|ddddg dg tddgddgd	d	gg}tdd
d	d	d	}tj|d d ddf tdd
d	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g ddd| t t|dg ddd| t t|ddgdgd	ggdd| td
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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|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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|d|d d dd d f ddt|d|d d dd d f dd d S )Nr   rK   r   rN   r   rz   rL   )rN   rN   rL   rN   rV   rJ   r      r   r]   rT   )r   r%   r7   r   r8   repeatrs   ZconcatenateTr   r~   )rd   re   rr   r   r=   r=   r>   test_multidim  sN   
,$"22" " ((" " zTestInsert.test_multidimc                 C   s   t d}tt j t|g ddd W d    n1 sw   Y  tt t|g ddd W d    d S 1 s<w   Y  d S )NrN   rL   r   rz   nonsense)r7   r   r   raisesr~   r%   r#  rn   r=   r=   r>   test_0d,  s   
"zTestInsert.test_0dc              	   C   s   G dd dt j}t d|}ttt |ddg| ttt |g g | ttt |ddgddg| ttt |tddddg| ttt |tdddg | t d|}ttt |ddg| d S )	Nc                   @   r   )z*TestInsert.test_subclass.<locals>.SubClassNr   r=   r=   r=   r>   SubClass4  r   r?  r   r   rN   rL   rT   r]   )	r7   r   r8   r   r   
isinstancer%   r0  r   rd   r?  re   r=   r=   r>   test_subclass3  s    " zTestInsert.test_subclassc                 C   s<   t g d}t g d|g d t|t g d d S )Nr   rM   rU   )r7   r   r%   r   rd   r   r=   r=   r>   test_index_array_copied@  s   z"TestInsert.test_index_array_copiedc                 C   s   t jg dddgd}d}t |d|}t|d t j||jd dgd }t |ddg|}t|ddg t j||jd d S )	N))rN   re   )rL   r   )rV   r   )foor   )bara1r   )rJ   r  r   rL   rV   )r7   r   r%   r	   r   )rd   re   valr   r=   r=   r>   test_structured_arrayE  s   

"z TestInsert.test_structured_arrayc                 C   s   t t tg dtddgddg W d    n1 s w   Y  t t tg dtjg tdg  W d    d S 1 sDw   Y  d S )NrM   r   r   r      r   )r   r=  
IndexErrorr7   r%   r   floatr   r=   r=   r>   test_index_floatsO  s   ""zTestInsert.test_index_floatsidxrJ   r7  c                 C   sL   t jtdd tg d|gddg W d    d S 1 sw   Y  d S )Nzout of boundsmatchrM   rV   rJ   )r   r=  rK  r7   r%   )rd   rN  r=   r=   r>   test_index_out_of_boundsU  s   "z#TestInsert.test_index_out_of_boundsN)ru   rv   rw   rh   r;  r>  rB  rD  rI  rM  r   r   r   rQ  r=   r=   r=   r>   r)    s    *
r)  c                   @      e Zd Zdd ZdS )TestAmaxc                 C   b   g d}t t|d g dg dg dg}t tj|ddg d t tj|d	dg d
 d S )NrV   rJ   rW   r   rZ   r         $@rV   r         "@rJ   rW  r   rp   r   r   r   rz   )r   rW  rY  rN   )rY  rW  r   )r   r7   Zamaxr   r=   r=   r>   rh   ]     zTestAmax.test_basicNru   rv   rw   rh   r=   r=   r=   r>   rS  [      rS  c                   @   rR  )TestAminc                 C   rT  )NrU  g      rX  rZ  r[  r   rz   )r   r   r   rN   )r   r   r   )r   r7   aminr   r=   r=   r>   rh   i  r\  zTestAmin.test_basicNr]  r=   r=   r=   r>   r_  g  r^  r_  c                   @   rR  )TestPtpc                 C   s   t g d}t|jddd t g dg dg dg}t|jddg d t|jd	dg d
 t|jdddg dg t|jddddgg d S )NrU  r   rz         .@rX  rZ  r[  )r         @rc  r]   )r   r   r   Tr   r^   r   )r7   r   r   Zptpr   r=   r=   r>   rh   u  s   
zTestPtp.test_basicNr]  r=   r=   r=   r>   ra  s  r^  ra  c                   @   rR  )
TestCumsumc              
   C   s   g d}g dg dg dg}t jt jt jt jt jt jt jt jt j	t j
f
D ]R}t ||}t ||}t g d|}tt j|dd| t g dg dg d	g|}tt j|dd| t g d
g dg dg|}tt j|dd| q%d S )NrN   rL   r   r   rq   rW   rJ   rN   rL   rV   rJ   rW   rq   rr   r  r   rV   rJ   rW   )rN   rV   r[   r6     #   '   r   rz   )rq   rp   r   r[   )   r         )rN   rV   rq   r   )rW   r   rn     )r   r[         rN   )r7   r  r$  int16uint16int32uint32r   r   	complex64
complex128r   r	   cumsum)rd   baba2ctypere   a2tgtr=   r=   r>   rh     s&   zTestCumsum.test_basicNr]  r=   r=   r=   r>   rd    r^  rd  c                   @   rR  )TestProdc                 C   s   g d}g dg dg dg}t jt jt jt jt jt jt jt jfD ]I}t 	||}t 	||}|dv rCt
tt j| t
tt j|d q!t|jddd	 t|jddt 	g d
| t|jddt 	g d| q!d S )Nre  rf  rg  rh  1r   rN   r   rz    g  ri   $   T      r]   )r6  b  X  )r7   rr  rs  rt  ru  r   r   rv  rw  r   r   ArithmeticErrorprodr   r	   rd   ry  rz  r{  re   r|  r=   r=   r>   rh     s$   zTestProd.test_basicNr]  r=   r=   r=   r>   r~    r^  r~  c                   @   rR  )TestCumprodc              	   C   s  g d}g dg dg dg}t jt jt jt jt jt jt jt jfD ]g}t 	||}t 	||}|dv rJt
tt j| t
tt j|d t
tt j| q!tt j|ddt 	g d	| tt j|d
dt 	g dg dg dg| tt j|ddt 	g dg dg dg| q!d S )Nre  rf  rg  rh  r  rN   r]   rz   )rN   rL   rJ     i(  i  r  r   )rW   r     r  r  )rN   rL   rq   r6  )rW   ri     r  )r   ri  r   r  )r7   rr  rs  rt  ru  r   r   rv  rw  r   r   r  Zcumprodr	   r  r=   r=   r>   rh     sB   


zTestCumprod.test_basicNr]  r=   r=   r=   r>   r    r^  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   g d}t g d}t g d}t ddg}tt|| tt|dd| tt|dd| g d	}t g d
}tt|| g d}t g d}t ddg}tt|| tt|dd| d S )N)rN   rJ   rq   rr   r  )rV   rL   rN   rW   )r]   r]   rJ   r   rW   rL   r;   rV   )皙?皙@r   gɿ皙)r  g?g	皙?)TTFFr  T)r7   r   r	   r   r
   )rd   r   outout2out3r=   r=   r>   rh     s   zTestDiff.test_basicc                 C   s   t d}d|d d dd dd d f< t d}d|d d dd dd d f< tt|t d tt|ddt d tt|ddt d	 tt|dd| tt|d
d| tt jt|dd tt jt|dd t dt j}tt	t| d S )N)r   rJ  ri  rN   rL   )r      ri  r]   )r   rJ     rz   r   )r  rJ  ri  rT   rV   r7  gq?)
r7   r@   rb   r	   r   r   r~   r   r   ra   )rd   r   expr=   r=   r>   	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 )NrJ  r   ri  rN   r]   rL   r  r   rz   )r;   r{   )r   r	   r   )rd   r   Zout1r  r  Zout4r=   r=   r>   r     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 u  tt||dd	D ])\}\}}tt|t	j
u  t|| t|jt	j tt|tdt |  q6d S )
NrV   r]   r  c                    s   g | ]}t  |d qS )r  )r   )r   r;   r   r=   r>   r     r  z#TestDiff.test_n.<locals>.<listcomp>rN   rW   r   start)listrc   r   ra   r   r   	enumerater	  r   r7   r   r	   r   r   r"  r  max)rd   r  expectedr;   r  r=   r  r>   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}|t jg ddgd  t|ddD ]\}}t||d	}t|| t|j	|j	 q-d S )
Nz
1066-10-13z
1066-10-16r   rN   timedelta64[D]r   rV   r  r  )
r7   r8   Z
datetime64r   extendr  r   r	   r   r   )rd   r   r  r;   r  r  r=   r=   r>   
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|u  t|dd}t|jg g g g g g t|jg g g g g g tt|t|u  d S )NrN   rL   rV   rJ   rW   rq   rr   rp   r  r   FTmaskr  )r   r   r   r	   r<   r  r   r   )rd   r   r  r  r=   r=   r>   rB    s   $ zTestDiff.test_subclassc                 C   sN  t dd }tt|ddt d tt|dgdt d tt t j|dd| tt|ddgdt d t d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 	d
d tt j
t|ddd d S )NrW   rN   r   )prependr]   rq   rJ   rL   )r{   r  rV   rV   rV   )r  r{   )r7   r8   r	   r   rb   rx  rs   r   ra   r@   r~   rd   r   resultr  r=   r=   r>   test_prepend  s$   



zTestDiff.test_prependc                 C   s<  t d}t|dd}g d}t|| t|dgd}t|| t|ddgd}|dg }t|| t d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 dd tt jt|ddd d S )NrW   r   )append)rN   rN   rN   rN   r7  rL   rJ   rN   )r{   r  r]   rZ   rT   r  rV   )r  r{   )	r7   r8   r   r	   rs   r   ra   r@   r~   r  r=   r=   r>   test_append7  s,   








zTestDiff.test_appendN)ru   rv   rw   rh   r  r   r  r  rB  r  r  r=   r=   r=   r>   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ejdedgdggdd Zdd ZdS )
TestDeletec                 C   s,   t d| _t ddddd| _d S )NrW   rL   rN   )r7   r8   re   r8  rs   nd_ar   r=   r=   r>   setup_methodV  s    zTestDelete.setup_methodc                 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 )NrN   rz   zDelete failed for obj: %r)err_msgr   )r   re   r  r	   r.   )rd   indicesa_delnd_a_delmsgxorr=   r=   r>   _check_inverse_of_slicingZ  s   $"z$TestDelete._check_inverse_of_slicingc                 C   sH   g d}g d}|D ]}|D ]}|D ]}t |||}| | qqq
d S )N)rT   r   rN   rL   rJ   rW   )rZ   r]   rN   rV   )r0  r  )rd   ZlimsZstepsr  stopstepsr=   r=   r>   test_slicesc  s   zTestDelete.test_slicesc                 C   sV  |  tddgddgg tt t| jdg W d    n1 s%w   Y  tt t| jdg W d    n1 sAw   Y  |  g d |  g d tt t| jd W d    n1 sjw   Y  tt t| jd	 W d    n1 sw   Y  tt t| jd	gd
  W d    d S 1 sw   Y  d S )Nr   rN   rL   r&  i)r   r]   rL   rL   )TFFTFTFrJ   )	r  r7   r   r   r=  rK  r   re   ra   r   r=   r=   r>   
test_fancyl  s$   "zTestDelete.test_fancyc                 C   s   |  d |  d d S )Nr   r7  )r  r   r=   r=   r>   test_single  s   
zTestDelete.test_singlec                 C   s   t d}tt j t|g dd W d    n1 sw   Y  tt t|g dd W d    d S 1 s:w   Y  d S )NrN   r   rz   r<  )r7   r   r   r=  r~   r   r#  rn   r=   r=   r>   r>    s   
"zTestDelete.test_0dc                 C   s   G dd dt 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                   @   r   )z*TestDelete.test_subclass.<locals>.SubClassNr   r=   r=   r=   r>   r?    r   r?  r   rN   rL   rT   )r7   r   re   r   r   r@  r   r0  rA  r=   r=   r>   rB    s   zTestDelete.test_subclassc                 C   sR   t 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   rL   rW   r   r   <   rN   rz   )	r7   r8   rs   r   r0  r   r   r   r   )rd   r\   r  r=   r=   r>   test_array_order_preserve  s   z$TestDelete.test_array_order_preservec                 C   s   t t tg dtddg W d    n1 sw   Y  t t tg dtjg td W d    d S 1 s@w   Y  d S )NrM   r   r   r   )r   r=  rK  r7   r   r   rL  r   r=   r=   r>   rM    s   "zTestDelete.test_index_floatsindexerrN   c                 C   sX   t | jd}t | j|}t|| t | jddd}t | jtdgdd}t|| d S )NrN   rz   )r   re   r   r  r7   r   )rd   r  Z	a_del_intr  Znd_a_del_intr  r=   r=   r>   test_single_item_array  s   
z!TestDelete.test_single_item_arrayc                 C   s$  t tdtdg}t|td td}tjdgtd}tjdgtd}t ||dd}t|| t ||dd}t||d d d df  tt t td	tjdgt	d W d    n1 sgw   Y  tt t td	tjdgd
d W d    d S 1 sw   Y  d S )NrN   F)rV   rN   r   Tr]   rz   r   rL   zm8[ns])
r   r7   rb   r   r	   boolr   r=  rK  object)rd   resr   Z
false_maskZ	true_maskr=   r=   r>   test_single_item_array_non_int  s   

"z)TestDelete.test_single_item_array_non_intN)ru   rv   rw   r  r  r  r  r  r>  rB  r  rM  r   r   r   r7   r   r  r  r=   r=   r=   r>   r  T  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dejejejejgdd Zejdejejejejgdd Zejdejejejejgdd Zejdejejejejgdd  Zd!d" Zd#S )$TestGradientc                 C   sf   ddgddgg}t |}t ddgddggt ddgddggg}tt|| tt|| d S )NrN   rV   rJ   r   r   r   r   )r7   r   r	   r!   rd   vr   dxr=   r=   r>   rh     s   
zTestGradient.test_basicc              	   C   s   t t d}g d}t ddd}tt dd tt dt d tt d| t|d t|t d t||| t||d t||dd ttd	t|t j	|gd d
dd d S )NrW   )r   r   r   rY        &@   r         ?rL   rN   rz   z.*scalars or 1dr]   )
r7   rx  rb   r8   rs   r!   r   r   ra   stack)rd   r  Z	dx_unevenf_2dr=   r=   r>   	test_args  s   
zTestGradient.test_argsc                 C   s   t ddd}t t d}ttt||t d ttt|dt d ttt|t dt 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 )Nr  rW   rL   rN   r^   rz   )	r7   r8   rs   rx  rb   r   ra   r!   r#  )rd   r  r   r=   r=   r>   test_badargs  s   zTestGradient.test_badargsc                 C   sJ   t jg ddd}t jg ddd}tt|| t|jt dk d S )N)z
1910-08-16z
1910-08-11z
1910-08-10z
1910-08-12z
1910-10-12z
1910-12-12z
1912-12-12zdatetime64[D]r   )rV  rZ   r      =   i  i  r  r7   r   r	   r!   r   r   rd   r   r  r=   r=   r>   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u t jd}t jj	|d< t j|dd	 t
|jg d
 d S )NrN   rV   rJ   Fr  r   rW   rL   
edge_order)FFTFF)r7   r   r   r!   r   r   r   Z_maskr8   maskedr	   r  )rd   r   r  x2r=   r=   r>   test_masked  s   zTestGradient.test_maskedc                 C   s  t ddd}|d |d  }d|d  d|d   d|  }d|d  d|  d }t t j||dd	| d }tt |d
k dk t jd t t jd}d|d  d|d   d|  }d|d  d|  d }t t j||dd	| d }tt |d
k dk d S )Nr   rN   r   rL   rV   rJ   rq   rp   r  gQ?T)	r7   linspaceabsr!   r   r   randomseedsort)rd   r   r  r   Z
analyticalZ	num_errorr=   r=   r>   test_second_order_accurate  s     z'TestGradient.test_second_order_accuratec                 C   s  t g d}t |d|dd }t g d}t d}t g dd}t g dd}t g d	d}t g d
d}d|fd|ffD ]r\}}	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||	 qGd|fd|ffD ]E\}}	t|||d|d}
t|||d |d}t|
| t|
d |	j t|
d |	 t||d|d}
t|
|	j t||d|d}
t|
|	 qt|||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 )N)r   r   r   r   r   r   )rq   rN   r]   rN   )r         ?r   r   r   rc  r   )r   r  r   r   r  r   )      @r  r   r   r        )r   r   333333?r        ?r   )r   r   r  r  r  g      пrL   r   r^   )r{   r  r   r_   )r7   r   Ztilers   r8   r!   r	   r
   r9  r   rB   )rd   fZx_unevenZx_evenZfdx_even_ord1Zfdx_even_ord2Zfdx_uneven_ord1Zfdx_uneven_ord2r  Zexp_resres1res2res3r=   r=   r>   test_spacing+  sl   



zTestGradient.test_spacingc                 C   s@  ddgddgg}t |}t ddgddggt 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 )NrN   rV   rJ   r   r   r   r   r   rz   r]   r_   rL   rZ   )r7   r   r	   r!   r
   r   r#  r~   r  r=   r=   r>   test_specific_axesk  s"   
zTestGradient.test_specific_axesc                 C   sJ   t jg ddd}t jg ddd}tt|| t|jt dk d S )N)rV  rZ   r   r  r  iA  ,  r  r   )rL   rr   rr   r     w   ir  r  r=   r=   r>   test_timedelta64  s   zTestGradient.test_timedelta64c                 C   sD   t jt jt jfD ]}t jg d|d}tt|jt |j qd S )Nr   r   )	r7   float16r   r   r   r   r!   r   r   )rd   dtr   r=   r=   r>   test_inexact_dtypes  s   z TestGradient.test_inexact_dtypesc                 C   s   t tddd t tddd ttt tddd ttt tddd ttt tddd ttt tddd ttt tddd d S )NrL   rN   r  rV   r   )r!   r7   r8   r   ra   r   r=   r=   r>   test_values  s   zTestGradient.test_valuesf_dtypec                 C   s2   t jg d|d}t|}t|dgt|  d S )N)rW   rJ   rV   rL   rN   r   r]   r7   r   r!   r	   r  )rd   r  r  gr=   r=   r>   test_f_decreasing_unsigned_int  s   z+TestGradient.test_f_decreasing_unsigned_intc                 C   sR   t |j}t ddg}t jd|g|d}t||}t||d d gd  d S )NrN   rV   r]   r   rL   )r7   iinfor  r   r!   r	   )rd   r  maxintr   r  dfdxr=   r=   r>   test_f_signed_int_big_jump  s
   
z'TestGradient.test_f_signed_int_big_jumpx_dtypec                 C   sB   t jg d|d}t g d}t||}t|dgt|  d S )Nr   r   r   rL   rJ   rT   r  )rd   r  r   r  r  r=   r=   r>   test_x_decreasing_unsigned  s   
z'TestGradient.test_x_decreasing_unsignedc                 C   sX   t |j}t |j}t jd|g|d}t |d dg}t||}t|ddg d S )Nr]   r   rL   r   r  )r7   r  minr  r   r!   r	   )rd   r  Zminintr  r   r  r  r=   r=   r>   test_x_signed_int_big_jump  s   
z'TestGradient.test_x_signed_int_big_jumpc                 C   sF   t ddgddgf}t  rt|tu sJ d S t|tu s!J d S )NrN   rL   rV   )r7   r!   Z_using_numpy2_behaviorr   tupler  rd   r  r=   r=   r>   test_return_type  s   zTestGradient.test_return_typeN)ru   rv   rw   rh   r  r  r  r  r  r  r  r  r  r  r   r   r   r7   r$  rs  ru  Zuint64r  r  rr  rt  Zint64r  r  r  r  r=   r=   r=   r>   r    s:    @



r  c                   @   r   )	TestAnglec                 C   s   dt dd dt d d  dddddd	g}t|}t d
t ddt jd t jt j d t d
 t jt d
 g}t|dd}t |d t j }t||d t||d d S )N      ?      @rL   r   r  rN   r]                      ?      y            @r   r   r   T)degr  r   )r7   sqrtr   arctanpir   r   )rd   r   r   ZyozZzor=   r=   r>   rh     s     zTestAngle.test_basicc                 C   s   t jddt dd d g}t jj|d< t jt ddt dg}t jj|d< t|}tt|t| t|j	|j	 t|| d S )Nr  rN   rL         ?      ?r   r   r   )
r7   r   r   r  r  r  r   r   r   r  )rd   r   r  r   r=   r=   r>   rB    s    zTestAngle.test_subclassN)ru   rv   rw   rh   rB  r=   r=   r=   r>   r        r  c                	   @   s   e Zd Zeg dZeeZee	Z
eeZdd Zdd Zdd Zdd	 Zd
d Zdd Zejdeg deg deg dgdd Zdd Zdd ZdS )TestTrimZeros)r   r   rN   r   rL   rV   rJ   r   c                    s   d} fdd|D S )N)re   r   r   r  c                 3   s    | ]}t  |V  qd S r6   )getattr)r   namer   r=   r>   	<genexpr>      z'TestTrimZeros.values.<locals>.<genexpr>r=   )rd   
attr_namesr=   r   r>   r
    s   zTestTrimZeros.valuesc                 C   s6   t jdd }|  D ]}t|}t|||  qd S )NrL   r]   r7   s_r
  r1   r	   rd   slcarrr  r=   r=   r>   rh     s
   zTestTrimZeros.test_basicc                 C   s:   t jd d }|  D ]}t|dd}t|||  qd S )Nr]   r   Ztrimr  r  r=   r=   r>   test_leading_skip  
   zTestTrimZeros.test_leading_skipc                 C   s:   t jdd  }|  D ]}t|dd}t|||  qd S )NrL   r   r  r  r  r=   r=   r>   test_trailing_skip  r  z TestTrimZeros.test_trailing_skipc                 C   sZ   |   D ]&}tj||jd}t|dd}t|dksJ t|dd}t|dks*J qd S )Nr   Br  r   r  )r
  r7   Z
zeros_liker   r1   r  )rd   Z_arrr  r  r  r=   r=   r>   test_all_zero  s   zTestTrimZeros.test_all_zeroc                 C   s    t d}t|}t|| d S r!  )r7   r@   r1   r	   rd   r  r  r=   r=   r>   test_size_zero  s   
zTestTrimZeros.test_size_zeror  )r   l            r   )r   l            r   )r   l            r   c                 C   s(   t jdd }t|}t|||  d S )NrN   rL   )r7   r  r1   r	   )rd   r  r  r  r=   r=   r>   test_overflow  s   zTestTrimZeros.test_overflowc                 C   s$   t g d}t|}t|| d S )N)NrN   N)r7   r   r1   r	   r#  r=   r=   r>   test_no_trim  s   zTestTrimZeros.test_no_trimc                 C   s    t | j }t|tsJ d S r6   )r1   re   tolistr@  r  r  r=   r=   r>   test_list_to_list"  s   zTestTrimZeros.test_list_to_listN)ru   rv   rw   r7   r   re   r   rL  r   complexr   r  r  r
  rh   r  r   r"  r$  r   r   r   r%  r&  r(  r=   r=   r=   r>   r    s*    




r  c                   @   rH   )
TestExtinsc                 C   s.   t g d}t|dk|}t|g d d S )N)rN   rV   rL   rN   rL   rV   rV   rN   )rV   rL   rL   rV   rV   )r7   r   r   r	   r   r=   r=   r>   rh   )  s   zTestExtins.test_basicc                    s   t ttg dddgddg tg d t g dg d t g d	 t td
g  t tdd t g dddg t g d tt	d fdd tddg t ddgd t ddg d S )Nr   TFr   rN   )rN   rJ   rV   rL   rW   rp   rr   )r   rN   r   rN   r   rN   r   rL   rJ   rq   )rN   rL   rV   rJ   rW   rq   rr   rr   rp   )rN   r   rN   r   rN   r   rN   r  )rp   rL   r  rJ   rp   rq   r  z!Cannot insert from an empty arrayc                      s   t  g dg S )N)r   r   r   r   r   rN   r   )r+   r=   re   r=   r>   <lambda>=  s    z'TestExtins.test_place.<locals>.<lambda>Z12Z349)
r   r#  r+   r7   r   r	   r@   r8   r   ra   r   r=   r,  r>   
test_place.  s   
zTestExtins.test_placec                 C   sH   t d}|dk}| }t||}t||d t||| t|| d S )Nr   r  r   )r   r   r   r+   r	   )rd   re   r  acr   r=   r=   r>   	test_bothD  s   
zTestExtins.test_bothN)ru   rv   rw   rh   r/  r1  r=   r=   r=   r>   r*  '  s    r*  r   c                 C   s   |t |  S r6   mathfloorr   r   r=   r=   r>   _foo1P     r6  r   c                 C   s   |t |  | S r6   r2  )r   r   r  r=   r=   r>   _foo2T  s   r8  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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$dEdF Z%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWS )XTestVectorizec                 C   s4   dd }t |}|g dg d}t|g d d S )Nc                 S      | |kr| | S | | S r6   r=   re   r   r=   r=   r>   addsubtract[     z.TestVectorize.test_simple.<locals>.addsubtractr   rV   rq   r  rN   rV   rW   rr   rN   rq   rN   rL   r4   r	   rd   r<  r  r:  r=   r=   r>   test_simpleZ  s   zTestVectorize.test_simplec                 C   s0   dd }t |}|g dd}t|g d d S )Nc                 S   r:  r6   r=   r;  r=   r=   r>   r<  f  r=  z.TestVectorize.test_scalar.<locals>.addsubtractr>  rW   )rW   rp   rN   rJ   rA  rB  r=   r=   r>   test_scalare  s   zTestVectorize.test_scalarc                 C   s0   t ddd}tdd }||}t|| d S )NrZ   rL   i'  c                 S      | S r6   r=   r  r=   r=   r>   r-  r      z*TestVectorize.test_large.<locals>.<lambda>)r7   r  r4   r	   )rd   r   r  r   r=   r=   r>   
test_largep  s   zTestVectorize.test_largec                 C   sR   t tj}tddtj tjdtj dtj g}||}t|}t|| d S )Nr   r  r  rL   )r4   r3  cosr7   r   r  r   )rd   r  argsr1r2r=   r=   r>   
test_ufuncv  s
   
(
zTestVectorize.test_ufuncc                 C   sf   ddd}t |}tg d}||}tg d}t|| ||d}tg d}t|| d S )	NrN   c                 S      | | S r6   r=   r;  r=   r=   r>   rE       z(TestVectorize.test_keywords.<locals>.foor   r   rL   rU   r   r4   r7   r   r	   rd   rE  r  rI  rJ  rK  r=   r=   r>   test_keywords}  s   


zTestVectorize.test_keywordsc                 C   s:   t ttgd}|tdd}|td}t|| d S Notypesr   r   r4   r6  rL  r7   r8   r	   rd   r  rJ  rK  r=   r=   r>    test_keywords_with_otypes_order1  s   z.TestVectorize.test_keywords_with_otypes_order1c                 C   s:   t ttgd}|td}|tdd}t|| d S rR  rU  rV  r=   r=   r>    test_keywords_with_otypes_order2  s   z.TestVectorize.test_keywords_with_otypes_order2c                 C   sT   t ttgd}|td}|tddd}|td}t|| t|| d S )NrS  r   r   r   rU  rd   r  rJ  rK  Zr3r=   r=   r>    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 )NrS  $@r&  )r  r]   rY  r4   r8  rL  r   rZ  r=   r=   r>   +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 )	NrS  r&  r\  r]   )r  r   r   rN   rL   rV   r]  rV  r=   r=   r>   +test_keywords_with_otypes_several_kwd_args2  s
   z9TestVectorize.test_keywords_with_otypes_several_kwd_args2c                 C   s.   dd l }zt|j W d S  ty   t w r!  )r  r4   	randrange	ExceptionAssertionError)rd   r  r=   r=   r>   test_keywords_no_func_code  s   z(TestVectorize.test_keywords_no_func_codec                 C   s   ddd}t |}tg d}||d}tg d}t|| |d|d}t|| ||dd	}tg d
}t|| d S )NrN   c                 S   rM  r6   r=   r;  r=   r=   r>   rE    rN  z5TestVectorize.test_keywords2_ticket_2100.<locals>.foor   r,  r   )r   re   rL   r   rU   r   rO  rP  r=   r=   r>   test_keywords2_ticket_2100  s   



z(TestVectorize.test_keywords2_ticket_2100c                 C   sr   dd }t j|ddgd}ddg}t||ddgg d	d
 t||ddgg d	d t||ddgg d	 d S )Nc                 S   s0   t |}|d}|r||  |d }|s|S r!  )r  pop)r   p_pr  r=   r=   r>   	mypolyval  s   
z;TestVectorize.test_keywords3_ticket_2100.<locals>.mypolyvalrg  rN   )excludedrV   rq   r   r   )r   rg  )rg  )r7   r4   r	   )rd   ri  ZvpolyvalZansr=   r=   r>   test_keywords3_ticket_2100  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}| D ]}|| | 9 }q|S Nr   r=   )kwr  Z_kr=   r=   r>   r    s   z3TestVectorize.test_keywords4_ticket_2100.<locals>.frN   rL   rV   rJ   r;  rp   rA  rd   r  r=   r=   r>   test_keywords4_ticket_2100  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   
   t | S r6   )r7   r  )r  r=   r=   r>   r    s   
z3TestVectorize.test_keywords5_ticket_2100.<locals>.frN   rL   rV   rJ   rp   rA  rn  r=   r=   r>   test_keywords5_ticket_2100  s   
 z(TestVectorize.test_keywords5_ticket_2100c                 C   s    dd }t |}t| d d S )Nc                   S      dS NrN   r=   r=   r=   r=   r>   rE       z5TestVectorize.test_coverage1_ticket_2100.<locals>.foorN   rA  rd   rE  r  r=   r=   r>   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   rE  )zOriginal documentationr=   r  r=   r=   r>   rE  	     z3TestVectorize.test_assigning_docstring.<locals>.foozProvided documentation)doc)r4   r   __doc__)rd   rE  r  rx  r=   r=   r>   test_assigning_docstring  s   z&TestVectorize.test_assigning_docstringc                 C   s`   G dd d}t t| jtdtdd  t t|j| tdtdd  d S )Nc                   @   s   e Zd ZdZdd ZdS )z9TestVectorize.test_UnboundMethod_ticket_1156.<locals>.FoorL   c                 S   s
   || j  S r6   rd  rn   r=   r=   r>   rF    s   
z=TestVectorize.test_UnboundMethod_ticket_1156.<locals>.Foo.barN)ru   rv   rw   r   rF  r=   r=   r=   r>   Foo  s    r{  r  rL   )r	   r4   rF  r7   r8   )rd   r{  r=   r=   r>   test_UnboundMethod_ticket_1156  s   z,TestVectorize.test_UnboundMethod_ticket_1156c                 C   sl   t dd }|td}|tdd}t dd }|tdd}|td}t|| t|| d S )Nc                 S   rE  r6   r=   r  r=   r=   r>   r-  #  rF  z@TestVectorize.test_execution_order_ticket_1487.<locals>.<lambda>rV   r  c                 S   rE  r6   r=   r  r=   r=   r>   r-  &  rF  )r4   r7   r8   r   )rd   f1Zres1aZres1bf2Zres2bZres2ar=   r=   r>    test_execution_order_ticket_1487!  s   
z.TestVectorize.test_execution_order_ticket_1487c                 C   s$   t dd }d}t||| d S )Nc                 S   rE  r6   r=   r  r=   r=   r>   r-  .  rF  z7TestVectorize.test_string_ticket_1892.<locals>.<lambda>Zd0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789)r7   r4   r   )rd   r  r  r=   r=   r>   test_string_ticket_1892,  s   z%TestVectorize.test_string_ticket_1892c                    sN   dg t  fdd}d|_td}t||||  t d t| d S )Nr   c                    s    d  d7  < | d S )Nr   rN   rL   r=   r  Z_callsr=   r>   r  6  s   z#TestVectorize.test_cache.<locals>.fTrW   )r4   cacher7   r8   r	   r   r  rd   r  r   r=   r  r>   
test_cache2  s   
zTestVectorize.test_cachec                 C   s0   t dd }d|_t d}t||| d S )Nc                 S   rE  r6   r=   r  r=   r=   r>   r-  A  rF  z+TestVectorize.test_otypes.<locals>.<lambda>r   rW   )r7   r4   rT  r8   r	   r  r=   r=   r>   test_otypes@  s   
zTestVectorize.test_otypesc                 C   s  t tddgdgf t tddgdgf t tdddgdgf t tddgdgf t td	dgddgf t td
g ddgf t tddgdgf t tddgdgf t tdddgdgf t tddgdgf t tddgddgf t tdg ddgf tt td W d    n1 sw   Y  tt td W d    n1 sw   Y  tt td W d    d S 1 sw   Y  d S )Nz(x)->()r  r=   z	(x,y)->()r5  z(x),(y)->()rY  z(x)->(y)z(x)->(y),()z(),(a,b,c),(d)->(d,e))r=   )re   r   r   )r  )r  ez(x )->()z( x , y )->(  )z(x),( y) ->()z(  x)-> (y )  z (x)->( y),( )z*(  ), ( a,  b,c )  ,(  d)   ->   (d  ,  e)z
(x)(y)->()z	(x),(y)->z
((x))->(x))r   nfbZ_parse_gufunc_signaturer   ra   r   r=   r=   r>   test_parse_gufunc_signatureF  sV   















"z)TestVectorize.test_parse_gufunc_signaturec                 C   s8   dd }t |dd}|g dg d}t|g d d S )Nc                 S   r:  r6   r=   r;  r=   r=   r>   r<  i  r=  z8TestVectorize.test_signature_simple.<locals>.addsubtractz	(),()->()	signaturer>  r?  r@  rA  rB  r=   r=   r>   test_signature_simpleh  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   |   S r6   r   r,  r=   r=   r>   r   t  rN  z4TestVectorize.test_signature_mean_last.<locals>.meanz(n)->()r  rN   rV   rL   rJ   rA  )rd   r   r  r:  r=   r=   r>   test_signature_mean_lasts  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   | |    S r6   r  r,  r=   r=   r>   center|  s   z3TestVectorize.test_signature_center.<locals>.center(n)->(n)r  rN   rV   rL   rJ   r]   rA  )rd   r  r  r:  r=   r=   r>   test_signature_center{  s   z#TestVectorize.test_signature_centerc                 C   s^   t dd dd}|g d}tt|tot|dk t|d g d t|d g d d S )	Nc                 S      | | fS r6   r=   r  r=   r=   r>   r-        z:TestVectorize.test_signature_two_outputs.<locals>.<lambda>	()->(),()r  r   rL   r   rN   )r4   r   r@  r  r  r	   rd   r  r:  r=   r=   r>   test_signature_two_outputs  s
   z(TestVectorize.test_signature_two_outputsc                 C   s   t tjdd}|ddgg d}t|g dg dg |ddgggg d}t|g dg dggg |ddgddggg d}t|g dg dgg dg dgg |ddgg dg dg}t|g dg dgg dg dgg d S )	Nz(a),(b)->(a,b)r  rN   rL   r   r+  r   r   )r4   r7   r:   r	   r  r=   r=   r>   test_signature_outer  s   
z"TestVectorize.test_signature_outerc                 C   sX   t dd dd}|g d}t|ddg |g dg dg}t|ddgdd	gg d S )
Nc                 S      | d d S Nr]   r=   r  r=   r=   r>   r-        z<TestVectorize.test_signature_computed_size.<locals>.<lambda>z(n)->(m)r  r   rN   rL   r   rV   rA  r  r=   r=   r>   test_signature_computed_size  s
   z*TestVectorize.test_signature_computed_sizec                 C   sN   ddd}t |ddhd}t|g dg d t|g dd	d
g d d S )NrN   c                 S   rM  r6   r=   r;  r=   r=   r>   rE    rN  z2TestVectorize.test_signature_excluded.<locals>.foo()->()r   )r  rj  r   r   r   rd  r   rA  ru  r=   r=   r>   test_signature_excluded  s   
z%TestVectorize.test_signature_excludedc                 C   sD   t dd ddgd}|g d}t|jtd t|g d d S )Nc                 S   rE  r6   r=   r  r=   r=   r>   r-    rF  z5TestVectorize.test_signature_otypes.<locals>.<lambda>r  r   r  rT  r   )r4   r   r   r7   r	   r  r=   r=   r>   test_signature_otypes  s   z#TestVectorize.test_signature_otypesc                 C   s   t tjdd}ttd |ddg W d    n1 sw   Y  ttd |dd W d    n1 s7w   Y  ttd |ddgg d W d    n1 sUw   Y  t tjd	d}ttd |dd W d    d S 1 sww   Y  d S )
Nz(n),(n)->(n)r  zwrong number of positionalrN   rL   zdoes not have enough dimensions$inconsistent size for core dimensionr   r  )r4   operatorr9   r   r#  ra   rn  r=   r=   r>   test_signature_invalid_inputs  s$   "z+TestVectorize.test_signature_invalid_inputsc                 C   s   t dd dd}ttd |g d W d    n1 sw   Y  t dd dd}ttd	 |d
 W d    n1 s?w   Y  t dd dd}ttd	 |d
dg W d    d S 1 scw   Y  d S )Nc                 S   r  r  r=   r  r=   r=   r>   r-    r  z>TestVectorize.test_signature_invalid_outputs.<locals>.<lambda>r  r  r  r   c                 S   rE  r6   r=   r  r=   r=   r>   r-    rF  r  zwrong number of outputsrN   c                 S   r  r6   r=   r  r=   r=   r>   r-    r  r  rL   )r4   r   ra   rn  r=   r=   r>   test_signature_invalid_outputs  s   
"z,TestVectorize.test_signature_invalid_outputsc                 C   s^  t dd }t jddgtd}ttd || W d    n1 s$w   Y  d|_t||| t jdd d	d
}ttd || W d    n1 sPw   Y  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    d S 1 sw   Y  d S )Nc                 S   rE  r6   r=   r  r=   r=   r>   r-    rF  z5TestVectorize.test_size_zero_output.<locals>.<lambda>r   rW   r   rT  r   c                 S   rE  r6   r=   r  r=   r=   r>   r-    rF  r  r  c                 S   rE  r6   r=   r  r=   r=   r>   r-    rF  r  c                 S   rE  r6   r=   r  r=   r=   r>   r-    rF  r  c                 S   rE  r6   r=   r  r=   r=   r>   r-    rF  c                 S   s   | gS r6   r=   r  r=   r=   r>   r-    s    z()->(n)znew output dimensions)	r7   r4   r@   intr   ra   rT  r	   r9  r  r=   r=   r>   test_size_zero_output  s*   


"z#TestVectorize.test_size_zero_outputc                 C   s   G dd dt j}t g dg dg dg|}t g dg dg dg|}t jt jd	d
}|||}tt|| t|g dg dg dg t dd }|||}tt|| t|||  d S )Nc                   @   r   )z/TestVectorize.test_subclasses.<locals>.subclassNr   r=   r=   r=   r>   r     r   r   )r   r   r   r+  )r   r   r   r   )r   r   r   )rc  r   rY  z(m,m),(m)->(m)r  )r   r   r   )r   r   r   )rc  rY  r   c                 S   s   | | S r6   r=   r5  r=   r=   r>   r-    r  z/TestVectorize.test_subclasses.<locals>.<lambda>)r7   r   r   r   r4   matmulr   r   )rd   r   r  r  Zmatvecr:  Zmultr=   r=   r>   r     s    
"

zTestVectorize.test_subclassesc                 C   s    t jdd }|jdksJ d S )Nc                 S   rM  r6   r=   r;  r=   r=   r>   r~     s   z#TestVectorize.test_name.<locals>.f2r~  )r7   r4   ru   )rd   r~  r=   r=   r>   	test_name  s   
zTestVectorize.test_namec                 C   s0   t dd }|g dg d}t|g d d S )Nc                 S   r:  r6   r=   r;  r=   r=   r>   r<    s   z1TestVectorize.test_decorator.<locals>.addsubtractr>  r?  r@  rA  )rd   r<  r:  r=   r=   r>   test_decorator  s   
zTestVectorize.test_decoratorc                 C   s.   t dd }tjjdk r|jdksJ d S d S )Nc                 S   rE  )	Docstringr=   r  r=   r=   r>   r    s   z'TestVectorize.test_docstring.<locals>.frL   r  )r4   sysr   optimizery  rn  r=   r=   r>   test_docstring  s   
zTestVectorize.test_docstringc                 C   s0   dd }t |d}t|}|ddksJ d S )Nc                 S   rM  r6   r=   r5  r=   r=   r>   rE    rN  z'TestVectorize.test_partial.<locals>.foorV   rN   rJ   )r   r7   r4   )rd   rE  rF  Zvbarr=   r=   r>   test_partial  s   

zTestVectorize.test_partialc                 C   sT   t ddgddd }|g d}t|jtd t|g d |jdks(J d S )Nr  r   r  c                 S   rE  r6   r=   r  r=   r=   r>   r  #  rw  z8TestVectorize.test_signature_otypes_decorator.<locals>.fr   r  )r4   r   r   r7   r	   ru   r  r=   r=   r>   test_signature_otypes_decorator"  s   
z-TestVectorize.test_signature_otypes_decoratorc                 C   s:   t t tjdd}W d    d S 1 sw   Y  d S )NrV   )Zpyfuncr   r#  r7   r4   rd   Ar=   r=   r>   test_bad_input,  s   
"zTestVectorize.test_bad_inputc                 C   s@   t t tddd }W d    d S 1 sw   Y  d S )Nstringc                   S   rr  )NrF  r=   r=   r=   r=   r>   rE  2  rw  z+TestVectorize.test_no_keywords.<locals>.foor  )rd   rE  r=   r=   r>   test_no_keywords0  s   
"zTestVectorize.test_no_keywordsc                 C   s0   t dd dg}|dg}t|jtd d S )Nc                 S   rE  r6   r=   r  r=   r=   r>   r-  :  rF  z?TestVectorize.test_positional_regression_9477.<locals>.<lambda>r   rL   )r4   r   r   r7   r  r=   r=   r>   test_positional_regression_94776  s   
z-TestVectorize.test_positional_regression_9477N).ru   rv   rw   rC  rD  rG  rL  rQ  rW  rX  r[  r^  r_  rc  re  rk  ro  rq  rv  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  r  r  r=   r=   r=   r>   r9  X  sX    

"		
r9  c                   @   sL   e Zd ZG dd dZejje dde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.ArJ  c                 G   rr  r!  r=   rd   rI  r=   r=   r>   boundC  rt  zTestLeaks.A.boundc                  G   rr  r!  r=   )rI  r=   r=   r>   unboundF  rw  zTestLeaks.A.unboundN)ru   rv   rw   itersr  staticmethodr  r=   r=   r=   r>   r  @  s
    r  Python lacks refcountsreasonz
name, incrr  )r  r   c           	      C   s   dd l }t| j|}|  zKt|}t| jjD ]}|  }t	t||dd|_
|
td}qd }tt|||  tdD ]}|  qDtt|| W |  d S |  w )Nr   rN   r   rW   )gcr  r  disabler  getrefcountrc   r  r7   Z
frompyfuncr  r8   r   Zcollectenable)	rd   r  incrr  ZA_funcrefcountr   re   r  r=   r=   r>   test_frompyfunc_leaksJ  s   

zTestLeaks.test_frompyfunc_leaksN)ru   rv   rw   r  r   r   skipifr   r   r  r  r=   r=   r=   r>   r  ?  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 dd}t dd}tt||t d d S )Nr  rW   rV  r   r7   r8   r	   r   rd   r   binsr=   r=   r>   test_forwardj  s   zTestDigitize.test_forwardc                 C   s6   t ddd}t ddd}tt||t d d S )NrW   r  r]   rV  r   r  r  r=   r=   r>   test_reverseo  s   zTestDigitize.test_reversec                 C   s:   t d}t| | d}ttt||dk d S )Nr   r   r   r7   r  r  r  r   r   r   )rd   r   binr=   r=   r>   test_randomt  s   zTestDigitize.test_randomc                 C   sF   g d}g d}g d}t t||| g d}t t||d| d S )N)rN   rW   rJ   r   rp   r   r   )rN   rW   r   )rN   rL   rN   rV   rL   rV   r   )r   rN   rN   rL   rL   rV   r   T)r	   r   )rd   r   r  Zdefault_answerZright_answerr=   r=   r>   test_right_basicy  s   zTestDigitize.test_right_basicc                 C   s4   t dd}t dd}tt||dt d d S )Nr  rW   rJ   Tr   r  r  r=   r=   r>   test_right_open  s   zTestDigitize.test_right_openc                 C   s8   t ddd}t ddd}tt||dt d d S )NrW   r  r]   rJ   Tr   r  r  r=   r=   r>   test_right_open_reverse  s   z$TestDigitize.test_right_open_reversec                 C   s<   t d}t| | d}ttt||ddk d S )Nr   Tr  r  r=   r=   r>   test_right_open_random  s   z#TestDigitize.test_right_open_randomc                 C   s   g d}g d}t t||dg d t t||dg d g d}t t||dg d t t||dg d	 g d
}t t||dg d t t||dg d g d}ttt|| g d}ttt|| d S )N)r]   r   rN   rL   r   F)r   rL   rV   rV   T)r   r   rL   rV   r   )rV   rL   r   r   )rV   rV   rL   r   r   )r   r   rJ   rJ   )r   r   r   rJ   r   )rN   rN   r   rN   )r	   r   r   ra   r  r=   r=   r>   test_monotonic  s   zTestDigitize.test_monotonicc                 C   s:   g d}g d}t tt|| ||}}t tt|| d S )N)rN   rL   y      @      ?r   )r   r#  r   r  r=   r=   r>   test_casting_error  s
   
zTestDigitize.test_casting_errorc                 C   sh   G dd dt j}t d|}t dd|}ttt||d|  ttt||d|  d S )Nc                   @   r   )z(TestDigitize.test_return_type.<locals>.ANr   r=   r=   r=   r>   r    r   r  rW   rN   rV   FT)r7   r   r8   r   r   r@  r   )rd   r  re   r   r=   r=   r>   r    s
   zTestDigitize.test_return_typec                 C   s&   d}t t||d |d gd d S Nl          rN   r   r7   r   rC  r=   r=   r>   test_large_integers_increasing  s   "z+TestDigitize.test_large_integers_increasingz8gh-11022: np.core.multiarray._monoticity loses precisionr  c                 C   s&   d}t t||d |d gd d S r  r  rC  r=   r=   r>   test_large_integers_decreasing  s   "z+TestDigitize.test_large_integers_decreasingN)ru   rv   rw   r  r  r  r  r  r  r  r  r  r  r  r   r   xfailr  r=   r=   r=   r>   r  h  s     	r  c                   @   r   )
TestUnwrapc                 C   sH   t tdddtj  gddg tttttdd tjk  d S )NrN   rL   r   r&  )r	   r2   r7   r  r   r   r   r   r   r=   r=   r>   rC    s    (zTestUnwrap.test_simplec                 C   s   t tddgddddg tttttdd dddk  tg d}t|d}t t|dd| tg d	}t|d
}t|d
d}t |g d t|d
dd}t |g d	 |j	|j	ksfJ d S )NrN   i     periodrL   r     )r   K         r  )r   r  r  r  r  i     )r   r  r  r  r  r     )r  Zdiscont)
r	   r2   r   r7   r   r   r   r   modr   )rd   Z
simple_seqZwrap_seqZ
uneven_seqZwrap_unevenZ
no_discontZ
sm_discontr=   r=   r>   test_period  s   &zTestUnwrap.test_periodN)ru   rv   rw   rC  r  r=   r=   r=   r>   r        r  r   O
AllIntegerFloatM)r   rN   r   c                   @   sz   e Zd ZdededdfddZdededdfddZdededdfd	d
ZdededdfddZdededdfddZ	dS )TestFilterwindowsr   r  returnNc                 C      t j||dd }t|}|dkrt j}nt |jt j}|j|ks$J t|t| |dk r9t|t g  d S |dkrGt|t 	d d S t
t j|dddd d S )	Nr   r=   r  rN   r   rz         @rJ   )r7   r   r#   r   r   r   r   r    r	   rb   r
   r   rd   r   r  Zscalarr   Z	ref_dtyper=   r=   r>   test_hanning     zTestFilterwindows.test_hanningc                 C   r  )	Nr   r=   r  rN   r   rz   g(\@rJ   )r7   r   r"   r   r   r   r   r    r	   rb   r
   r   r  r=   r=   r>   test_hamming  r  zTestFilterwindows.test_hammingc                 C   r  )	Nr   r=   r  rN   r   rz   g^)@rJ   )r7   r   r   r   r   r   r   r    r	   rb   r
   r   r  r=   r=   r>   test_bartlett  r  zTestFilterwindows.test_bartlettc                 C   r  )	Nr   r=   r  rN   r   rz   g=
ףp=@rJ   )r7   r   r   r   r   r   r   r    r	   rb   r
   r   r  r=   r=   r>   test_blackman  r  zTestFilterwindows.test_blackmanc                 C   s   t j||dd }t|d}|dkrt j}nt |jt j}|j|ks%J t|t| |dk r:t|t g  d S |dkrHt|t 	d d S t
t j|dddd d S )	Nr   r=   r   r  rN   rz   r   r  )r7   r   r'   r   r   r   r   r    r	   rb   r
   r   r  r=   r=   r>   test_kaiser2  s   
zTestFilterwindows.test_kaiser)
ru   rv   rw   strr  r  r  r  r  r  r=   r=   r=   r>   r    s    r  c                   @   rH   )	TestTrapzc                 C   sH   t ddd}tt d|d  t dt j  dd}t|dd d S )	Nr   r  r  rL   )r  rN   rr   )r7   r8   r0   r  r  r  r
   )rd   r   r:  r=   r=   r>   rC  J  s   *zTestTrapz.test_simplec                 C   s&  t ddd}t ddd}t ddd}t ||d |d   }|d  d  < |d  d  < t ||d |d   }|d  d  < |d  d  < t ||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   rN   rV   rL   rp   r[   r]   rz   )r   r{   )r7   r  Z	ones_liker   r0   r
   )rd   r   r   r  ZwxZwyZwzqZqxZqyZqzr:  r=   r=   r>   	test_ndimP  s8   6




zTestTrapz.test_ndimc                 C   s   t d}|| }|dk}t jj||d}d}tt||| t jj||d}tt||| t jj||d}tt||| d S )NrW   rL   r  g      *@)r7   r8   r   r   r
   r0   )rd   r   r   r  Zymr:  Zxmr=   r=   r>   r  u  s   
zTestTrapz.test_maskedN)ru   rv   rw   rC  r  r  r=   r=   r=   r>   r  H  s    %r  c                   @   r   )TestSincc                 C   s6   t tddk ttddd}t|t|d d S )Nr   rN   r]   r&  rr   )r   r/   r7   r  r   r    rd   r   r=   r=   r>   rC    s   zTestSinc.test_simplec                 C   sF   ddg}t t|}t t|}t t|}t|| t|| d S )Nr   r  )r/   r7   r   r  r  r	   )rd   r   r   r   r   r=   r=   r>   test_array_like  s   
zTestSinc.test_array_likeN)ru   rv   rw   rC  r  r=   r=   r=   r>   r    r  r  c                   @   rR  )
TestUniquec                 C   s   t g d}tt t|g dk ttt g dt dgk g d}tt t|g dk t g d}tt t|g dk d S )	N)	rJ   rV   rL   rN   rN   rL   rV   rJ   r   )r   rN   rL   rV   rJ   )rN   rN   rN   rN   rN   rN   )widgethamrE  rF  rE  r   )rF  rE  r   r  )      @      @r        ?      $@r   r  )r  r  r  r   )r7   r   r   r   r3   rC  r=   r=   r>   rC    s   "zTestUnique.test_simpleNru   rv   rw   rC  r=   r=   r=   r>   r    r^  r  c                   @   r   )TestCheckFinitec                 C   sP   g d}ddt jg}ddt jg}t j| ttt jj| ttt jj| d S )Nr   rN   rL   )r7   infr  libasarray_chkfiniter   ra   r   r=   r=   r>   rC    s   zTestCheckFinite.test_simplec                 C   s0   g d}t jj|dt jd}t|jt jk d S )Nr   r   )r   r   )r7   r  r  r   r   r   rn   r=   r=   r>   test_dtype_order  s   z TestCheckFinite.test_dtype_orderN)ru   rv   rw   rC  r  r=   r=   r=   r>   r    r   r  c                	   @   s   e Zd Zeg dg dg dgZeg dg dg dgZeg dg dg d	gZeg d
g dg dg dg dg 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ejd ejejejejgd!d" Zd#S )$TestCorrCoef)g^?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?)r   ޛ?r@)r
  r   p]4?)r  r  r   )r   r
  r  ?'L?(8?4V}?)r
  r   r  w{,H5?jS,?)r  r  r   )h?5#A?)r  r  r  r   toBC,)r  r  r  r  r   @02v?)r  r  r  r  r  r   c                 C   s*   t tg dg dddgddgg d S )Nr   )rN   r   rN   r         )r
   r7   r   r   r=   r=   r>   test_non_array  s   zTestCorrCoef.test_non_arrayc                 C   sd   t | j}t|| j ttt|dk t | j| j}t|| j	 ttt|dk d S rl  )
r   r  r
   r  r   r7   r   r  r!  r  )rd   Ztgt1Ztgt2r=   r=   r>   rC    s   
zTestCorrCoef.test_simplec                 C   s   t  L}td ttt| jdd |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    d S 1 sRw   Y  d S )Nr.  r]   ZddofrV   )r   r1  simplefilterr   DeprecationWarningr   r  filterr
   r  r!  r  rd   supr=   r=   r>   	test_ddof  s   

"zTestCorrCoef.test_ddofc                 C   s~   t  2}td ttt| j| jdd ttt| jdd |t t	t| jdd| j
 W d    d S 1 s8w   Y  d S )Nr.  rN   r   )Zbias)r   r1  r  r   r  r   r  r!  r  r
   r  r  r=   r=   r>   	test_bias  s   

"zTestCorrCoef.test_biasc                 C   sZ   t g dg dg}t|}t ddgddgg}t|| tt t |dk d S Nr   r  y               @r  r   r	  r  )r7   r   r   r   r   r   r  )rd   r   r  r}  r=   r=   r>   test_complex  s
   
zTestCorrCoef.test_complexc                 C   sH   t g dg}t g dg}tt ||t ddgddgg d S r#  )r7   r   r   r   rd   r   r   r=   r=   r>   test_xy  s   (zTestCorrCoef.test_xyc                 C      t jddJ t dt tttg tj tttg 	ddtg 	dd tttg 	ddttjtjgtjtjgg W d    d S 1 sSw   Y  d S NTr,  r.  r   rL   )
r1  r2  r  RuntimeWarningr	   r   r7   r   r  rs   r   r=   r=   r>   
test_empty     "zTestCorrCoef.test_emptyc                 C   s|   ddgddgg}t jdd t|}W d    n1 sw   Y  t|t ddgddgg tt t |dk d S )Ng0.++g}Ô%ITraise)r   r   r  )r7   Zerrstater   r   r   r   r   r  )rd   r   r   r=   r=   r>   test_extreme	  s   
zTestCorrCoef.test_extreme	test_typec                 C   *   | j |}t||d}||jksJ d S Nr   )r  r   r   r   )rd   r/  Zcast_Ar  r=   r=   r>   test_corrcoef_dtype	     z TestCorrCoef.test_corrcoef_dtypeN)ru   rv   rw   r7   r   r  r!  r  r  r  rC  r!  r"  r%  r'  r+  r.  r   r   r   halfsingledouble
longdoubler2  r=   r=   r=   r>   r	    sL    	
	r	  c                   @   s\  e Zd ZeddgddgddggjZeddgddggZejg dddZeg dZ	ed	gdgdgdgdgd
ggjZ
eddgddggZejdejdZeg dZeddgddggZedZeg 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d'ej ej!ej"ej#gd(d) Z$d*S )+TestCovr   rL   rN   r   r  )r   r   r   )ndmin)rN   rJ   rN   r   r   皙?gٿrV   r   )r   r   r   gUUUUUU?gUUUUUU)g&S:?go_?g#~j?gZӼ?gQ|?c                 C   s   t t| j| j d S r6   )r   r   x1r  r   r=   r=   r>   rh   	  s   zTestCov.test_basicc                 C   sV   t g dg dg}t ddgddgg}tt|| tt|t dd| d S )Nr   r$  r   r	  r  rV   aweights)r7   r   r   r   rb   )rd   r   r  r=   r=   r>   r%  	  s   zTestCov.test_complexc                 C   sF   t g dg}t g dg}tt||t ddgddgg d S r#  )r7   r   r   r   r&  r=   r=   r>   r'  %	  s   &zTestCov.test_xyc                 C   r(  r)  )
r1  r2  r  r*  r	   r   r7   r   r  rs   r   r=   r=   r>   r+  *	  r,  zTestCov.test_emptyc                 C   sp   t jdd( t dt tt| jddttj	tj	 gtj	 tj	gg W d    d S 1 s1w   Y  d S )NTr,  r.  rW   r  )
r1  r2  r  r*  r	   r   r;  r7   r   r  r   r=   r=   r>   test_wrong_ddof3	  s   "zTestCov.test_wrong_ddofc                 C   sJ   t t| jt| jdd tg d}t t| j|t| j|dd d S )NF)Zrowvar)g+?g4@?g&S?go_?gJ4?)r   r   x3r7   r   rd   r   r=   r=   r>   test_1D_rowvar:	  s   "zTestCov.test_1D_rowvarc                 C   s$   t t| jddtj| jdd d S )NrN   r  )r   r   r?  r7   varr   r=   r=   r>   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)fweightsr  rL   rV   r   rL   r]   rV   )r   r   r  frequencies
x2_repeatsr;  r  unit_frequenciesr  r   r#  r7   rb   r"  RuntimeErrorra   )rd   Znonintr  r=   r=   r>   test_fweightsB	  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d}t	t
t| j|d td}t	t
t| j|d dtd }t	tt| j|d d S )Nr<  r   rE  rL   r  rV   )r   r   r;  r   r  unit_weightsr  r7   rb   r   rI  ra   r  r=   r=   r>   test_aweightsR	  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)rD  r=  r   r<  )r   r   r  rF  rK  rG  r;  r  rH  r  r   r  r   r=   r=   r>   test_unit_fweights_and_aweights^	  s<   z'TestCov.test_unit_fweights_and_aweightsr/  c                 C   r0  r1  )r;  r   r   r   )rd   r/  Zcast_x1r  r=   r=   r>   test_cov_dtyper	  r3  zTestCov.test_cov_dtypeN)%ru   rv   rw   r7   r   r9  r;  r  r  rF  rG  r  rb   r"  rH  r   r  rK  r?  rh   r%  r'  r+  r>  rA  rC  rJ  rL  rM  r   r   r   r4  r5  r6  r7  rN  r=   r=   r=   r>   r8  	  s0    $
	r8  c                   @   rH   )Test_I0c              
   C   s   t tdtd tg d}tg d}t t|| t t| | tddgddgd	d
gddgddgg}t t|tddgddgddgddgddgg tdg}t|jd ttdgtdg d S )Nr  gǒ#?)gC7?gmM?g3a,?g$WV?ۏ?rW  )gֿN^?gE ?g閡1?g%m? ?gDn@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?r   r   r   )r
   r$   r7   r   r   rB   r	   )rd   r  r  r!  Zi0_0r=   r=   r>   rC  {	  s4   

zTest_I0.test_simplec                    sV   t d G  fddd}tt | |sJ t  }t | }t|| d S )NrJ   c                       s   e Zd Z jZdd ZdS )z*Test_I0.test_non_array.<locals>.array_likec                 S   rE  r6   r=   )rd   r  r=   r=   r>   __array_wrap__	  rt  z9Test_I0.test_non_array.<locals>.array_like.__array_wrap__N)ru   rv   rw   Z__array_interface__rP  r=   r,  r=   r>   
array_like	  s    rQ  )r7   r8   r@  r  r$   r	   )rd   rQ  r  r  r=   r,  r>   r  	  s   

zTest_I0.test_non_arrayc                 C   sJ   t ddg}tjtdd t|}W d    d S 1 sw   Y  d S )Nr   y      ?       @z#i0 not supported for complex valuesrO  )r7   r   r   r=  r#  r$   )rd   re   r  r=   r=   r>   r%  	  s   
"zTest_I0.test_complexN)ru   rv   rw   rC  r  r%  r=   r=   r=   r>   rO  y	  s    rO  c                   @   r   )
TestKaiserc                 C   s|   t ttdd ttddtg  ttddtddg ttddtg d ttddtg d	 d S )
NrN   r   r   rL    oF?rW   )rS  vT=?r   rT  rS  gg?)?YJ?r   rV  rU  )r   r7   isfiniter'   r
   r   r   r=   r=   r>   rC  	  s   



zTestKaiser.test_simplec                 C   s   t dd d S )NrV   rJ   )r'   r   r=   r=   r>   test_int_beta	  r7  zTestKaiser.test_int_betaN)ru   rv   rw   rC  rX  r=   r=   r=   r>   rR  	  r  rR  c                   @   rR  )	TestMsortc              	   C   sv   t g dg dg dg}tjtdd tt|t g dg dg dg W d    d S 1 s4w   Y  d S )	N)\?bCQ?הs?)w?kl?*dta?)ӯ?6H?ܘC?zmsort is deprecatedrO  )r]  r^  rb  )rZ  ra  r\  )r`  r[  r_  )r7   r   r   Zwarnsr  r
   r)   r  r=   r=   r>   rC  	  s   

"zTestMsort.test_simpleNr  r=   r=   r=   r>   rY  	  r^  rY  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d Z
dd Zdd Zdd ZdS )TestMeshgridc              	   C   sj   t g dg d\}}t|tg dg dg dg dg t|tg dg dg dg dg d S )Nr   rJ   rW   rq   rr   r   )rW   rW   rW   )rq   rq   rq   )rr   rr   rr   r(   r	   r7   r   rd   XYr=   r=   r>   rC  	  s   zTestMeshgrid.test_simplec                 C   s&   t g d\}t|tg d d S )Nrf  re  )rd   rg  r=   r=   r>   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(   r  r=   r=   r>   test_no_input	  s   zTestMeshgrid.test_no_inputc                 C   s   g d}g d}t ||dd\}}t|tg dg dg dg t|tg dg dg d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 )Nr   rd  ijZindexingr   )rL   rL   rL   rL   )rV   rV   rV   rV   rp   r  r   r  rV   rJ   )rJ   rV   rL   )rV   rJ   rL   Znotvalid)r(   r	   r7   r   r   rB   r   ra   )rd   r   r   rg  rh  r  r=   r=   r>   test_indexing	  s"   zTestMeshgrid.test_indexingc                 C   sT   t g dg ddd\}}t|tg dg t|tdgdgdgdgg d S )	Nr   rd  TsparserJ   rW   rq   rr   re  rf  r=   r=   r>   test_sparse	  s   $zTestMeshgrid.test_sparsec                 C   s   t ttg dg ddd d S )Nr   rd  rk  )r  )r   r#  r(   r   r=   r=   r>   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 ||\}}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   rJ  T)r   ro  )r7   r8   r   r   r(   r   r   )rd   r   r   rg  rh  r=   r=   r>   r  
  s   zTestMeshgrid.test_return_typec                 C   sr   t ddg}t 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 )
Nr  r  gffffff
@g@FT)rp  r   r   rN   )r7   r   r(   r   )rd   rg  rh  r   r   r=   r=   r>   test_writeback
  s   zTestMeshgrid.test_writebackc                 C   sh   t jdd tddD  \}}}}}d}t|j| t|j| t|j| t|j| t|j| d S )Nc                 s   s    | ]}d g| V  qdS )r   Nr=   r   r   r=   r=   r>   r  '
  r  z-TestMeshgrid.test_nd_shape.<locals>.<genexpr>rN   rq   )rL   rN   rV   rJ   rW   )r7   r(   rc   r   rB   )rd   re   r   r   r  r  Zexpected_shaper=   r=   r>   test_nd_shape&
  s   $zTestMeshgrid.test_nd_shapec                 C   sp   t dgddgg d\}}}t|g dgg dgg t|g dgg dgg t|g dgg dgg d S )Nr   rN   rL   rU   r   r   rK   r7   r(   r   r   r=   r=   r>   test_nd_values/
  s   zTestMeshgrid.test_nd_valuesc                 C   sn   t jdgddgg ddd\}}}t|g dg dgg t|g dg d	gg t|g dg dgg d S )
Nr   rN   rL   rU   rk  rl  r   r   rK   rv  r   r=   r=   r>   test_nd_indexing5
  s   "zTestMeshgrid.test_nd_indexingN)ru   rv   rw   rC  ri  rj  rn  rq  rr  r  rs  ru  rw  rx  r=   r=   r=   r>   rc  	  s    
	rc  c                   @   rx   )TestPiecewisec                 C   s4  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ddgdg}t|ddg t ddgtddgdg}t|ddg t ddgt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g d	 d S )
Nr   TFrN   c                 S   rr  r  r=   r  r=   r=   r>   r-  S
  rF  z+TestPiecewise.test_simple.<locals>.<lambda>r]   z1 or 2 functions are expectedr   )r*   r	   r7   r   r   ra   rC  r=   r=   r>   rC  >
  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 )NrN   rL   TFrV   rJ   r*   r	   rC  r=   r=   r>   test_two_conditions[
  s    z!TestPiecewise.test_two_conditionsc                 C   s"   t dg dg d}t|d d S )NrV   )TFF)rJ   rL   r   rJ   )r*   r   rC  r=   r=   r>   $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 )NrN   rL   TFr   rV   rz  rC  r=   r=   r>   test_defaultc
  s   zTestPiecewise.test_defaultc                 C   s   t 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|g dg d	}t|d d S )
NrV   rJ   r   rW   TFrN   r  r   )r7   r   r*   r   r   r	   r&  r=   r=   r>   r>  l
  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g d}t|d ttdt ||dk|dkgdg ttdt ||dk|dkgg d	 d S )
NrV   rJ   r   rW   r   rL   z2 or 3 functions are expectedrN   r   )r*   r   r	   r   ra   r&  r=   r=   r>   test_0d_comparison{
  s   
*
z TestPiecewise.test_0d_comparisonc                 C   s8   t d}t |dk}t||gddg}t|d d S )NrV   rN   rL   )r7   r   r*   r   )rd   r   r   r   r=   r=   r>   test_0d_0d_condition
  s   
z"TestPiecewise.test_0d_0d_conditionc                 C   sR   t g dg dg}t||dk |dkgg d}t|t g dg dg d S )N)g      g      r  )r  r  r  r   rL   r*  )r  r  r  )r   r   r   )r7   r   r*   r	   r&  r=   r=   r>   test_multidimensional_extrafunc
  s   
z-TestPiecewise.test_multidimensional_extrafuncc                 C   s^   G dd dt j}t d|}t||dk |dkgg d}tt|| t|g d d S )Nc                   @   r   )z/TestPiecewise.test_subclasses.<locals>.subclassNr   r=   r=   r=   r>   r   
  r   r   r   r   rJ   )r  r   r   )r  r  r   r   r   )r7   r   r8   r   r*   r   r   )rd   r   r   r:  r=   r=   r>   r   
  s
   zTestPiecewise.test_subclassesN)ru   rv   rw   rC  r{  r|  r}  r>  r~  r  r  r   r=   r=   r=   r>   ry  <
  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ejje dddd Zejdddggdgdd ZdS )TestBincountc                 C   s$   t t d}t|t d d S )NrJ   )r7   bincountr8   r	   rb   r@  r=   r=   r>   rC  
  s   zTestBincount.test_simplec                 C   s,   t t g d}t|t g d d S )N)rN   rW   rL   rJ   rN   )r   rL   rN   r   rN   rN   )r7   r  r   r	   r@  r=   r=   r>   test_simple2
  s   zTestBincount.test_simple2c                 C   s2   t d}t g d}t ||}t|| d S )NrJ   )皙?333333?r  r  )r7   r8   r   r  r	   rd   r   r   r   r=   r=   r>   test_simple_weight
  s   
zTestBincount.test_simple_weightc                 C   s@   t g d}t g d}t ||}t|t g d d S )NrN   rL   rJ   rW   rL   r  r  r  r  r  )r   r  r  r   r  r  r7   r   r  r	   r  r=   r=   r>   test_simple_weight2
  s   z TestBincount.test_simple_weight2c                 C   sV   t g d}t j|dd}t|t g d g }t j|dd}t|t g  d S )N)r   rN   r   rN   rN   rV   Z	minlength)rL   rV   r   r   r  r&  r=   r=   r>   test_with_minlength
  s   z TestBincount.test_with_minlengthc                 C   sV   t g d}t j|dd}t|t g d t j|dd}t|t g d d S )N)r   rN   rN   rL   rL   rV   rV   rL   r  )rN   rL   rL   rL   r   r  r&  r=   r=   r>   )test_with_minlength_smaller_than_maxvalue
  s
   z6TestBincount.test_with_minlength_smaller_than_maxvaluec                 C   sB   t g d}t g d}t ||d}t|t g d d S )Nr  r  rp   )r   r  r  r   r  r  r   r   r  r  r=   r=   r>   test_with_minlength_and_weights
     z,TestBincount.test_with_minlength_and_weightsc                 C   s&   t jg td}t |}t|| d S r1  )r7   r   r  r  r	   r&  r=   r=   r>   r+  
  s   
zTestBincount.test_emptyc                 C   s4   t jg td}t j|dd}t|t jdtd d S )Nr   rW   r  )r7   r   r  r  r	   r@   r&  r=   r=   r>   test_empty_with_minlength
  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 d ttd fdd ttd fd	d d S )
Nr   z"'str' object cannot be interpretedc                         t j ddS Nfoobarr  r7   r  r=   r  r=   r>   r-  
      z<TestBincount.test_with_incorrect_minlength.<locals>.<lambda>zmust not be negativec                      r  Nr]   r  r  r=   r  r=   r>   r-  
  r  rW   c                      r  r  r  r=   r  r=   r>   r-  
  r  c                      r  r  r  r=   r  r=   r>   r-  
  r  )r7   r   r  r   r#  ra   r8   r   r=   r  r>   test_with_incorrect_minlength
  s$   




z*TestBincount.test_with_incorrect_minlengthr  r  c                 C   s   t ttj}t ttj}tdD ]	}tg d qtt ttj| tt ttj| tdD ]}tg dg d q<tt ttj| tt ttj| d S )Nr   r   r   )	r  r  r7   r   Zintpr6  rc   r  r   )rd   Zintp_refcountZdouble_refcountjr=   r=   r>   test_dtype_reference_leaks
  s   z'TestBincount.test_dtype_reference_leaksvalsrL   c                 C   st   t |}tt t | W d    n1 sw   Y  tt t | W d    d S 1 s3w   Y  d S r6   )r7   asarrayr   ra   r  )rd   r  Zvals_arrr=   r=   r>   test_error_not_1d
  s   


"zTestBincount.test_error_not_1dN)ru   rv   rw   rC  r  r  r  r  r  r  r+  r  r  r   r   r  r   r  r   r  r=   r=   r=   r>   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g d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   rN   rL   r  h  )r   ra   r&   r   r=   r=   r>   test_exceptions  s
   zTestInterp.test_exceptionsc                 C   sB   t ddd}t ddd}t ddd}tt |||| d S )Nr   rN   rW   ri   )r7   r  r
   r&   rd   r   r   x0r=   r=   r>   rh   	  r  zTestInterp.test_basicc           
      C   s  t 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g dtd}|d d d }	t|| t||	 t|||dd}t|||dd}tjg dtd}|d d d }	t|| t||	 t|||d	d
}t|||d	d
}tjg dtd}|d d d }	t|| t||	 t|||dd	d}t|||dd	d}tjg dtd}|d d d }	t|| t||	 qd S )NrN   r   r   r]   r   r   left)r   rN   rN   rN   rL   right)rN   rN   rN   rL   )r  r  )r   rN   rN   rL   )	rc   r7   r8   r6  rb   r   r&   rL  r   )
rd   sizexpZypZincptsZdecptsZincresZdecresZinctgtZdectgtr=   r=   r>   test_right_left_behavior  s<   






z#TestInterp.test_right_left_behaviorc                 C   s   t ddd}t ddd}d}tt |||| d}tt |||| t d}tt |||| t d}tt |||| t j}tt |||| d S )Nr   rN   rW   r  )r7   r  r
   r&   r   r   r  r  r=   r=   r>   test_scalar_interpolation_point5  s   

z*TestInterp.test_scalar_interpolation_pointc                 C   st   g d}g d}ddt jdg}tt |||ddt jt jdg ddt jdg}tt |||ddt jt jdg d S )NrN   rL   r  rV   rJ   rf  rN   rL   rJ   )r7   r  r
   r&   r  )rd   r   r  fpr=   r=   r>    test_non_finite_behavior_exact_xC  s   "&z+TestInterp.test_non_finite_behavior_exact_xc                 C   rp  r6   )r7   Zfloat_r  r=   r=   r>   r-  L     
 zTestInterp.<lambda>c                 C   s
   t | dS r!  rG   r  r=   r=   r>   r-  M  r  c                 C   s
   t d| S r!  r  r  r=   r=   r>   r-  N  r  c                 C   s   t | t| dS )NrT   )rG   r7   multiplyr  r=   r=   r>   r-  O  s    )rD   zcomplex-realzcomplex-imagzcomplex-both)paramsZidsc                 C   s   |j S )z( scale function used by the below tests )param)rd   requestr=   r=   r>   scK  s   zTestInterp.scc                 C   s   t tdtjdg|ddg|tj t tddtjg|ddg|tj t tdddg|tjdg|tj t tdddg|dtjg|tj dS )z test that nans are propagated r  rN   r   r   N)r   r7   r&   r  rd   r  r=   r=   r>   test_non_finite_any_nanZ  s   (((,z"TestInterp.test_non_finite_any_nanc                 C   s   t tdtj tj
 g|ddg|tj t tdddg|tj tj
 g|tj t tdddg|tj
 tj g|tj t tdtj tj
 g|ddg|d dS )z2 Test that interp between opposite infs gives nan r  r   r   rN   Nr   r7   r&   r  r  r  r=   r=   r>   test_non_finite_infa  s   ...0zTestInterp.test_non_finite_infc                 C   st  t tdtj dg|tj dg|tj t tdtj dg|tj
 dg|tj t tdtj dg|dtj g|tj t tdtj dg|dtj
 g|tj t tddtj
 g|tj dg|tj t tddtj
 g|tj
 dg|tj t tddtj
 g|dtj g|tj t t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 r  rN   r   r   Nr  r  r=   r=   r>   test_non_finite_half_inf_xfj  s   .......2z&TestInterp.test_non_finite_half_inf_xfc                 C   s   t tdtj tj g|ddg|d t tdtj dg|ddg|d t tddtj
 g|ddg|d t tdtj
 tj
 g|ddg|d dS )z1 Test interp where the x axis has a bound at inf r  r   r   rN   Nr   r7   r&   r  r  r=   r=   r>   test_non_finite_half_inf_xu  s   ,((0z%TestInterp.test_non_finite_half_inf_xc                 C   s  t tdddg|dtj g|tj  t tdddg|dtj
 g|tj
  t tdddg|tj dg|tj  t tdddg|tj
 dg|tj
  t tdddg|tj tj g|tj  t t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 r  r   rN   r   Nr  r  r=   r=   r>   test_non_finite_half_inf_f|  s   ,,,,04z%TestInterp.test_non_finite_half_inf_fc           	      C   s  t ddd}t ddddt ddd d  }d}|d| d  }tt |||| d}d}tt j||||d| d	}d}tt j||||d
| g d}g d}ddt jdg}ddt jd t jdg}tt |||| g d}g d}g d}g d}tt j|||dd| d S )Nr   rN   rW   r  r  r]          @      @r  r   r  r  rf         @      ?rJ   y              ?iLiViG   r  rV  r   im     iBi^  i)      @      ?y      $@       @      @      @y      @      @)y      @      ?r  y     !@      ?y      @      ?r  y      
@      
@y      @      @y      @      @r  r  )r7   r  r
   r&   r  )	rd   r   r   r  Zy0r  r  r  r  r=   r=   r>   test_complex_interp  s*   $zTestInterp.test_complex_interpc                 C   s   t ddd}t ddd}t d}tt |||| t g d}t g d}t t d||}t|d tt|t j t jt d||dd	}t|d
 tt|t j d S )Nr   rN   rW   r  r   )rN   r]   rN   r  rJ   r  r  )	r7   r  r   r
   r&   r   r   r@  r   )rd   r   r   r  r  r  r   r=   r=   r>   )test_zero_dimensional_interpolation_point  s   


z4TestInterp.test_zero_dimensional_interpolation_pointc                 C   s2   t ddd}t |}tt t j||d d S )Nr   r   g-C6?r   )r7   r8   sinr
   r&   r  )rd   r  r  r=   r=   r>   test_if_len_x_is_small  s   
z!TestInterp.test_if_len_x_is_smallc                 C   s   g d}g d}g d}g d}t tj|||dd| tj|ddd	d
}tj|ddd	d
}t tj|||dd| d S )Nr  r  )rW   r   rV   rJ   )g      @r        !@g      @r   g      
@      @g      @r  r  r   r   rL   r]   r  )r
   r7   r&   r   rs   )rd   r   r  r  r   r=   r=   r>   r    s   zTestInterp.test_periodN)ru   rv   rw   r  rh   r  r  r  r   Zfixturer  r  r  r  r  r  r  r  r  r  r=   r=   r=   r>   r     s0    &
		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ejd dd Zdd ejd D ejejfejejfejejfejejfedejfg Zej	
ddgeej	
ddgg ddd Zejd ejd  d Zej	
dedd Zej	
dedd Zej	
de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 d0d1 Z!d2d3 Z"d4d5 Z#d6d7 Z$d8d9 Z%d:d; Z&ej	
d<d=d>d=ggej	j
d?g d@dAdBdC Z'dDdE Z(dFdG Z)dHdI Z*dJdK Z+ej	
ddLdMgej	
dNg dOdPdQ Z,dRS )STestPercentilec                 C   s~   t dd }tt |dd tt |dd tt |dd t j|d	< tt |dt j tt j|dd
dt j d S )Nrp   r  r   r   r&  r  ri   r   rN   nearestmethod)r7   r8   r   
percentiler  rC  r=   r=   r>   rh     s   
zTestPercentile.test_basicc                 C   s   dd t dD }t|td}t|td tt|t t|td}t|tdd tt|t t|td}t|tdd	 tt|t t|tdg}t|ttdd	g tt|tj d S )
Nc                 S      g | ]}t |d qS rL   r   rt  r=   r=   r>   r     r   z0TestPercentile.test_fraction.<locals>.<listcomp>rp   r   r&  rr   rL   ri   rJ   )rc   r7   r  r   r   r   r   r   )rd   r   rg  r=   r=   r>   test_fraction  s   zTestPercentile.test_fractionc                 C   sR   t d}t |dd d d t |dd d dd t d}t |dd |dd d S )NrW   Flinearr   )r7   rb   r  )rd   r  or=   r=   r>   test_api  s
   

zTestPercentile.test_apic                 C   j   t jg ddd}ttt j|d t jg ddd}ttt j|d t jg ddd}ttt j|d d S N)y      ?      @y @      ?y?ffffff@Gr   r  Dr   )r7   r   r   r#  r  rd   Zarr_cr=   r=   r>   r%    s   zTestPercentile.test_complexc                 C   sF   t g dg dg dg dg dg}tt j|dddg d d S )Nr   )rJ   rJ   rV   ri   r   rz   )r7   r   r	   r  rC  r=   r=   r>   test_2D  s   
zTestPercentile.test_2Dr   r  c                 C   sP   t jdt jdddg|d}t j|ddd}t j|t j t j|j|j d S )Nrb       A@      D@      I@r   r  r  )r7   r  ZNANr  testingr   r   )rd   r   r  r  r=   r=   r>   test_linear_nan_1D  s   z!TestPercentile.test_linear_nan_1Dc                 C   s   g | ]}|t jfqS r=   )r7   r   )r   Zint_typer=   r=   r>   r     s    zTestPercentile.<listcomp>r  r  input_dtypeexpected_dtyper  r  )	)inverted_cdfrJ  )averaged_inverted_cdf     ;@)closest_observationrJ  )interpolated_inverted_cdfrJ  )hazenr  )weibull   )r  r  )median_unbiasedro  )normal_unbiasedg      ;@c                 C   s   t |}t  dkrt |t j}t jg d|d}t j|d|d}t j||	|d |dv rT|dkrDt j
t |jt j d S t j
t |jt | d S t j
t |jt | d S )	Nlegacy)rb  g      4@r  r  r  r   r  r  rm  )r  r  r  )r7   r   Z_get_promotion_stateZpromote_typesr   r  r  r  r
   r   r   )rd   r  r  r  r  r  r   r=   r=   r>   test_linear_interpolation
  s"   
z(TestPercentile.test_linear_interpolationc                 C   sD   t tjtjd|ddddd t tjtjd|ddddd d S )	Nr   r   ri   lowerr  rJ   higherrW   r   r7   r  r8   rd   r   r=   r=   r>   test_lower_higher1     z TestPercentile.test_lower_higherc                 C   s   t tjtjd|ddddd t tjtjd|dd d	ddd
 t tjtjd|ddddd t tjtjd|dd	ddd
 d S )Nr   r   3   midpointr  r  r  rN   ri   rW   r         @r  r  r=   r=   r>   test_midpoint8  s(   zTestPercentile.test_midpointc                 C   sD   t tjtjd|ddddd t tjtjd|ddddd d S )	Nr   r   r  r  r  rW   1   rJ   r  r  r=   r=   r>   test_nearestC  r  zTestPercentile.test_nearestc                 C   sL   t jd}t |d}t j||  t |d}t j||  d S )NrW   r&  r   )r7   r  r   r  r  r   r  r  )rd   r  r   r=   r=   r>   'test_linear_interpolation_extrapolationJ  s
   z6TestPercentile.test_linear_interpolation_extrapolationc                 C   s,   t dd }tt |g dg d d S )Nrp   r  )r   r&  ri   )r   r  r   )r7   r8   r   r  rC  r=   r=   r>   test_sequenceS  s   zTestPercentile.test_sequencec                 C   s  t ddd}tt |dg d g dg dg dg}tt j|dd	d
| g dg dg dg}tt j|ddd
t |j t ddddd}tt |djd tt |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|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  rV   rJ   )r  ri   r&  )g      @r  r  )rL   rV   rJ   rW   rd  )rp   r  r   r   r   rz   )      ?r  rV   )      @r  rr   )r  r   r   rN   r  rW   rq   r  ri   r  )r  ri   r  rV   )rL   rJ   rW   rq   )rL   rV   rW   rq   rL   )rL   rV   rJ   rq   )rV   rV   rW   rq   r  r  r{   r  )r7   r8   rs   r   r  r   r9  rB   )rd   r   r0rJ  r=   r=   r>   r  W  sf   

zTestPercentile.test_axisc                 C   s  t ddd}tt |dd tt t |d t g d}tt j|ddd| tt j|dddj|j t g d	}t	t j|dd
d| tt j|dd
dj|j t 
d
}tt j|d|dd t|d t 
d}tt j|dd|d| t|| t 
d}tt j|dd
|d| t|| t ddd}tt j|dddd tt t |d t g d}t j|dddd}t|| t|j|j t g d}t j|ddd
d}t	|| t|j|j t j
d|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  rV   rJ   ri   r  r   r   r   rc  r   rz   r  r  r   rN   r  r{   r  r  r  r   )r  r{   )r   r   rY  r=   r   r  r  rW   r  r{   r  )r7   r8   rs   r   r  r   isscalarr   rB   r
   emptyr   )rd   r   r  rJ  r  Zc0c1r   r=   r=   r>   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 )
NrN   rL   8   r  r  e   r]   ri   r  )r   ra   r7   r  r  rc   r   r=   r=   r>   test_exception  s    $zTestPercentile.test_exceptionc                 C   s   t tg ddd d S )Nr   r   rN   )r   r7   r  r   r=   r=   r>   test_percentile_list  s   z#TestPercentile.test_percentile_listc                 C   s  t g d}t d}d}t j|||d tt ||| t g dg dg}t d}t j||d|d tt j||dd| t d	}t j||d
|d tt j||d
d| t ddd}t g dg dg}t d}tt j|dd|d| t|| t g dg dg}t d}tt j|dd
|d| t|| t g dg dg}t jd|jd}t j|ddd|d}t|| t|| t g dg dg}t jd|jd}t j|ddd
|d}t|| t|| d S )Nr   r   r  r   r  r   r  rz   rV   rL   rN   r  rV   rJ   )r   r   r   r   r  )rL   rJ   r  )r  r  r  r  rE  r   rN   rL   rV   rd  r   r  r  )r   rJ   rp   )rN   rW   r  )	r7   r   r@   r  r   r8   rs   r
  r   )rd   r   r   rg  r  r  rJ  r   r=   r=   r>   test_percentile_out  sB   










z"TestPercentile.test_percentile_outc                 C   s  t d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 t j|ddgddjd tt t j|ddgddjd tt t j|ddgddjd tt t j|ddgddjd d S )Nrq  r   rN   rL   ri   r   rz   )rN   rL   rN   )r   rL   rN   )r   rN   rN   rV   )r   rN   rL   r]   rT   rZ   r7  r  r  r   )rL   rN   rL   rN   )rL   r   rL   rN   )rL   r   rN   rN   )rL   r   rN   rL   )r7   r8   rs   r	   r  rB   r   rd   r  r=   r=   r>   test_percentile_empty_dim  sB   z(TestPercentile.test_percentile_empty_dimc                 C   sh   t g d}t j|dgdd t|t g d t g d}t |dg t|t g d d S )NrL   rV   rJ   rN   ri   Foverwrite_inputr7   r   r  r   rn   r=   r=   r>   test_percentile_no_overwrite  s   z+TestPercentile.test_percentile_no_overwritec                 C   s   t jdddd}t jt d|dd t|t jdddd t jdddd }t jt d|dd t|t jdddd  d S )Nr         Y@rW   )numr  r  )r7   r  r  r8   r	   r'  )rd   rg  r=   r=   r>   test_no_p_overwrite  s   z"TestPercentile.test_no_p_overwritec                 C   s^   t g d}t j|dgdd}t|t dg t jg ddgdd}t|t dg d S )Nr  ri   Tr  r  r  r   r=   r=   r>   test_percentile_overwrite  s
   z(TestPercentile.test_percentile_overwritec              
   C   s  t jjdd}t |gd }tt j|dddt |d t |dd}tt j|dd	dt |d |dd
 }tt j|dddt |d |dd
 }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 	d
d}t j|  tt j|dddd t |d d d d d d df  d tt j|ddgddd d d
f t |d d d d d
d d f  ddg tt j|dddd t |d d d d dd d f  d tt j|dddd t |dd d d d d d f  d tt j|dddd t |dd
d d d d f  d tt j|dddd t |dd d d d d
f  d tt j|dddd t |dd d dd d f  d d S )NG      r  r   ri  r^   rz   r]   r   rm   rN   rk   r  r  rM   r(    rV   rW   rr   r   Z   r   rN   rV   rV   rN   r7  rL   rV   rN   rL   r  rL   rN   rN   rT   rN   rV   rQ   )r7   r  normaldstackr   r  moveaxisr   r   r8   rs   shuffleravelflattenrd   r  r   r  r=   r=   r>   test_extended_axis  sJ   & *&&"""z!TestPercentile.test_extended_axisc                 C   s   t 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 )Nr$  rV  r  )r{   r  r   rV  rJ   r   rJ   rS   )r]   r]   )rV   r]   )r7   rb   r   r~   r  ra   r  r=   r=   r>   test_extended_axis_invalid4  s   
z)TestPercentile.test_extended_axis_invalidc                 C   s   t 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 )Nr$  rr   Tr   r   r^   rN   rN   rr   r   r}   rN   rW   rr   rN   r   rV   rN   rr   r   r  )r   r&  rN   rN   rr   rN   rN   )rL   rN   rN   rr   rN   )rL   rN   rW   rr   rN   )r7   rb   r   r  rB   r  r=   r=   r>   test_keepdims?  s:   
zTestPercentile.test_keepdimsr  rr   rN   r{   NrN   r   r^   )rZ   r]   argnamesZ	argvaluesc                    s   t d|d u rdj }nt|j t fddtjD }t || }t |}t j||d|d}||u s@J t	|j| d S )Nr$  r   c                 3   &    | ]}| v r
d nj | V  qdS rN   NrB   rt  Z	axis_normr  r=   r>   r  d      
z3TestPercentile.test_keepdims_out.<locals>.<genexpr>Tr{   r   r  )
r7   rb   r   r5   r  rc   rB   r
  r  r   )rd   r  r{   	shape_outr  r  r=   rB  r>   test_keepdims_outS  s   

z TestPercentile.test_keepdims_outc                 C   s   t d}t d}tt j|dd|d| tt j|ddd|d| t d}tt j|dd|d| tt j|ddd|d| t d	}tt j|d
|d| tt j|d
d|d| d S )NrJ   rm  r   r  r  r  r   rN   r=   rL   )r7   r@   rb   r   r  rd   r  r  r=   r=   r>   test_outm  s   



zTestPercentile.test_outc              	   C   s  t jddr t ddt td}td}tj|d< ttj	|dd|d	| ttj	|ddd
|d| td}ttj	|dd|d	| ttj	|ddd
|d| td}ttj	|d|d	| ttj	|dd
|d| W d    d S 1 s{w   Y  d S )NTr,  r.  r/  rG  rm  r)  r   r  r  r  r   rN   r=   )
r1  r2  r3  r*  r7   r@   rb   r  r   r  rH  r=   r=   r>   test_out_nanz  s(   




"zTestPercentile.test_out_nanc                 C   s:  t jdtd}t j|d< tt |dt j tt j|dddt j tt j|ddgddt t jgd  t jdtdddd	}t j|d
< t j|d< tt |dt j tt |djd t t jdtdddd	dd}t j|d< t j|d< tt |dd| t t jdtdddd	ddgd}t j|d d ddf< t j|d d ddf< tt |ddgd| t t jdtdddd	dd}t j|d< t j|d< tt |dd| t t jdtdddd	ddgd}t j|d d ddf< t j|d d ddf< tt |ddgd| t t jdtdddd	dd}t j|d< t j|d< tt |dd| t t jdtdddd	ddgd}t j|d d df< t j|d d df< tt |ddgd| t jt jdtd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 )Nr6  r   rL   r  r   rz   g333333?rV   rJ   r   rN   rN   rL   rE  rl   rN   r+  rR   r  r  )	r7   r8   rL  r  r   r  r   rs   r   r   r=   r=   r>   test_nan_behavior  sl   


"

"




z TestPercentile.test_nan_behaviorc                 C   s   t jtdd tg dtj W d    n1 sw   Y  t jtdd tg dtjg W d    n1 s<w   Y  tddd}tj|d< t jtdd tg d| W d    d S 1 shw   Y  d S )NzPercentiles must be inrO  )rN   rL   rV   r   r   g     X@rl  r   )r   r=  ra   r7   r  r  r  )rd   r  r=   r=   r>   
test_nan_q  s   
"zTestPercentile.test_nan_qzm8[D]zM8[s]posr   r!  r   c                 C   s   t jdd|d}d||< t |d}|j|ksJ t |s J t |ddg}|j|ks/J t | s8J t jdd|ddd	}d||d
f< t j|ddd}tt |g d d S Nr   r6  r   ZNaTri  r  H   r]   rV   rN   rz   r  )r7   r8   r  r   isnatr   rs   r	   rd   r   rN  re   r  r=   r=   r>   test_nat_basic  s   zTestPercentile.test_nat_basicN)-ru   rv   rw   rh   r  r  r%  r  r   r   r   r7   	typecodesr  r  r   r   r7  r   ZH_F_TYPE_CODESr  Z
TYPE_CODESr  r  r  r  r  r  r  r  r  r  r  r  r  r  r3  r6  r;  rF  rI  rJ  rL  rM  rT  r=   r=   r=   r>   r    sr    	









	$0)	 
=r  )r  r  r  r  r  r  r  r  r  r  r  r  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	e
jdejd dd Ze
jdedd Zejeejejdddejddddddddd  Zd!d" Ze
jdee
jd#g d$d%d& Ze
jdee
jd#g d$d'd( Zd)S )*TestQuantilec                 C   s   ||k| S r6   r=   )rd   r   r   alphar=   r=   r>   r    s   zTestQuantile.Vc                 C   s*   g d}t |d}t jj|ddd d S )N)r   r  r:  g?g
ףp=
?rN   )Zmaxulp)r7   quantiler  Zassert_array_max_ulp)rd   r   re   r=   r=   r>   test_max_ulp  s   zTestQuantile.test_max_ulpc                 C   sH   t dd }tt |dd tt |dd tt |dd d S )Nrp   r  r   r   rN   r  r   )r7   r8   r   rX  rC  r=   r=   r>   rh     s   zTestQuantile.test_basicc                 C   sl   t dg}t dd}t||d  tt||j t g d}t ||}t|| t|j|j d S )NTFr   )FTT)r7   r   rX  r   r   r   r	   )rd   re   Ztf_quantZ	quant_resr=   r=   r>   test_correct_quantile_value  s   
z(TestQuantile.test_correct_quantile_valuec                 C   s^  dd t dD }t|d}t|d tt|t t|d}t|tdd tt|t t|d}t|d	 tt|tj t|tdd}t|tdd
 tt|t t|tddg}t|ttdd
g tt|tj t|tddgg}t|ttdd
gg tt|tj t	d}tt|tddtdd d S )Nc                 S   r  r  r   rt  r=   r=   r>   r     r   z.TestQuantile.test_fraction.<locals>.<listcomp>rp   r   rN   rr   rL   r  r   rJ   )
rc   r7   rX  r   r   r   r   r   r   r8   )rd   r   r  r=   r=   r>   r    s*   


"zTestQuantile.test_fractionc                 C   r  r  )r7   r   r   r#  rX  r  r=   r=   r>   r%  -  s   zTestQuantile.test_complexc                 C   sj   t g d}| }t jt d|dd t|| | }| }t jt d|dd t|| d S )N)r   r  r  r  r   r  r  r  )r7   r   r   rX  r8   r	   r'  )rd   p0rg  r=   r=   r>   r  6  s   
z TestQuantile.test_no_p_overwriter   r  c                 C   s2   t jt jddg|ddgdd}|j|ksJ d S )NrN   rL   r   r  r  r  )r7   rX  r   r   )rd   r   r  r=   r=   r>   test_quantile_preserve_int_typeB  s   z,TestQuantile.test_quantile_preserve_int_typer  c                 C   sd   t ddd}t jt g dd ||d}tt || t jg d||d}tt || d S )Nr   rN   r  )r   rN   rN   rL   rL   rV   rV   rJ   rW   rW   rN   rN   r  r  r  rp   rp   rr   r  r  )r   r   r   r   )r7   r  rX  r   r   r  )rd   r  r[  rX  r=   r=   r>   test_quantile_monotonicH  s   z$TestQuantile.test_quantile_monotonicrV   r  )	min_value	max_valueFu <7u <7~)allow_infinity	allow_nanr^  r_  )r   rB   elements)r  c                 C   s.   t ddd}t ||}tt || d S )Nr   rN   g{Gz?)r7   r8   rX  r   r  )rd   r  r[  rX  r=   r=   r>   test_quantile_monotonic_hypoV  s   z)TestQuantile.test_quantile_monotonic_hypoc                 C   sV   t g dg dg}t j|d d< t |d}t |sJ tt |dt j d S )N)rW  rc  r   )r   r   r   r   rN   r  )r7   r   r  rX  r	  r   )rd   re   r   r=   r=   r>   test_quantile_scalar_nan`  s
   z%TestQuantile.test_quantile_scalar_nanrW  )r  r  g?c              	   C   s   t jd}d}||}t j|||d}|dv r.t t | |||d| ks,J d S t|| || krItt | |||ddd d S tt | |||dd	| t 	|d	| g d d S )
N  f   r  )r  r  r   g+=)ZatolrN   )
r7   r  default_rngrX  r  r   r  r  r   r`  )rd   r  rW  rngr;   r   r   r=   r=   r>   %test_quantile_identification_equationg  s   

*"
z2TestQuantile.test_quantile_identification_equationc                 C   sf  t jd}d}||}t j|||d}d}tt j|| ||d||  tt j|| ||d||  t j| d| |d }|dkrx|| t|| ks^t || t|| d krkt|t j||dd d S t|t j||dd d S |d	kr|| t|| krt|t j||dd d S t || t|| d krt|t j||d|  dd d S t|t j||dd d S |d
krt|t j||d|  |d d S |dkr|| t|| krt|t j||d|  |d d S t|t j|||d d S |dkrt|t j||dd d S |dkr&t|t j||dd d S t|t j|||d d S )Nrg  rh  r  g      +@rN   r  r  r  r  r  r  )r7   r  ri  rX  r   r  round)rd   r  rW  rj  r;   r   r  r   r=   r=   r>   'test_quantile_add_and_multiply_constant  s@   

"
"

z4TestQuantile.test_quantile_add_and_multiply_constantN)ru   rv   rw   r  rY  rh   rZ  r  r%  r  r   r   r   r7   rU  r\  quantile_methodsr]  
hypothesisgivenr   r   stZintegersfloatsre  rf  rk  rm  r=   r=   r=   r>   rV    s8    
	


rV  c                
   @   s   e Zd Zejejdddddejdddddejdddddejdddddddd	 Zejejdddddejdddddejdddddd
dd Zejejdddddejdddddejdddddd
dd Z	dd Z
dS )TestLerpFr   rN   )rc  rb  r^  r_  r`  ra  )t0t1re   r   c                 C   sl   t |||}t |||}||ks||kr||ksJ d S ||k ||k kr.||ks,J d S ||ks4J d S r6   r  _lerp)rd   rt  ru  re   r   Zl0l1r=   r=   r>   +test_linear_interpolation_formula_monotonic  s   	z4TestLerp.test_linear_interpolation_formula_monotonic)tre   r   c                 C   s\   ||kr|t |||  kr|ksJ  J d S |t |||  kr)|ks,J  J d S r6   rv  )rd   rz  re   r   r=   r=   r>   )test_linear_interpolation_formula_bounded  s   **z2TestLerp.test_linear_interpolation_formula_boundedc                 C   s6   t ||dd|  }t ||d| }t|| d S rs  )r  rw  r   )rd   rz  re   r   r  r  r=   r=   r>   +test_linear_interpolation_formula_symmetric  s   z4TestLerp.test_linear_interpolation_formula_symmetricc                 C   s8   t d}t d}t d}t|||dksJ d S )NrL   rW   r  g@)r7   r   r  rw  )rd   re   r   rz  r=   r=   r>   +test_linear_interpolation_formula_0d_inputs  s   


z4TestLerp.test_linear_interpolation_formula_0d_inputsN)ru   rv   rw   ro  rp  rq  rr  ry  r{  r|  r}  r=   r=   r=   r>   rs    sL    



rs  c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zej	
dg ddejdgejdfdd Zdd Zdd Zdd Zej	jedddd Zdd Zdd Zd d! Zd"d# Zej	j
d$g d%d&d'd( Zej	
d)d*gej	
d+g d,d-d. Zd/S )0
TestMedianc                 C   s>  t d}t d}t ddd}tt |d tt |d tt |d tt j|ddg d	 tt j|dddd
g tt j|d dd t g d}t|d |d  d t | t g d}t|d t | t g d}t|d t | tt |jd t j	|d< tt |jd d S )NrN   rL   rq   rV   r  r  r   rz   r  r  r  rJ   )6-¦?0?}r?g4?r   )r  r  r  )r  r  r  r]   )
r7   r   r8   rs   r   medianr   r
   r   r  )rd   a0rG  r|  re   r=   r=   r>   rh     s$   

 
zTestMedian.test_basicc                 C   s   t ddgddgddgddgg}|t jjdd	d
dfD ]!}| }t j|d d t|jD ]	}t j||d q.t|| qt	t j|ddddg t	t j|j
ddddg t	t |d t	t j|d dd t	t |j
d d S )NrL   rV   r   rN   rq   rr   rJ   rW   r&  r   r"  rz   r  )r7   r   r  randintr   r  rc   r   r	   r   r9  )rd   a3re   origaxr=   r=   r>   test_axis_keyword
  s    
zTestMedian.test_axis_keywordc                 C   s  t ddgddgddgddgg}t d}t d}t ddd}tt j| d	d
d tt j| d	d
d tt j| d	d
d tt j| d	ddg d tt j| d	ddddg tt j| d	d dd tt j| d	ddddg tt j|j d	ddddg t jdt jdd}t j	
|  tt j|d dt j| d d	d tt j|ddt j| dd	d tt j|ddt j| dd	d tt j|ddt j| dd	d d S )NrL   rV   r   rN   rq   rr   rJ   rW   Tr  r  r  )r  r{   r  r  r   rU   rz   )r{   r  )r7   r   r8   rs   r   r  r   r9  r   r  r/  r0  )rd   r  r  rG  r|  Za4r=   r=   r>   test_overwrite_keyword  sP   


z!TestMedian.test_overwrite_keywordc                 C   sF   g d}t t|d |g}t t|d ttj|dd| d S )Nr   rL   r   rz   )r
   r7   r  r   )rd   r   r  r=   r=   r>   r  =  s
   zTestMedian.test_array_likec                 C   s2   G dd dt j}|g d}tt |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 || }||_|S r6   )r7   r  r   info)clsZinput_arrayr  objr=   r=   r>   __new__H  s   z4TestMedian.test_subclass.<locals>.MySubClass.__new__c                 S   rr  )Nr=   )rd   r{   r   r  r=   r=   r>   r   M  rt  z1TestMedian.test_subclass.<locals>.MySubClass.meanr6   )NNN)ru   rv   rw   r  r   r=   r=   r=   r>   
MySubClassF  s    
r  r   r  )r7   r   r   r  )rd   r  re   r=   r=   r>   rB  D  s   
zTestMedian.test_subclassr  r   r   r   r   c                 C   s:   G dd dt j}t t ||}t||sJ dS )z6Check that we return subclasses, even if a NaN scalar.c                   @   r   )z-TestMedian.test_subclass2.<locals>.MySubclassNr   r=   r=   r=   r>   
MySubclassW  r   r  N)r7   r   r  r   r   r@  )rd   r  r  r  r=   r=   r>   test_subclass2S  s   zTestMedian.test_subclass2c                 C   sl   t d}t d}tt j|d|d| t d}tt j|d|d| t d}tt j||d| d S )NrG  rm  r   r  r   rN   r=   )r7   r@   rb   r   r  rH  r=   r=   r>   rI  ]  s   



zTestMedian.test_outc                 C   s   t jddI t ddt td}td}tj|d< ttj	|d|d	| td
}ttj	|d|d	| td}ttj	||d	| W d    d S 1 sRw   Y  d S )NTr,  r.  r/  rG  rm  r)  r   r  r   rN   r=   )
r1  r2  r3  r*  r7   r@   rb   r  r   r  rH  r=   r=   r>   rJ  f  s   




"zTestMedian.test_out_nanc                 C   sf  t jdtd}t j|d< tt |t j tt j|ddt j t jdtdddd}t j|d< t j|d	< tt |t j tt |jd t t jdtddddd}t j|d
< t j|d< tt |d| t t jdtddddd}t j|d< t j|d< tt |d| t t jdtddddd}t j|d< t j|d< tt |d| d S )Nr6  r   rL   r   rz   rV   rJ   r   rK  rE  rl   rN   r+  rR   )r7   r8   rL  r  r   r  rs   r   r   r=   r=   r>   rL  r  s*   


 

 

 

zTestMedian.test_nan_behaviorzfp errors don't work correctlyr  c                 C   s  t jg td}tjdd(}tddt tt |t j	 t
|d jtu  tt|d W d    n1 s8w   Y  t jg tdd	}tjdd!}tddt tt |t j	 t
|d jtu  W d    n1 sow   Y  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ddt tt j|dd
| t
|d jtu  W d    d S 1 sw   Y  d S )Nr   Tr,  r.  r/  r   rL   rV   )r   r9  rz   rN   )r7   r   rL  r1  r2  r3  r*  r   r  r  r   r5  r  )rd   re   r   r   r=   r=   r>   r+    s,   "zTestMedian.test_emptyc                 C   sL   t d}ttt |tt t j|d< ttt |tt d S )Nrc  rL   )	r7   r8   r   r   r  r   r  rL  r  )rd   r  r=   r=   r>   test_object  s   

zTestMedian.test_objectc              
   C   s  t jjdd}t |gd }tt j|ddt | t |dd}tt j|ddt | |dd	 }tt j|d
dt | 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 	d
d}t j|  tt j|ddd t |d d d d d d df   tt j|ddd	 t |d d d d d	d d f   tt j|ddd t |d d d d dd d f   tt j|ddd t |dd d d d d d f   tt j|ddd t |dd	d d d d f   tt j|ddd t |dd d d d d	f   tt j|ddd t |dd d dd d f   d S )Nr  r"  r   r^   rz   r]   r   rm   rN   rk   rM   r(  )r]   r#  r$  r&  r'  rL   r(  r  r)  r*  r+  rQ   )r7   r  r,  r-  r   r  r.  r   r   r8   rs   r/  r0  r1  r2  r=   r=   r>   r3    sB   $$$$   zTestMedian.test_extended_axisc                 C   sp   t 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 )Nr$  rV  rz   r4  rJ   r5  rS   )r7   rb   r   r~   r  ra   r  r=   r=   r>   r6    s   
z%TestMedian.test_extended_axis_invalidc                 C   s   t 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 )Nr$  Tr   r   r^   r7  r}   r8  r   r9  r  r&  r:  )r7   rb   r   r  rB   r  r=   r=   r>   r;    s&   
zTestMedian.test_keepdimsr{   r<  r=  c                    s   t d|d u rdj }nt|j t fddtjD }t |}t j|d|d}||u s8J t|j	| d S )Nr$  r   c                 3   r?  r@  rA  rt  rB  r=   r>   r    rC  z/TestMedian.test_keepdims_out.<locals>.<genexpr>TrD  )
r7   rb   r   r5   r  rc   r
  r  r   rB   )rd   r{   rE  r  r  r=   rB  r>   rF    s   

zTestMedian.test_keepdims_outr   zm8[s]rN  rO  c                 C   s   t jdd|d}d||< t |}|j|ksJ t |sJ t |ddg}|j|ks.J t | s7J t jdd|ddd	}d||d
f< t j|dd}tt |g d d S rP  )	r7   r8   r  r   rR  r  r   rs   r	   rS  r=   r=   r>   test_nat_behavior  s   
zTestMedian.test_nat_behaviorN)ru   rv   rw   rh   r  r  r  rB  r   r   r   r7   r  r  rI  rJ  rL  r  r   r+  r  r3  r6  r;  rF  r  r=   r=   r=   r>   r~    s6    !
	 


r~  c                   @   r   )TestAdd_newdoc_ufuncc                 C   s"   t ttdd t tttjd d S )NrL   Zblah)r   r#  r   ra   r7   r9   r   r=   r=   r>   test_ufunc_arg  s   z#TestAdd_newdoc_ufunc.test_ufunc_argc                 C   s   t tttjd d S )NrV   )r   r#  r   r7   r9   r   r=   r=   r>   test_string_arg  s   z$TestAdd_newdoc_ufunc.test_string_argN)ru   rv   rw   r  r  r=   r=   r=   r>   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ejjejjdkdddd Zd	S )
TestAdd_newdocrL   Python running -OOr  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.r  )r   r7   coreflatiterindexry  r  r   Zufuncidentityr  Zindex_tricksZmgrid)rd   r}  r=   r=   r>   test_add_doc"  s   zTestAdd_newdoc.test_add_docc                 C   s2   t jjjj}t ddd |t jjjjksJ d S )Nz
numpy.corer  )r  zbad docstring)r7   r  r  r  ry  Z
add_newdoc)rd   Zprev_docr=   r=   r>   test_errors_are_ignored+  s   z&TestAdd_newdoc.test_errors_are_ignoredN)ru   rv   rw   r   r   r  r  r   r  r  r   r  r  r=   r=   r=   r>   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
ejjejjdkdddd Zd	S )
TestAddDocstringrL   r  r  r  c                 C   s0   t t jjt jjj dd }t ||j d S )Nc                   S   rr  	docstringNr=   r=   r=   r=   r>   func=  rw  z6TestAddDocstring.test_add_same_docstring.<locals>.func)r7   add_docstringr   flatry  rd   r  r=   r=   r>   test_add_same_docstring7  s   z(TestAddDocstring.test_add_same_docstringc                 C   sz   t t ttjjd W d    n1 sw   Y  dd }t t t|d W d    d S 1 s6w   Y  d S )Nzdifferent docstringc                   S   rr  r  r=   r=   r=   r=   r>   r  I  rw  z=TestAddDocstring.test_different_docstring_fails.<locals>.func)r   rI  r7   r  r   r  r  r=   r=   r>   test_different_docstring_failsC  s   

"z/TestAddDocstring.test_different_docstring_failsN)ru   rv   rw   r   r   r  r  r   r  r   r  r  r=   r=   r=   r>   r  4  s    
r  c                   @   s.   e Zd Zejdg ddd Zdd ZdS )TestSortComplexztype_in, type_out))lr  )hr   )Hr   )r   r   )r!  r   )r  r  c                 C   sH   t jg d|d}t |}t ||}t|| t|j|j d S )N)rW   rV   rq   rL   rN   r   )r7   r   sort_complexr  r   r   r   )rd   Ztype_inZtype_outre   r   r  r=   r=   r>   test_sort_realS  s
   


zTestSortComplex.test_sort_realc                 C   sJ   t jg ddd}t jg ddd}t |}t|| t|j|j d S )N)r        ?       r
  r  r  r   )r
  r  r  r  )r7   r   r  r   r   )rd   re   r  r   r=   r=   r>   test_sort_complexc  s
   

z!TestSortComplex.test_sort_complexN)ru   rv   rw   r   r   r   r  r  r=   r=   r=   r>   r  Q  s    
r  )r   )r   r   )r  r1  r  r   	fractionsr   r3  r   ro  Zhypothesis.extra.numpyr   Zhypothesis.strategies
strategiesrq  	functoolsr   numpyr7   r   Znumpy.testingr   r   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/   r0   r1   r2   r3   r4   Znumpy.core.numericr5   r?   rG   rI   ry   r   r   r   r   r   r)  rS  r_  ra  rd  r~  r  r  r  r  r  r  r*  r6  r8  r9  r  r  r  r   r   rU  r  r  r  r  r  r	  r8  rO  rR  rY  rc  ry  r  r  r  rn  rV  rs  r~  r  r  r  r  r=   r=   r=   r>   <module>   s    <Dg# >o u  A
)
   j)Ul>[j4nd` C    * R2  &
