o
    0ZcG?                    @   s.  d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlZd dlZd dl	m
Z
 d dlmZ d dlZd dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZ d dl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,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZD dd	 ZEd
d ZFG dd dZGG dd dZHG dd dZIG dd dZJG dd dZKG dd dZLG dd dZMG dd dZNG dd dZOG dd dZPG d d! d!ZQG d"d# d#ZRG d$d% d%ZSG d&d' d'ZTG d(d) d)ZUG d*d+ d+ZVG d,d- d-ZWG d.d/ d/ZXG d0d1 d1ZYG d2d3 d3ZZdtd5d6Z[dud8d9Z\G d:d; d;Z]G d<d= d=Z^G d>d? d?Z_G d@dA dAZ`ejabdBdCejcdD  ejcdE  ejabdFg dGG dHdI dIZdG dJdK dKZeG dLdM dMZfG dNdO dOZgG dPdQ dQZhG dRdS dSZiG dTdU dUZjG dVdW dWZkG dXdY dYZlG dZd[ d[ZmG d\d] d]ZnG d^d_ d_ZoG d`da daZpG dbdc dcZqG ddde deZrG dfdg dgZsG dhdi diZtG djdk dkZuG dldm dmZvG dndo doZwG dpdq dqZxG drds dsZydS )v    NFraction)arrays)ma)assert_assert_equalassert_array_equalassert_almost_equalassert_array_almost_equalassert_raisesassert_allcloseIS_PYPYassert_warnsassert_raises_regexsuppress_warningsHAS_REFCOUNT)rand) add_newdoc_ufuncangleaveragebartlettblackmancorrcoefcovdeletediffdigitizeextractflipudgradienthamminghanningi0insertinterpkaisermeshgridmsort	piecewiseplacerot90selectsetxor1dsinctrapz
trim_zerosunwrapunique	vectorizec                 C   s   t | }t j||}|S N)nparangeaddouter)ndata r:   X/var/www/chikooza/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
    )r4   zeros	broadcastshapecomplex_realimag)rA   rB   retr:   r:   r;   _make_complex$   s   rD   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      rI   rI   r      rI   axesrI   rI   r   rI   rK   rK   )rK      rG      rI   rT   rK   r   rS   rT   rG   rS   rI   rK   r      )krQ   r   rK   rK   r   rY   rM   )r   
ValueErrorr*   r4   onesranger   )selfab1b2b3b4rY   r:   r:   r;   
test_basic0   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   (   rS   )ri   rh   rS   rO   rL   r   rZ   rK   rI   rQ   rZ   )r4   r_   r   r*   r?   ra   rb   r:   r:   r;   	test_axesP   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   rH   rI   rS         r   rK   rG   rT   r[   rL   r\   rk   )rI   r   r]   )r4   r5   reshaper   r*   r`   )ra   rb   
a_rot90_01
a_rot90_12
a_rot90_20
a_rot90_10rY   r:   r:   r;   test_rotation_axesV   sJ   zTestRot90.test_rotation_axesN)__name__
__module____qualname__rg   rn   rw   r:   r:   r:   r;   rF   /   s     rF   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 )NrG   rK   axisrG   rG   rI   rW   r   rS   )r   r4   	AxisErrorflipr_   ra   r:   r:   r;   rn   u   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 )NrG   rZ   rK   rJ   rR   rV   rU   r<   r   r4   r   ra   rb   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 )NrG   rZ   r   rJ   rR   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   rK   rI   rS   rG   rT   rp   rq   r4   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   rI   rS   rG   rT   r   )	r4   r5   rr   r`   ndimr   r   r   swapaxes)ra   rb   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rK   rI   rS   rG   rT   rp   )rp   rT   rG   rS   rI   rK   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   rK   rI   rS   rG   rT   rp   rq   r:   r}   rO   rk   r   ra   rb   r   cr:   r:   r;   test_multiple_axes   s0   


zTestFlip.test_multiple_axesN)rx   ry   rz   rn   r   r   r   r   r   r   r   r   r:   r:   r:   r;   r|   s   s    

r|   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   rK   r   r   r   r   r   )rK   r   rK   r   )r   r4   anyra   y1y2y3r:   r:   r;   rg      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   rK   r   rK   rK   r   r   r}   rK   r   rK   rK   )r   r4   r   r   sometruera   r   r:   r:   r;   test_nd   s   zTestAny.test_ndNrx   ry   rz   rg   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   rK   rK   r   r   rK   rK   rK   rK   )r   r4   allr   r   r:   r:   r;   rg      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   rK   r   rK   rK   rK   r   r}   rK   )r   r4   r   r   alltruer   r:   r:   r;   r      s   zTestAll.test_ndNr   r:   r:   r:   r;   r      s    	r   c                   @   rE   )TestCopyc                 C   sR   t ddgddgg}t |}t|| d|d< t|d d t|d d d S )NrK   rI   rS   rG   
   )r   r   )r4   r   copyr   r   )ra   rb   a_copyr:   r:   r;   rg      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 )NrK   rI   rS   rG   Forder)r4   r   r   flagsc_contiguousf_contiguousr   )ra   rb   a_fortr   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 )NrT   F)subokT)r   r_   r   isMaskedArrayr4   r   )ra   mxr:   r:   r;   
test_subok  s   
zTestCopy.test_subokN)rx   ry   rz   rg   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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   r}          @      ?r         @)        r   r   r   r   r[   rI   r\   rK   rT   )r4   r   r   r   r_   r	   meanr   )ra   r   r   r   y4y5r:   r:   r;   rg   "  s   

zTestAverage.test_basicz<x, axis, expected_avg, weights, expected_wavg, expected_wsumr   Nr   )rS   rG   rK         ?       @)rK   rI   rT   )rK   rp      r   )r         @r   rK   rS   )r         @      #@rG   rG   rG   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   )r4   r   r?   r   )
ra   xr~   expected_avgr   expected_wavgexpected_wsumavgwavgwsumr:   r:   r;   test_basic_keepdims4  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   rI   r   r   r   rK   r   )r   r~   )r   r   r   r   r         @)r   r   rI   r   rT   rI   rS   rG   rS   F)r   r~   r   )r   r   r   Tr   r   )r4   r5   r   sumr	   r   r   r   r   astypefloat32float64r   dtyperesult_typerr   )ra   ywactualdesiredr   w0w1w2r   w3r   r:   r:   r;   test_weightsK  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   rK   r   rI   )r   r~   r   )r   r   r   r   r   )r4   r   r   r   r   )ra   r   r   sclr   r   r   r:   r:   r;   test_returnedw  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rx   ry   rz   r:   r:   r:   r;   subclass      r   rK   rI   rS   rG   r   )r4   ndarrayr   viewr   typer   )ra   r   rb   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   rK   rI   rS   rG   r   r   )r4   r   r   r   r   )ra   typsatwtrtrb   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 rK   r  )r
  _r:   r:   r;   r    r  r   r   )r4   r   r`   r   r	   r   r   )ra   rb   r   r:   r:   r;   test_object_dtype  s   zTestAverage.test_object_dtype)rx   ry   rz   rg   pytestmarkparametrizer   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   rq   ro   	   )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>)r`   lenzip)ra   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   rS   )choices
conditionsr   r+   r"  r   r  ra   r%  r&  r:   r:   r;   rg     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  rK      rG   rS   rG   rS   r   r$  r  )	r4   r   r5   rr   r   r+   r_   r   r?   ra   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   r4   int8)r
  choicer:   r:   r;   r        z0TestSelect.test_return_dtype.<locals>.<listcomp>rK   rI   rS   rT   rq   r   )r   r+   r&  r%  r   r4   r@   r-  r   nanisnan)ra   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   r^   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   r4   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   rK   )r4   r   r+   r*  r:   r:   r;   test_many_arguments  s   zTestSelect.test_many_argumentsNr   )rx   ry   rz   r4   r   r%  r&  r"  rg   r+  r3  r5  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   rK   )rK   rK   rI   rS   rS   )rK   rI   rS   rK   r   )rK   rK   rI   rS   rI   rS   )rK   rZ   rS   r  )rK   r  rI   r  rS   r  rZ   )r  rK   r  rI   r  rS   rZ   rK   rS   r  )rK   ro   rI   rq   rS   r  r  r   r   r   Trecordalways rG   )rK   r  r  r  r  rI   rS   )r   r#   slicer4   r   r   warningscatch_warningsfilterwarningsFutureWarningr   category)ra   rb   r   r   r:   r:   r;   rg     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   rH   r   rK   r   r}   rI   )rK   rK   rI   rK   rS   rG   r      r   rZ   rQ   )r   r#   r4   r   r5   repeatrr   concatenateTr   r   )ra   rb   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 )NrK   rI   r   r}   nonsense)r4   r   r  raisesr   r#   r8  rm   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;   SubClass.  r   rU  r   r   rK   rI   rQ   rZ   )	r4   r   r5   r   r   
isinstancer#   rE  r   ra   rU  rb   r:   r:   r;   test_subclass-  s    " zTestInsert.test_subclassc                 C   s<   t g d}t g d|g d t|t g d d S )Nr   rJ   rR   )r4   r   r#   r   ra   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))rK   rb   )rI   r   )rS   r   )foor   )bara1r  )rG   r2  r   rI   rS   )r4   r   r#   r   r   )ra   rb   valr   r:   r:   r;   test_structured_array?  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 )NrJ   r   r   r      r  )r  rS  
IndexErrorr4   r#   r   floatr   r:   r:   r;   test_index_floatsI  s   ""zTestInsert.test_index_floatsidxrG   rL  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matchrJ   rS   rG   )r  rS  ra  r4   r#   )ra   rd  r:   r:   r;   test_index_out_of_boundsO  s   "z#TestInsert.test_index_out_of_boundsN)rx   ry   rz   rg   rQ  rT  rX  rZ  r_  rc  r  r  r  rg  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rS   rG   rT   r   rW   r         $@rS   r         "@rG   rm  r   ro   r   r   r   r}   )r   rm  ro  rK   )ro  rm  r   )r   r4   amaxr   r:   r:   r;   rg   W     zTestAmax.test_basicNrx   ry   rz   rg   r:   r:   r:   r;   ri  U      ri  c                   @   rh  )TestAminc                 C   rj  )Nrk  g      rn  rp  rq  r   r}   )r   r   r   rK   )r   r   r   )r   r4   aminr   r:   r:   r;   rg   c  rs  zTestAmin.test_basicNrt  r:   r:   r:   r;   rv  a  ru  rv  c                   @   rh  )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 )Nrk  r   r}         .@rn  rp  rq  )r         @rz  rZ   )r   r   r   Tr   r[   r   )r4   r   r   ptpr   r:   r:   r;   rg   o  s   
zTestPtp.test_basicNrt  r:   r:   r:   r;   rx  m  ru  rx  c                   @   rh  )
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rK   rI   r   r   rp   rT   rG   rK   rI   rS   rG   rT   rp   rq   r  r   rS   rG   rT   )rK   rS   rX   rK     #   '   r   r}   )rp   ro   r   rX   )   r         )rK   rS   rp   r   )rT   r   r     )r   rX         rK   )r4   r-  r9  int16uint16int32uint32r   r   	complex64
complex128r   r   cumsum)ra   baba2ctyperb   a2tgtr:   r:   r;   rg   ~  s&   zTestCumsum.test_basicNrt  r:   r:   r:   r;   r|  |  ru  r|  c                   @   rh  )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 )Nr}  r~  r  r  1r   rK   r   r}    g  rh   $   T      rZ   )rK  b  X  )r4   r  r  r  r  r   r   r  r  r   r   ArithmeticErrorprodr   r   ra   r  r  r  rb   r  r:   r:   r;   rg     s$   zTestProd.test_basicNrt  r:   r:   r:   r;   r    ru  r  c                   @   rh  )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 )Nr}  r~  r  r  r  rK   rZ   r}   )rK   rI   r`     i(  i  r  r   )rT   r(     r  r  )rK   rI   rp   rK  )rT   r     r  )r   r  r   r  )r4   r  r  r  r  r   r   r  r  r   r   r  cumprodr   r  r:   r:   r;   rg     sB   


zTestCumprod.test_basicNrt  r:   r:   r:   r;   r    ru  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)rK   rG   rp   rq   r(  )rS   rI   rK   rT   )rZ   rZ   rG   r   rT   rI   r8   rS   )皙?皙@r   gɿ皙)r  g?g	皙?)TTFFr  T)r4   r   r   r   r	   )ra   r   outout2out3r:   r:   r;   rg     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   r`  r  rK   rI   )r      r  rZ   )r   r`     r}   r   )r  r`  r  rQ   rS   rL  gq?)
r4   r=   r_   r   r   r   r   r   r   r^   )ra   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 )Nr`  r   r  rK   rZ   rI   r  r   r}   )r8   r~   )r   r   r   )ra   r   out1r  r  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 )
NrS   rZ   r  c                    s   g | ]}t  |d qS )r  )r   )r
  r8   r   r:   r;   r    r/  z#TestDiff.test_n.<locals>.<listcomp>rK   rT   r   start)listr`   r   r^   r   r   	enumerater  r   r4   r   r   r   r   r7  r  max)ra   r!  expectedr8   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  rK   timedelta64[D]r   rS   r  r  )
r4   r5   
datetime64r   extendr  r   r   r   r   )ra   r   r  r8   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 )NrK   rI   rS   rG   rT   rp   rq   ro   r  r   FTmaskr  )r   r   r   r   r9   r  r   r   )ra   r   r  r  r:   r:   r;   rX  
  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 )NrT   rK   r   )prependrZ   rp   rG   rI   )r~   r  rS   rS   rS   )r  r~   )r4   r5   r   r   r_   r  rr   r   r^   r=   r   ra   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 )NrT   r   )append)rK   rK   rK   rK   rL  rI   rG   rK   )r~   r  rZ   rW   rQ   r  rS   )r  r~   )	r4   r5   r   r   rr   r   r^   r=   r   r  r:   r:   r;   test_append1  s,   








zTestDiff.test_appendN)rx   ry   rz   rg   r  r   r  r  rX  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 )NrT   rI   rK   )r4   r5   rb   rM  rr   nd_ar   r:   r:   r;   setup_methodP  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 )NrK   r}   zDelete failed for obj: %r)err_msgr   )r   rb   r  r   r,   )ra   indicesa_delnd_a_delmsgxorr:   r:   r;   _check_inverse_of_slicingT  s   $"z$TestDelete._check_inverse_of_slicingc                 C   sH   g d}g d}|D ]}|D ]}|D ]}t |||}| | qqq
d S )N)rQ   r   rK   rI   rG   rT   )rW   rZ   rK   rS   )rE  r  )ra   limsstepsr  stopstepsr:   r:   r;   test_slices]  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   rK   rI   r;  i)r   rZ   rI   rI   )TFFTFTFrG   )	r  r4   r   r  rS  ra  r   rb   r^   r   r:   r:   r;   
test_fancyf  s$   "zTestDelete.test_fancyc                 C   s   |  d |  d d S )Nr   rL  )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 )NrK   r   r}   rR  )r4   r   r  rS  r   r   r8  rm   r:   r:   r;   rT    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;   rU    r   rU  r   rK   rI   rQ   )r4   r   rb   r   r   rV  r   rE  rW  r:   r:   r;   rX    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   rI   rT   r   r   <   rK   r}   )	r4   r5   rr   r   rE  r   r   r   r   )ra   rY   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 )NrJ   r   r   r  )r  rS  ra  r4   r   r   rb  r   r:   r:   r;   rc    s   "zTestDelete.test_index_floatsindexerrK   c                 C   sX   t | jd}t | j|}t|| t | jddd}t | jtdgdd}t|| d S )NrK   r}   )r   rb   r   r  r4   r   )ra   r  	a_del_intr  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 )NrK   F)rS   rK   r  TrZ   r}   r   rI   zm8[ns])
r   r4   r_   r   r   boolr  rS  ra  object)ra   resr   
false_mask	true_maskr:   r:   r;   test_single_item_array_non_int  s   

"z)TestDelete.test_single_item_array_non_intN)rx   ry   rz   r  r  r  r  r  rT  rX  r  rc  r  r  r  r4   r   r  r  r:   r:   r:   r;   r  N  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!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 )NrK   rS   rG   r   r   r   r   )r4   r   r   r   ra   vr   dxr:   r:   r;   rg     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 )NrT   )r   r   r   ro        &@   r         ?rI   rK   r}   z.*scalars or 1drZ   )
r4   r  r_   r5   rr   r   r   r   r^   stack)ra   r  	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  rT   rI   rK   r[   r}   )	r4   r5   rr   r  r_   r   r^   r   r8  )ra   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  )rl  rW   r      =   i  i  r  r4   r   r   r   r   r   ra   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 )NrK   rS   rG   Fr  r   rT   rI   
edge_order)FFTFF)r4   r   r   r   r   r   r   _maskr5   maskedr   r  )ra   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   rK   r   rI   rS   rG   rp   ro   r  gQ?T)	r4   linspaceabsr   r   r   randomseedsort)ra   r   r  r   
analytical	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   )rp   rK   rZ   rK   )r         ?r   r   r   rz  r   )r   r  r   r   r
  r   )      @r  r   r   r
        )r   r   333333?r
        ?r   )r   r   r  r
  r  g      пrI   r   r[   )r~   r  r   r\   )r4   r   tilerr   r5   r   r   r	   rO  r   r?   )ra   fx_unevenx_evenfdx_even_ord1fdx_even_ord2fdx_uneven_ord1fdx_uneven_ord2r  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 )NrK   rS   rG   r   r   r   r   r   r}   rZ   r\   rI   rW   )r4   r   r   r   r	   r   r8  r   r  r:   r:   r;   test_specific_axese  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)rl  rW   r   r(  r  iA  ,  r  r  )rI   rq   rq   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  )	r4   float16r   r   r   r   r   r   r   )ra   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 )NrI   rK   r  rS   r   )r   r4   r5   r   r^   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)rT   rG   rS   rI   rK   r  rZ   r4   r   r   r   r  )ra   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 )NrK   rS   rZ   r  rI   )r4   iinfor  r   r   r   )ra   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   rI   rG   rQ   r&  )ra   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 )NrZ   r  rI   r   r
  )r4   r)  minr  r   r   r   )ra   r-  minintr*  r   r  r+  r:   r:   r;   test_x_signed_int_big_jump  s   
z'TestGradient.test_x_signed_int_big_jumpN)rx   ry   rz   rg   r  r  r  r  r	  r  r  r   r#  r$  r  r  r  r4   r9  r  r  uint64r(  r-  r  r  int64r,  r/  r2  r:   r:   r:   r;   r    s8    @


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      ?      @rI   r   r,  rK   rZ                      ?      y            @r   r   r   T)degr  r   )r4   sqrtr   arctanpir   r
   )ra   r   r   yozzor:   r:   r;   rg     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 )Nr6  rK   rI         ?      ?r   r   r   )
r4   r   r   r:  r  r;  r   r   r   r  )ra   r   r  r   r:   r:   r;   rX    s    zTestAngle.test_subclassN)rx   ry   rz   rg   rX  r:   r:   r:   r;   r5        r5  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   rK   r   rI   rS   rG   r   c                    s   d} fdd|D S )N)rb   r   r   r2  c                 3   s    | ]}t  |V  qd S r3   )getattr)r
  namer   r:   r;   	<genexpr>      z'TestTrimZeros.values.<locals>.<genexpr>r:   )ra   
attr_namesr:   r   r;   r    s   zTestTrimZeros.valuesc                 C   s6   t jdd }|  D ]}t|}t|||  qd S )NrI   rZ   r4   s_r  r/   r   ra   slcarrr  r:   r:   r;   rg     s
   zTestTrimZeros.test_basicc                 C   s:   t jd d }|  D ]}t|dd}t|||  qd S )NrZ   r   trimrH  rJ  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 )NrI   r   rM  rH  rJ  r:   r:   r;   test_trailing_skip  rP  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  BrM  r   r  )r  r4   
zeros_liker   r/   r  )ra   _arrrL  r  r  r:   r:   r;   test_all_zero  s   zTestTrimZeros.test_all_zeroc                 C   s    t d}t|}t|| d S r6  )r4   r=   r/   r   ra   rL  r  r:   r:   r;   test_size_zero   s   
zTestTrimZeros.test_size_zerorL  )r   l            r   )r   l            r   )r   l            r   c                 C   s(   t jdd }t|}t|||  d S )NrK   rI   )r4   rI  r/   r   )ra   rL  rK  r  r:   r:   r;   test_overflow  s   zTestTrimZeros.test_overflowc                 C   s$   t g d}t|}t|| d S )N)NrK   N)r4   r   r/   r   rV  r:   r:   r;   test_no_trim  s   zTestTrimZeros.test_no_trimc                 C   s    t | j }t|tsJ d S r3   )r/   rb   tolistrV  r  )ra   r  r:   r:   r;   test_list_to_list  s   zTestTrimZeros.test_list_to_listN)rx   ry   rz   r4   r   rb   r   rb  r   complexr   r  r2  r  rg   rO  rQ  rU  rW  r  r  r  rX  rY  r[  r:   r:   r:   r;   rB    s*    




rB  c                   @   rE   )
TestExtinsc                 C   s.   t g d}t|dk|}t|g d d S )N)rK   rS   rI   rK   rI   rS   rS   rK   )rS   rI   rI   rS   rS   )r4   r   r   r   r   r:   r:   r;   rg     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   rK   )rK   rG   rS   rI   rT   ro   rq   )r   rK   r   rK   r   rK   r   rI   rG   rp   )rK   rI   rS   rG   rT   rp   rq   rq   ro   )rK   r   rK   r   rK   r   rK   r  )ro   rI   r  rG   ro   rp   r  z!Cannot insert from an empty arrayc                      s   t  g dg S )N)r   r   r   r   r   rK   r   )r)   r:   rb   r:   r;   <lambda>0  s    z'TestExtins.test_place.<locals>.<lambda>12349)
r   r8  r)   r4   r   r   r=   r5   r   r^   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   )ra   rb   r  acr   r:   r:   r;   	test_both7  s   
zTestExtins.test_bothN)rx   ry   rz   rg   rd  rf  r:   r:   r:   r;   r]    s    r]  r   c                 C   s   |t |  S r3   mathfloorr   r   r:   r:   r;   _foo1C     rk  r   c                 C   s   |t |  | S r3   rg  )r   r   r>  r:   r:   r;   _foo2G  s   rm  c                   @   s$  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGS )HTestVectorizec                 C   s4   dd }t |}|g dg d}t|g d d S )Nc                 S      | |kr| | S | | S r3   r:   rb   r   r:   r:   r;   addsubtractN     z.TestVectorize.test_simple.<locals>.addsubtractr   rS   rp   r  rK   rS   rT   rq   rK   rp   rK   rI   r2   r   ra   rq  r  rP  r:   r:   r;   test_simpleM  s   zTestVectorize.test_simplec                 C   s0   dd }t |}|g dd}t|g d d S )Nc                 S   ro  r3   r:   rp  r:   r:   r;   rq  Y  rr  z.TestVectorize.test_scalar.<locals>.addsubtractrs  rT   )rT   ro   rK   rG   rv  rw  r:   r:   r;   test_scalarX  s   zTestVectorize.test_scalarc                 C   s0   t ddd}tdd }||}t|| d S )NrW   rI   i'  c                 S      | S r3   r:   r  r:   r:   r;   r`  e      z*TestVectorize.test_large.<locals>.<lambda>)r4   r  r2   r   )ra   r   r  r   r:   r:   r;   
test_largec  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  rI   )r2   rh  cosr4   r   r<  r
   )ra   r  argsr1r2r:   r:   r;   
test_ufunci  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 )	NrK   c                 S      | | S r3   r:   rp  r:   r:   r;   r[  r     z(TestVectorize.test_keywords.<locals>.foor   r   rI   rR   r  r2   r4   r   r   ra   r[  r  r~  r  r  r:   r:   r;   test_keywordsp  s   


zTestVectorize.test_keywordsc                 C   s:   t ttgd}|tdd}|td}t|| d S Notypesr   r   r2   rk  rb  r4   r5   r   ra   r  r  r  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 r  r  r  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 )Nr  r   r   r   r  ra   r  r  r  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 )Nr  $@r;  )r>  rZ   r  r2   rm  rb  r   r  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 )	Nr  r;  r  rZ   )r>  r   r   rK   rI   rS   r  r  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 r6  )r  r2   	randrange	ExceptionAssertionError)ra   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 )NrK   c                 S   r  r3   r:   rp  r:   r:   r;   r[    r  z5TestVectorize.test_keywords2_ticket_2100.<locals>.foor   r_  r   )r   rb   rI   r   rR   r  r  r  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 r6  )r  pop)r   p_pr  r:   r:   r;   	mypolyval  s   
z;TestVectorize.test_keywords3_ticket_2100.<locals>.mypolyvalr  rK   )excludedrS   rp   r   r   )r   r  )r  )r4   r2   r   )ra   r  vpolyval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  _kr:   r:   r;   r    s   z3TestVectorize.test_keywords4_ticket_2100.<locals>.frK   rI   rS   rG   rp  ro   rv  ra   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 r3   )r4   r  )r  r:   r:   r;   r    s   
z3TestVectorize.test_keywords5_ticket_2100.<locals>.frK   rI   rS   rG   ro   rv  r  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 NrK   r:   r:   r:   r:   r;   r[       z5TestVectorize.test_coverage1_ticket_2100.<locals>.foorK   rv  ra   r[  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   rz  )zOriginal documentationr:   r  r:   r:   r;   r[       z3TestVectorize.test_assigning_docstring.<locals>.foozProvided documentation)doc)r2   r   __doc__)ra   r[  r  r  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>.FoorI   c                 S   s
   || j  S r3   r  rm   r:   r:   r;   r\    s   
z=TestVectorize.test_UnboundMethod_ticket_1156.<locals>.Foo.barN)rx   ry   rz   r   r\  r:   r:   r:   r;   Foo	  s    r  r  rI   )r   r2   r\  r4   r5   )ra   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   rz  r3   r:   r  r:   r:   r;   r`    r{  z@TestVectorize.test_execution_order_ticket_1487.<locals>.<lambda>rS   r  c                 S   rz  r3   r:   r  r:   r:   r;   r`    r{  )r2   r4   r5   r   )ra   f1res1ares1bf2res2b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   rz  r3   r:   r  r:   r:   r;   r`  !  r{  z7TestVectorize.test_string_ticket_1892.<locals>.<lambda>d0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789)r4   r2   r   )ra   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   rK   rI   r:   r  _callsr:   r;   r  )  s   z#TestVectorize.test_cache.<locals>.fTrT   )r2   cacher4   r5   r   r   r  ra   r  r   r:   r  r;   
test_cache%  s   
zTestVectorize.test_cachec                 C   s0   t dd }d|_t d}t||| d S )Nc                 S   rz  r3   r:   r  r:   r:   r;   r`  4  r{  z+TestVectorize.test_otypes.<locals>.<lambda>r   rT   )r4   r2   r  r5   r   r  r:   r:   r;   test_otypes3  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)->()rj  z(x),(y)->()r  z(x)->(y)z(x)->(y),()z(),(a,b,c),(d)->(d,e))r:   )rb   r   r   )r2  )r2  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   nfb_parse_gufunc_signaturer   r^   r   r:   r:   r;   test_parse_gufunc_signature9  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   ro  r3   r:   rp  r:   r:   r;   rq  \  rr  z8TestVectorize.test_signature_simple.<locals>.addsubtractz	(),()->()	signaturers  rt  ru  rv  rw  r:   r:   r;   test_signature_simple[  s   z#TestVectorize.test_signature_simplec                 C   s:   dd }t |dd}|ddgddgg}t|ddg d S )	Nc                 S   s   |   S r3   r   r_  r:   r:   r;   r   g  r  z4TestVectorize.test_signature_mean_last.<locals>.meanz(n)->()r  rK   rS   rI   rG   rv  )ra   r   r  rP  r:   r:   r;   test_signature_mean_lastf  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 r3   r  r_  r:   r:   r;   centero  s   z3TestVectorize.test_signature_center.<locals>.center(n)->(n)r  rK   rS   rI   rG   rZ   rv  )ra   r  r  rP  r:   r:   r;   test_signature_centern  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 r3   r:   r  r:   r:   r;   r`  w      z:TestVectorize.test_signature_two_outputs.<locals>.<lambda>	()->(),()r  r   rI   r   rK   )r2   r   rV  tupler  r   ra   r  rP  r:   r:   r;   test_signature_two_outputsv  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  rK   rI   r   r^  r   r   )r2   r4   r7   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 NrZ   r:   r  r:   r:   r;   r`        z<TestVectorize.test_signature_computed_size.<locals>.<lambda>z(n)->(m)r  r   rK   rI   r   rS   rv  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 )NrK   c                 S   r  r3   r:   rp  r:   r:   r;   r[    r  z2TestVectorize.test_signature_excluded.<locals>.foo()->()r   )r  r  r   r   r   r  r  rv  r  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   rz  r3   r:   r  r:   r:   r;   r`    r{  z5TestVectorize.test_signature_otypes.<locals>.<lambda>r  r   r  r  r   )r2   r   r   r4   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 positionalrK   rI   zdoes not have enough dimensions$inconsistent size for core dimensionr   r  )r2   operatorr6   r   r8  r^   r  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   rz  r3   r:   r  r:   r:   r;   r`    r{  r  zwrong number of outputsrK   c                 S   r  r3   r:   r  r:   r:   r;   r`    r  r  rI   )r2   r   r^   r  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   rz  r3   r:   r  r:   r:   r;   r`    r{  z5TestVectorize.test_size_zero_output.<locals>.<lambda>r   rT   r  r  r   c                 S   rz  r3   r:   r  r:   r:   r;   r`    r{  r  r  c                 S   rz  r3   r:   r  r:   r:   r;   r`    r{  r  c                 S   rz  r3   r:   r  r:   r:   r;   r`    r{  r  c                 S   rz  r3   r:   r  r:   r:   r;   r`    r{  c                 S   s   | gS r3   r:   r  r:   r:   r;   r`    s    z()->(n)znew output dimensions)	r4   r2   r=   intr   r^   r  r   rO  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   )rz  r   ro  z(m,m),(m)->(m)r  )r   r   r   )r   r   r   )rz  ro  r   c                 S   s   | | S r3   r:   rj  r:   r:   r;   r`    r  z/TestVectorize.test_subclasses.<locals>.<lambda>)r4   r   r   r   r2   matmulr   r   )ra   r   r  r  matvecrP  multr:   r:   r;   r     s    
"

zTestVectorize.test_subclassesN)&rx   ry   rz   rx  ry  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r:   r:   r:   r;   rn  K  sH    

"	rn  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.Ar`  c                 G   r  r6  r:   ra   r~  r:   r:   r;   bound  r  zTestLeaks.A.boundc                  G   r  r6  r:   )r~  r:   r:   r;   unbound  r  zTestLeaks.A.unboundN)rx   ry   rz   itersr  staticmethodr  r:   r:   r:   r;   A  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   rK   r   rT   )gcrC  r  disablesysgetrefcountr`   r  r4   
frompyfuncr  r5   r   collectenable)	ra   rD  incrr  A_funcrefcountr   rb   r  r:   r:   r;   test_frompyfunc_leaks  s   

zTestLeaks.test_frompyfunc_leaksN)rx   ry   rz   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  rT   rl  r   r4   r5   r   r   ra   r   binsr:   r:   r;   test_forward  s   zTestDigitize.test_forwardc                 C   s6   t ddd}t ddd}tt||t d d S )NrT   r  rZ   rl  r   r   r  r:   r:   r;   test_reverse"  s   zTestDigitize.test_reversec                 C   s:   t d}t| | d}ttt||dk d S )Nr   r   r   r4   r  r0  r  r   r   r   )ra   r   binr:   r:   r;   test_random'  s   zTestDigitize.test_randomc                 C   sF   g d}g d}g d}t t||| g d}t t||d| d S )N)rK   rT   rG   r   ro   r   r   )rK   rT   r   )rK   rI   rK   rS   rI   rS   r   )r   rK   rK   rI   rI   rS   r   T)r   r   )ra   r   r  default_answerright_answerr:   r:   r;   test_right_basic,  s   zTestDigitize.test_right_basicc                 C   s4   t dd}t dd}tt||dt d d S )Nr  rT   rG   Tr   r   r  r:   r:   r;   test_right_open4  s   zTestDigitize.test_right_openc                 C   s8   t ddd}t ddd}tt||dt d d S )NrT   r  rZ   rG   Tr   r   r  r:   r:   r;   test_right_open_reverse9  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)rZ   r   rK   rI   r   F)r   rI   rS   rS   T)r   r   rI   rS   r   )rS   rI   r   r   )rS   rS   rI   r   r   )r   r   rG   rG   )r   r   r   rG   r   )rK   rK   r   rK   )r   r   r   r^   r  r:   r:   r;   test_monotonicC  s   zTestDigitize.test_monotonicc                 C   s:   g d}g d}t tt|| ||}}t tt|| d S )N)rK   rI   y      @      ?r   )r   r8  r   r  r:   r:   r;   test_casting_errorS  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  rT   rK   rS   FT)r4   r   r5   r   r   rV  r   )ra   r  rb   r   r:   r:   r;   test_return_typeZ  s
   zTestDigitize.test_return_typec                 C   s&   d}t t||d |d gd d S Nl          rK   r   r4   r   rY  r:   r:   r;   test_large_integers_increasingc  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  rY  r:   r:   r;   test_large_integers_decreasingh  s   "z+TestDigitize.test_large_integers_decreasingN)rx   ry   rz   r  r  r  r
  r  r  r  r  r  r  r  r  r  xfailr  r:   r:   r:   r;   r    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 )NrK   rI   r   r;  )r   r0   r4   r<  r   r   r   r   r   r:   r:   r;   rx  r  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 )NrK   i     periodrI   r     )r   K         r  )r   r  r  r  r  i     )r   r  r  r  r  r     )r  discont)
r   r0   r   r4   r   r   r   r   modr   )ra   
simple_seqwrap_seq
uneven_seqwrap_uneven
no_discont
sm_discontr:   r:   r;   test_periodx  s   &zTestUnwrap.test_periodN)rx   ry   rz   rx  r(  r:   r:   r:   r;   r  p      r  r   O
AllIntegerFloatM)r   rK   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*  rK   r   r}         @rG   )r4   r   r!   r   r   r   r   r   r   r_   r	   r   ra   r   r-  scalarr   	ref_dtyper:   r:   r;   test_hanning     zTestFilterwindows.test_hanningc                 C   r0  )	Nr  r:   r*  rK   r   r}   g(\@rG   )r4   r   r    r   r   r   r   r   r   r_   r	   r   r2  r:   r:   r;   test_hamming  r6  zTestFilterwindows.test_hammingc                 C   r0  )	Nr  r:   r*  rK   r   r}   g^)@rG   )r4   r   r   r   r   r   r   r   r   r_   r	   r   r2  r:   r:   r;   test_bartlett  r6  zTestFilterwindows.test_bartlettc                 C   r0  )	Nr  r:   r*  rK   r   r}   g=
ףp=@rG   )r4   r   r   r   r   r   r   r   r   r_   r	   r   r2  r:   r:   r;   test_blackman  r6  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*  rK   r}   r   r#  )r4   r   r%   r   r   r   r   r   r   r_   r	   r   r2  r:   r:   r;   test_kaiser  s   
zTestFilterwindows.test_kaiser)
rx   ry   rz   strr  r5  r7  r8  r9  r:  r:   r:   r:   r;   r.    s    r.  c                   @   rE   )	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  rI   )r  rK   rq   )r4   r5   r.   r  r:  r<  r	   )ra   r   rP  r:   r:   r;   rx    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   rK   rS   rI   ro   rX   rZ   r}   )r   r~   )r4   r  	ones_liker   r.   r	   )ra   r   r   r>  wxwywzqqxqyqzrP  r:   r:   r;   	test_ndim  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 )NrT   rI   r  g      *@)r4   r5   r   r   r	   r.   )ra   r   r   r  ymrP  xmr:   r:   r;   r  (  s   
zTestTrapz.test_maskedN)rx   ry   rz   rx  rF  r  r:   r:   r:   r;   r<    s    %r<  c                   @   r   )TestSincc                 C   s6   t tddk ttddd}t|t|d d S )Nr   rK   rZ   r;  rq   )r   r-   r4   r  r
   r   ra   r   r:   r:   r;   rx  ;  s   zTestSinc.test_simplec                 C   sF   ddg}t t|}t t|}t t|}t|| t|| d S )Nr   r
  )r-   r4   r   r  r  r   )ra   r   r   r   r   r:   r:   r;   test_array_likeA  s   
zTestSinc.test_array_likeN)rx   ry   rz   rx  rK  r:   r:   r:   r;   rI  9  r)  rI  c                   @   rh  )
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)	rG   rS   rI   rK   rK   rI   rS   rG   r   )r   rK   rI   rS   rG   )rK   rK   rK   rK   rK   rK   )widgethamr[  r\  r[  rN  )r\  r[  rN  rM  )      @      @r@        ?      $@r   rO  )r@  rP  rO  r   )r4   r   r   r   r1   rY  r:   r:   r;   rx  L  s   "zTestUnique.test_simpleNrx   ry   rz   rx  r:   r:   r:   r;   rL  J  ru  rL  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   rK   rI   )r4   infr0  libasarray_chkfiniter   r^   r   r:   r:   r;   rx  X  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   )r4   rT  rU  r   r   r   rm   r:   r:   r;   test_dtype_order`  s   z TestCheckFinite.test_dtype_orderN)rx   ry   rz   rx  rV  r:   r:   r:   r;   rR  V  r   rR  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@)rX  r   p]4?)rY  rZ  r   )r   rX  rY  ?'L?(8?4V}?)rX  r   rZ  w{,H5?jS,?)rY  rZ  r   )h?5#A?)r[  r^  ra  r   toBC,)r\  r_  rb  rd  r   @02v?)r]  r`  rc  re  rf  r   c                 C   s*   t tg dg dddgddgg d S )Nr   )rK   r   rK   r         )r	   r4   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 r  )
r   r  r	   r  r   r4   r   r  rR  r  )ra   tgt1tgt2r:   r:   r;   rx    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 )NrC  rZ   ddofrS   )r   rF  simplefilterr   DeprecationWarningr   r  filterr	   r  rR  r  ra   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 )NrC  rK   r   )bias)r   rF  rm  r   rn  r   r  rR  ro  r	   r  rp  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               @r4  r   r7  r,  )r4   r   r   r   r   r   r  )ra   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 ru  )r4   r   r   r   ra   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 NTrA  rC  r   rI   )
rF  rG  rm  RuntimeWarningr   r   r4   r   r0  rr   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   rg  )r4   errstater   r
   r   r   r   r  )ra   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   )ra   r  cast_Ar  r:   r:   r;   test_corrcoef_dtype     z TestCorrCoef.test_corrcoef_dtypeN)rx   ry   rz   r4   r   r  rR  r  r  rh  rx  rr  rt  rw  ry  r}  r  r  r  r  halfsingledouble
longdoubler  r:   r:   r:   r;   rW  g  sL    	
	rW  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   rI   rK   r   rg  )r   r   r   )ndmin)rK   rG   rK   r   r   皙?gٿrS   r  )r   r   r   gUUUUUU?gUUUUUU)g&S:?go_?g#~j?gZӼ?gQ|?c                 C   s   t t| j| j d S r3   )r   r   x1r  r   r:   r:   r;   rg     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   rv  r   r7  r,  rS   aweights)r4   r   r   r   r_   )ra   r   r  r:   r:   r;   rw    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 ru  )r4   r   r   r   rx  r:   r:   r;   ry    s   &zTestCov.test_xyc                 C   rz  r{  )
rF  rG  rm  r|  r   r   r4   r   r0  rr   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 )NTrA  rC  rT   rk  )
rF  rG  rm  r|  r   r   r  r4   r   rS  r   r:   r:   r;   test_wrong_ddof  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)rowvar)g+?g4@?g&S?go_?gJ4?)r   r   x3r4   r   ra   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 )NrK   rk  )r   r   r  r4   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
  rI   rS   r  rI   rZ   rS   )r   r   r   frequencies
x2_repeatsr  r  unit_frequenciesr  r   r8  r4   r_   r7  RuntimeErrorr^   )ra   nonintr  r:   r:   r;   test_fweights  s"   
zTestCov.test_fweightsc                 C   s   t t| j| jd| j t t| jd| j dt| j| jd t t| j| jd| j t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   r  rI   rg  rS   )r   r   r  r   r  unit_weightsr  r4   r_   r   r  r^   rJ  r:   r:   r;   test_aweights	  s   

zTestCov.test_aweightsc                 C   s   t t| j| j| jdt| j t t| j| j| jd| j t t| j| j| jd| j	 t t| j| j| j
d| j t t| j| jd| j
 dt| j| j
d t t| j| j| jd| j	 d S )N)r  r  r   r  )r   r   r   r  r  r  r  r  r  r  r   r  r   r:   r:   r;   test_unit_fweights_and_aweights	  s<   z'TestCov.test_unit_fweights_and_aweightsr  c                 C   r  r  )r  r   r   r   )ra   r  cast_x1r  r:   r:   r;   test_cov_dtype%	  r  zTestCov.test_cov_dtypeN)%rx   ry   rz   r4   r   rO  r  r  r   r  r  r  r_   r7  r  r   r  r  r  rg   rw  ry  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r:   r:   r:   r;   r    s0    $
	r  c                   @   rE   )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?ۏ?rm  )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"   r4   r   r   r?   r   )ra   r  r  rR  i0_0r:   r:   r;   rx  .	  s4   

zTest_I0.test_simplec                    sV   t d G  fddd}tt | |sJ t  }t | }t|| d S )NrG   c                       s   e Zd Z jZdd ZdS )z*Test_I0.test_non_array.<locals>.array_likec                 S   rz  r3   r:   )ra   rL  r:   r:   r;   __array_wrap__P	  r  z9Test_I0.test_non_array.<locals>.array_like.__array_wrap__N)rx   ry   rz   __array_interface__r  r:   r_  r:   r;   
array_likeM	  s    r  )r4   r5   rV  r  r"   r   )ra   r  r  r  r:   r_  r;   rh  J	  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 valuesre  )r4   r   r  rS  r8  r"   )ra   rb   r  r:   r:   r;   rw  Z	  s   
"zTest_I0.test_complexN)rx   ry   rz   rx  rh  rw  r:   r:   r:   r;   r  ,	  s    r  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 )
NrK   r   r   rI    oF?rT   )r  vT=?r   r  r  gg?)?YJ?r   r  r  )r   r4   isfiniter%   r	   r   r   r:   r:   r;   rx  b	  s   



zTestKaiser.test_simplec                 C   s   t dd d S )NrS   rG   )r%   r   r:   r:   r;   test_int_betao	  rl  zTestKaiser.test_int_betaN)rx   ry   rz   rx  r  r:   r:   r:   r;   r  `	  rA  r  c                   @   rh  )	TestMsortc                 C   sF   t g dg dg dg}tt|t g dg dg dg d S )N)\?bCQ?הs?)w?kl?*dta?)ӯ?6H?ܘC?)r  r  r  )r  r  r  )r  r  r  )r4   r   r	   r'   )ra   r  r:   r:   r;   rx  u	  s   

zTestMsort.test_simpleNrQ  r:   r:   r:   r;   r  s	  ru  r  c                   @   sd   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	d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   rG   rT   rp   rq   r   )rT   rT   rT   )rp   rp   rp   )rq   rq   rq   r&   r   r4   r   ra   XYr:   r:   r;   rx  	  s   zTestMeshgrid.test_simplec                 C   s&   t g d\}t|tg d d S )Nr~  r  )ra   r  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   r  ijindexingr   )rI   rI   rI   rI   )rS   rS   rS   rS   ro   r  r   r)  rS   rG   )rG   rS   rI   )rS   rG   rI   notvalid)r&   r   r4   r   r   r?   r   r^   )ra   r   r   r  r  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   r  TsparserG   rT   rp   rq   r  r  r:   r:   r;   test_sparse	  s   $zTestMeshgrid.test_sparsec                 C   s   t ttg dg ddd d S )Nr   r  r  )r  )r   r8  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  r`  T)r   r  )r4   r5   r   r   r&   r   r   )ra   r   r   r  r  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)r  r   r   rK   )r4   r   r&   r   )ra   r  r  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;   rE  	  rF  z-TestMeshgrid.test_nd_shape.<locals>.<genexpr>rK   rp   )rI   rK   rS   rG   rT   )r4   r&   r`   r   r?   )ra   rb   r   r   r2  r  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   rK   rI   rR   r   r   rH   r4   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   rK   rI   rR   r  r  r   r   rH   r  r   r:   r:   r;   test_nd_indexing	  s   "zTestMeshgrid.test_nd_indexingN)rx   ry   rz   rx  r  r  r  r  r  r  r  r  r  r  r:   r:   r:   r;   r  	  s    
	r  c                   @   r{   )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   TFrK   c                 S   r  r  r:   r  r:   r:   r;   r`  
  r{  z+TestPiecewise.test_simple.<locals>.<lambda>rZ   z1 or 2 functions are expectedr   )r(   r   r4   r   r   r^   rY  r:   r:   r;   rx  	  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 )NrK   rI   TFrS   rG   r(   r   rY  r:   r:   r;   test_two_conditions
  s    z!TestPiecewise.test_two_conditionsc                 C   s"   t dg dg d}t|d d S )NrS   )TFF)rG   rI   r   rG   )r(   r   rY  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 )NrK   rI   TFr   rS   r  rY  r:   r:   r;   test_default
  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 )
NrS   rG   r   rT   TFrK   r  r   )r4   r   r(   r   r   r   rx  r:   r:   r;   rT  
  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 )
NrS   rG   r   rT   r   rI   z2 or 3 functions are expectedrK   r   )r(   r   r   r   r^   rx  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 )NrS   rK   rI   )r4   r   r(   r   )ra   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   rI   r?  )rg  rg  rg  )r   r   r   )r4   r   r(   r   rx  r:   r:   r;   test_multidimensional_extrafuncB
  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   J
  r   r   r   r   rG   )rg  r   r   )rg  rg  r   r   r   )r4   r   r5   r   r(   r   r   )ra   r   r   rP  r:   r:   r;   r   I
  s
   zTestPiecewise.test_subclassesN)rx   ry   rz   rx  r  r  r  rT  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	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 )NrG   )r4   bincountr5   r   r_   r  r:   r:   r;   rx  T
  s   zTestBincount.test_simplec                 C   s,   t t g d}t|t g d d S )N)rK   rT   rI   rG   rK   )r   rI   rK   r   rK   rK   )r4   r  r   r   r  r:   r:   r;   test_simple2X
  s   zTestBincount.test_simple2c                 C   s2   t d}t g d}t ||}t|| d S )NrG   )皙?333333?r
  r  )r4   r5   r   r  r   ra   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rK   rI   rG   rT   rI   r  r  r
  r  r  )r   r  r
  r   r
  r  r4   r   r  r   r  r:   r:   r;   test_simple_weight2b
  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   rK   r   rK   rK   rS   	minlength)rI   rS   r   r   r  rx  r:   r:   r;   test_with_minlengthh
  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   rK   rK   rI   rI   rS   rS   rI   r  )rK   rI   rI   rI   r   r  rx  r:   r:   r;   )test_with_minlength_smaller_than_maxvaluep
  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  ro   )r   r  r
  r   r
  r  r   r   r  r  r:   r:   r;   test_with_minlength_and_weightsw
     z,TestBincount.test_with_minlength_and_weightsc                 C   s&   t jg td}t |}t|| d S r  )r4   r   r  r  r   rx  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  rT   r  )r4   r   r  r  r   r=   rx  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  r4   r  r:   r  r:   r;   r`  
      z<TestBincount.test_with_incorrect_minlength.<locals>.<lambda>zmust not be negativec                      r  NrZ   r  r  r:   r  r:   r;   r`  
  r  rT   c                      r  r  r  r:   r  r:   r;   r`  
  r  c                      r  r  r  r:   r  r:   r;   r`  
  r  )r4   r   r  r   r8  r^   r5   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  r4   r   intpr  r`   r  r   )ra   intp_refcountdouble_refcountjr:   r:   r;   test_dtype_reference_leaks
  s   z'TestBincount.test_dtype_reference_leaksvalsrI   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 r3   )r4   asarrayr   r^   r  )ra   r  vals_arrr:   r:   r;   test_error_not_1d
  s   


"zTestBincount.test_error_not_1dN)rx   ry   rz   rx  r  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   rK   rI   r  h  )r   r^   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   rK   rT   rh   )r4   r  r	   r$   ra   r   r   x0r:   r:   r;   rg   
  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 )NrK   r   r  rZ   r   r   left)r   rK   rK   rK   rI   right)rK   rK   rK   rI   )r  r  )r   rK   rK   rI   )	r`   r4   r5   r  r_   r   r$   rb  r   )
ra   sizexpypincptsdecptsincresdecresinctgt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   rK   rT   r  )r4   r  r	   r$   r   r   r0  r  r:   r:   r;   test_scalar_interpolation_point
  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rK   rI   r  rS   rG   r~  rK   rI   rG   )r4   rS  r	   r$   r0  )ra   r   r	  fpr:   r:   r;    test_non_finite_behavior_exact_x
  s   "&z+TestInterp.test_non_finite_behavior_exact_xc                 C   r  r3   )r4   float_r  r:   r:   r;   r`  
     
 zTestInterp.<lambda>c                 C   s
   t | dS r6  rD   r  r:   r:   r;   r`  
  r  c                 C   s
   t d| S r6  r  r  r:   r:   r;   r`     r  c                 C   s   t | t| dS )NrQ   )rD   r4   multiplyr  r:   r:   r;   r`    s    )rA   zcomplex-realzcomplex-imagzcomplex-both)paramsidsc                 C   s   |j S )z( scale function used by the below tests )param)ra   requestr:   r:   r;   sc
  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
  rK   r   r   N)r   r4   r$   r0  ra   r  r:   r:   r;   test_non_finite_any_nan  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   rK   Nr   r4   r$   rS  r0  r  r:   r:   r;   test_non_finite_inf  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
  rK   r   r   Nr!  r  r:   r:   r;   test_non_finite_half_inf_xf  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   rK   Nr   r4   r$   rS  r  r:   r:   r;   test_non_finite_half_inf_x'  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   rK   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   rK   rT   r,  r  rZ          @      @r  r   r  r  r~         @      ?rG   y              ?iLiViG   r=  rl  r   im     iBi^  i)      @      ?y      $@       @      @      @y      @      @)y      @      ?r-  y     !@      ?y      @      ?r.  y      
@      
@y      @      @y      @      @r   r  )r4   r  r	   r$   rS  )	ra   r   r   r  y0r  r  r	  r  r:   r:   r;   test_complex_interp7  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   rK   rT   r  r.  )rK   rZ   rK   r1  rG   r  r
  )	r4   r  r   r	   r$   r   r   rV  r   )ra   r   r   r  r	  r  r   r:   r:   r;   )test_zero_dimensional_interpolation_pointS  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   )r4   r5   sinr	   r$   r<  )ra   r	  r  r:   r:   r;   test_if_len_x_is_smalld  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+  )rT   r   rS   rG   )g      @r        !@g      @r   g      
@      @g      @r   r  r   r   rI   rZ   r  )r	   r4   r$   r   rr   )ra   r   r	  r  r   r:   r:   r;   r(  i  s   zTestInterp.test_periodN)rx   ry   rz   r  rg   r  r  r  r  fixturer  r   r"  r#  r%  r&  r0  r1  r3  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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
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"d.d/ Z#d0d1 Z$d2d3 Z%d4d5 Z&d6d7 Z'd8d9 Z(d:d; Z)d<d= Z*d>d? Z+d@dA Z,dBS )C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 )Nro   r
  r   r   r;  r5  rh   r   rK   nearestmethod)r4   r5   r   
percentiler0  rY  r:   r:   r;   rg   v  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 rI   r   r  r:   r:   r;   r    r  z0TestPercentile.test_fraction.<locals>.<listcomp>ro   r   r;  rq   rI   rh   rG   )r`   r4   r;  r   r   r   r   r   )ra   r   r  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 )NrT   Flinearr  )r4   r_   r;  )ra   r2  or:   r:   r;   test_api  s
   

zTestPercentile.test_apic                 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   )rG   rG   rS   rh   r   r}   )r4   r   r   r;  rY  r:   r:   r;   test_2D  s   
zTestPercentile.test_2Dr   AllFloatc                 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 )Nry       A@      D@      I@r  r?  r9  )r4   r  NANr;  testingr   r   )ra   r   rL  r  r:   r:   r;   test_linear_nan_1D  s   z!TestPercentile.test_linear_nan_1Dc                 C   s   g | ]}|t jfqS r:   )r4   r   )r
  int_typer:   r:   r;   r    s    zTestPercentile.<listcomp>r+  r*  input_dtypeexpected_dtyper:  r  )	)inverted_cdfr`  )averaged_inverted_cdf     ;@)closest_observationr`  )interpolated_inverted_cdfr`  )hazenrO  )weibull   )r?  r  )median_unbiasedr  )normal_unbiasedg      ;@c                 C   s   t jg d|d}t j|d|d}t j||d |dv r?|dkr/t jt |jt j d S t jt |jt | d S t jt |jt | d S )N)ry  g      4@rD  rE  rF  r  rE  r9  r  )rM  rP  r*  )r4   r  r;  rH  r	   r   r   r   )ra   r:  r  rK  rL  rL  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  rh   lowerr9  rG   higherrT   r   r4   r;  r5   ra   r   r:   r:   r;   test_lower_higher     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   midpointr9  r1  r  rK   rh   rT   r         @rZ  r[  r:   r:   r;   test_midpoint  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^  r8  r9  rT   1   rG   rZ  r[  r:   r:   r;   test_nearest  r]  zTestPercentile.test_nearestc                 C   sL   t jd}t |d}t j||  t |d}t j||  d S )NrT   r;  r   )r4   r  r   r;  rH  r   r  r0  )ra   rL  r   r:   r:   r;   'test_linear_interpolation_extrapolation  s
   z6TestPercentile.test_linear_interpolation_extrapolationc                 C   s,   t dd }tt |g dg d d S )Nro   r
  )r   r;  rh   )r   r5  r   )r4   r5   r   r;  rY  r:   r:   r;   test_sequence  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(  rS   rG   )r  rh   r;  )g      @r`  r  )rI   rS   rG   rT   r  )ro   r  r   r   r   r}   )      ?r  rS   )      @r`  rq   )r4  r   r   rK   r   rT   rp   r  rh   r=  )r  rh   r  rS   )rI   rG   rT   rp   )rI   rS   rT   rp   rI   )rI   rS   rG   rp   )rS   rS   rT   rp   rY  r9  r~   r:  )r4   r5   rr   r   r;  r   rO  r?   )ra   r   r0r  r:   r:   r;   r    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(  rS   rG   rh   r`  r   r   r   rz  r   r}   r  r`  r   rK   r  r~   r  rX  r9  r   )r:  r~   )r   r   ro  r:   r  r:  r  rT   r:  r~   r  )r4   r5   rr   r   r;  r   isscalarr   r?   r	   emptyr   )ra   r   rk  r  r  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 )
NrK   rI   8   r  r9  e   rZ   rh   r  )r   r^   r4   r;  r  r`   r   r:   r:   r;   test_exceptionS  s    $zTestPercentile.test_exceptionc                 C   s   t tg ddd d S )Nr   r   rK   )r   r4   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   ri  rn  r   r  r   ro  r}   rS   rI   rK   r(  rS   rG   )r   r   r   r   rl  )rI   rG   rh  )rf  rg  r4  rm  r  r   rK   rI   rS   r  r  rX  rq  )r   rG   ro   )rK   rT   r  )	r4   r   r=   r;  r   r5   rr   rs  r   )ra   r   r   r  rk  r  r  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 )Nr  r   rK   rI   rh   r   r}   )rK   rI   rK   )r   rI   rK   )r   rK   rK   rS   )r   rK   rI   rZ   rQ   rW   rL  r_  rj  r   )rI   rK   rI   rK   )rI   r   rI   rK   )rI   r   rK   rK   )rI   r   rK   rI   )r4   r5   rr   r   r;  r?   r   ra   r2  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rI   rS   rG   rK   rh   Foverwrite_inputr4   r   r;  r   rm   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@rT   )numr_  r9  )r4   r  r;  r5   r   rZ  )ra   r  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  rh   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   r  r[   r}   rZ   r   rl   rK   rj   r  r  rJ   r=    rS   rT   rq   r   Z   r   rK   rS   rS   rK   rL  rI   rS   rK   rI   r{  rI   rK   rK   rQ   rK   rS   rN   )r4   r  normaldstackr   r;  moveaxisr   r   r5   rr   shuffleravelflattenra   r@  r   r2  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  rl  r  )r~   rB  r   rl  rG   r   rG   rP   )rZ   rZ   )rS   rZ   )r4   r_   r   r   r;  r^   r~  r:   r:   r;   test_extended_axis_invalid  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  rq   Tr   r   r[   rK   rK   rq   r   r   rK   rT   rq   rK   r  rS   rK   rq   r   r|  )r   r  rK   rK   rq   rK   rK   )rI   rK   rK   rq   rK   )rI   rK   rT   rq   rK   )r4   r_   r   r;  r?   r~  r:   r:   r;   test_keepdims  s:   
zTestPercentile.test_keepdimsc                 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rG   r  r   rn  r8  rp  ri  rK   r:   rI   )r4   r=   r_   r   r;  ra   r@  r2  r:   r:   r;   test_out  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 )NTrA  rC  rD  r  r  r  r   rn  r8  rp  ri  rK   r:   )
rF  rG  rH  r|  r4   r=   r_   r0  r   r;  r  r:   r:   r;   test_out_nan  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 )NrK  r  rI   r  r   r}   g333333?rS   rG   r   rK   rK   rI   r  rk   rK   r  rO   r8  r9  )	r4   r5   rb  r0  r   r;  r   rr   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 inre  )rK   rI   rS   r   r   g     X@r  r   )r  rS  r^   r4   r;  r0  r  )ra   rB  r:   r:   r;   
test_nan_qW  s   
"zTestPercentile.test_nan_qN)-rx   ry   rz   rg   r>  rA  rB  r  r  r  r4   	typecodesrI  r!  r   r   r  r  r  clongdoubler   H_F_TYPE_CODESrW  
TYPE_CODESr\  ra  rc  rd  re  r  rv  ry  rz  r}  r  r  r  r  r  r  r  r  r  r  r  r:   r:   r:   r;   r7  t  sd    	












	$0)	 =r7  c                
   @   s   e Zd Zdd Zdd Zejjdddd Zd	d
 Z	dd Z
ejdejd dd Zejdg d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d"S )#TestQuantilec                 C   s*   g d}t |d}t jj|ddd d S )N)r   r  r  g?g
ףp=
?rK   )maxulp)r4   quantilerH  assert_array_max_ulp)ra   r   rb   r:   r:   r;   test_max_ulpf  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 )Nro   r
  r   r   rK   r5  r   )r4   r5   r   r  rY  r:   r:   r;   rg   n  s   zTestQuantile.test_basiczSee gh-19154r  c                 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)r4   r   r  r   r   r   r   )ra   rb   tf_quant	quant_resr:   r:   r;   test_correct_quantile_valuet  s   
z(TestQuantile.test_correct_quantile_valuec                 C   s8  dd t dD }t|d}t|d tt|t t|d}t|tdd tt|t 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   r  r:   r:   r;   r    r  z.TestQuantile.test_fraction.<locals>.<listcomp>ro   r   rK   rq   rI   rG   )	r`   r4   r  r   r   r   r   r   r5   )ra   r   rB  r:   r:   r;   r>    s$   

"zTestQuantile.test_fractionc                 C   sj   t g d}| }t jt d|dd t|| | }| }t jt d|dd t|| d S )N)r   rf  r  r
  r   r  r_  r9  )r4   r   r   r  r5   r   rZ  )ra   p0r  r:   r:   r;   r    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 )NrK   rI   r  r
  r8  r9  )r4   r  r   r   )ra   r   r  r:   r:   r;   test_quantile_preserve_int_type  s   z,TestQuantile.test_quantile_preserve_int_typer:  )rM  rN  rP  rQ  rR  rS  r?  rU  rV  r8  rX  rY  r_  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   rK   rx  )r   rK   rK   rI   rI   rS   rS   rG   rT   rT   rK   rK   r  r  r  ro   ro   rq   r  r9  )r   r   r   r   )r4   r  r  r   r   r  )ra   r:  r  r  r:   r:   r;   test_quantile_monotonic  s   	z$TestQuantile.test_quantile_monotonicrS   r  )	min_value	max_valueFu <7u <7~)allow_infinity	allow_nanr  r  )r   r?   elements)rL  c                 C   s.   t ddd}t ||}tt || d S )Nr   rK   g{Gz?)r4   r5   r  r   r  )ra   rL  r  r  r:   r:   r;   test_quantile_monotonic_hypo  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)rm  rz  r   )r   r   r   r   rK   r
  )r4   r   r0  r  rr  r   )ra   rb   r   r:   r:   r;   test_quantile_scalar_nan  s
   z%TestQuantile.test_quantile_scalar_nanN)rx   ry   rz   r  rg   r  r  r  r  r>  r  r  r4   r  r  r  
hypothesisgivenr   r   stintegersfloatsr  r  r:   r:   r:   r;   r  c  s.    




r  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   rK   )r  r  r  r  r  r  )t0t1rb   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 r3   r  _lerp)ra   r  r  rb   r   l0l1r:   r:   r;   +test_linear_interpolation_formula_monotonic  s   	z4TestLerp.test_linear_interpolation_formula_monotonic)trb   r   c                 C   s\   ||kr|t |||  kr|ksJ  J d S |t |||  kr)|ks,J  J d S r3   r  )ra   r  rb   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 r  )r  r  r   )ra   r  rb   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 )NrI   rT   r  g@)r4   r   r  r  )ra   rb   r   r  r:   r:   r;   +test_linear_interpolation_formula_0d_inputs  s   


z4TestLerp.test_linear_interpolation_formula_0d_inputsN)rx   ry   rz   r  r  r  r  r  r  r  r  r:   r:   r:   r;   r    sL    



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g ddejdgejdfdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"S )#
TestMedianc                 C   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 )NrK   rI   rp   rS   r
  r  r   r}   r  r  r5  rG   )6-¦?0?}r?g4?r   )r  r  r  )r  r  r  rZ   )
r4   r   r5   rr   r   medianr   r	   r   r0  )ra   a0r]  r  rb   r:   r:   r;   rg     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 )NrI   rS   r   rK   rp   rq   rG   rT   r;  r   r  r}   r5  )r4   r   r  randintr   r  r`   r   r   r   rO  )ra   a3rb   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 )NrI   rS   r   rK   rp   rq   rG   rT   Tr  r
  r  )r  r~   r  r  r  rR   r}   )r~   r  )r4   r   r5   rr   r   r  r   rO  r   r  r  r  )ra   r  r  r]  r  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   rI   r   r}   )r	   r4   r  r   )ra   r   r   r:   r:   r;   rK  M  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 r3   )r4   r  r   info)clsinput_arrayr  objr:   r:   r;   __new__X  s   z4TestMedian.test_subclass.<locals>.MySubClass.__new__c                 S   r  )Nr:   )ra   r~   r   r  r:   r:   r;   r   ]  r  z1TestMedian.test_subclass.<locals>.MySubClass.meanr3   )NNN)rx   ry   rz   r  r   r:   r:   r:   r;   
MySubClassV  s    
r  r   r  )r4   r   r   r  )ra   r  rb   r:   r:   r;   rX  T  s   
zTestMedian.test_subclassrL  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;   
MySubclassg  r   r  N)r4   r   r  r   r   rV  )ra   rL  r  r  r:   r:   r;   test_subclass2c  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 )Nr  r  r   rn  ri  rK   r:   )r4   r=   r_   r   r  r  r:   r:   r;   r  m  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 )NTrA  rC  rD  r  r  r  r   rn  ri  rK   r:   )
rF  rG  rH  r|  r4   r=   r_   r0  r   r  r  r:   r:   r;   r  v  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 )NrK  r  rI   r   r}   rS   rG   r   r  r  rk   rK   r  rO   )r4   r5   rb  r0  r   r  rr   r   r   r:   r:   r;   r    s*   


 

 

 

zTestMedian.test_nan_behaviorc                 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  TrA  rC  rD  r   rI   rS   )r   r  r}   rK   )r4   r   rb  rF  rG  rH  r|  r   r  r0  r   rJ  r  )ra   rb   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 )Nrz  rI   )	r4   r5   r   r   r  r   r  rb  r0  )ra   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[   r}   rZ   r   rl   rK   rj   rJ   r=  )rZ   r  r  r  r  rI   r  r{  r  r  r  rN   )r4   r  r  r  r   r  r  r   r   r5   rr   r  r  r  r  r:   r:   r;   r    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  rl  r}   r  rG   r  rP   )r4   r_   r   r   r  r^   r~  r:   r:   r;   r    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[   r  r   r  r  r  r|  r  r  )r4   r_   r   r  r?   r~  r:   r:   r;   r    s&   
zTestMedian.test_keepdimsN)rx   ry   rz   rg   r  r  rK  rX  r  r  r  r4   r0  r  r  r  r  r}  r  r  r  r  r:   r:   r:   r;   r    s$    !
	 r  c                   @   r   )TestAdd_newdoc_ufuncc                 C   s"   t ttdd t tttjd d S )NrI   blah)r   r8  r   r^   r4   r6   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 )NrS   )r   r8  r   r4   r6   r   r:   r:   r;   test_string_arg  s   z$TestAdd_newdoc_ufunc.test_string_argN)rx   ry   rz   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_newdocrI   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   r4   coreflatiterindexr  r  r   ufuncidentityrT  index_tricksmgrid)ra   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)r4   r  r  r  r  
add_newdoc)ra   prev_docr:   r:   r;   test_errors_are_ignored  s   z&TestAdd_newdoc.test_errors_are_ignoredN)rx   ry   rz   r  r  r  r  r   optimizer  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 )
TestAddDocstringrI   r  r  r  c                 C   s0   t t jjt jjj dd }t ||j d S )Nc                   S   r  	docstringNr:   r:   r:   r:   r;   func"  r  z6TestAddDocstring.test_add_same_docstring.<locals>.func)r4   add_docstringr   flatr  ra   r  r:   r:   r;   test_add_same_docstring  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   r  r  r:   r:   r:   r:   r;   r  .  r  z=TestAddDocstring.test_different_docstring_fails.<locals>.func)r   r  r4   r  r   r  r  r:   r:   r;   test_different_docstring_fails(  s   

"z/TestAddDocstring.test_different_docstring_failsN)rx   ry   rz   r  r  r  r  r   r   r   r  r	  r:   r:   r:   r;   r    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))lD)hr   )Hr   )r   r   )rR  r   )r'  Gc                 C   sH   t jg d|d}t |}t ||}t|| t|j|j d S )N)rT   rS   rp   rI   rK   r  )r4   r   sort_complexr  r   r   r   )ra   type_intype_outrb   r   r  r:   r:   r;   test_sort_real8  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'        ?       r8  r(  r  r  )r8  r  r(  r'  )r4   r   r  r   r   )ra   rb   r  r   r:   r:   r;   test_sort_complexH  s
   

z!TestSortComplex.test_sort_complexN)rx   ry   rz   r  r  r  r  r  r:   r:   r:   r;   r
  6  s    
r
  )r   )r   r   )zr  rF  r  r  	fractionsr   rh  r  r  hypothesis.extra.numpyr   hypothesis.strategies
strategiesr  numpyr4   r   numpy.testingr   r   r   r	   r
   r   r   r   r   r   r   r   numpy.lib.function_baserT  function_baser  numpy.randomr   	numpy.libr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r<   rD   rF   r|   r   r   r   r   r  r>  ri  rv  rx  r|  r  r  r  r  r  r5  rB  r]  rk  rm  rn  r  r  r  r  r  r  r.  r<  rI  rL  rR  rW  r  r  r  r  r  r  r  r  r7  r  r  r  r  r  r  r
  r:   r:   r:   r;   <module>   s    8Dg# 	>o u }A
)
   *)Ul>[j4nd` C   rm2 z
