%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python3.9/site-packages/numpy/lib/tests/__pycache__/
Upload File :
Create Path :
Current File : //lib64/python3.9/site-packages/numpy/lib/tests/__pycache__/test_function_base.cpython-39.pyc

a

z[ycG?�@s.ddlZddlZddlZddlZddlmZddlZddlZddlZddl	m
Z
ddlmZ
ddlZddlmZddlmZmZmZmZmZmZmZmZmZmZmZmZddlmm Z!ddl"m#Z#ddl$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@mAZAmBZBmCZCmDZDdd	�ZEd
d�ZFGdd
�d
�ZGGdd�d�ZHGdd�d�ZIGdd�d�ZJGdd�d�ZKGdd�d�ZLGdd�d�ZMGdd�d�ZNGdd�d�ZOGdd�d�ZPGd d!�d!�ZQGd"d#�d#�ZRGd$d%�d%�ZSGd&d'�d'�ZTGd(d)�d)�ZUGd*d+�d+�ZVGd,d-�d-�ZWGd.d/�d/�ZXGd0d1�d1�ZYGd2d3�d3�ZZdtd5d6�Z[dud8d9�Z\Gd:d;�d;�Z]Gd<d=�d=�Z^Gd>d?�d?�Z_Gd@dA�dA�Z`eja�bdBdCejcdDejcdE�eja�bdFgdG��GdHdI�dI���ZdGdJdK�dK�ZeGdLdM�dM�ZfGdNdO�dO�ZgGdPdQ�dQ�ZhGdRdS�dS�ZiGdTdU�dU�ZjGdVdW�dW�ZkGdXdY�dY�ZlGdZd[�d[�ZmGd\d]�d]�ZnGd^d_�d_�ZoGd`da�da�ZpGdbdc�dc�ZqGddde�de�ZrGdfdg�dg�ZsGdhdi�di�ZtGdjdk�dk�ZuGdldm�dm�ZvGdndo�do�ZwGdpdq�dq�ZxGdrds�ds�ZydS)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�	vectorizecCst�|�}tj�||�}|S�N)�np�arange�add�outer)�n�data�r:�H/usr/lib64/python3.9/site-packages/numpy/lib/tests/test_function_base.py�get_mats
r<cCs(t�t�||�jtj�}||_||_|S)za
    Like real + 1j * imag, but behaves as expected when imag contains non-finite
    values
    )r4�zeros�	broadcast�shape�complex_�real�imag)rArB�retr:r:r;�
_make_complex$srDc@s$eZdZdd�Zdd�Zdd�ZdS)�	TestRot90cCs�tttt�d��tttt�d�dd�tttt�d�dd�tttt�d�dd�tttt�d�dd�gd�gd	�g}d
dgddgd
dgg}gd�gd�g}dd
gddgdd
gg}gd�gd	�g}tddd�D]}tt||d�|�q�tddd�D]}tt||d�|�q�tddd�D]}tt||d�|��qtd
dd�D]}tt||d�|��q@ttt|dd�dd�|�tt|ddd�t|ddd��dS)N���rHrH�r�rH��axes�rHrH�rrH�rJrJ)���rJ��rF�rHrSrJrrR�rSrFrR�rHrJr����
)�krP����rrJ�rJr�rXrL)r�
ValueErrorr*r4�ones�ranger)�self�a�b1�b2Zb3Zb4rXr:r:r;�
test_basic0s@�����zTestRot90.test_basiccCsRt�d�}tt|�jd�tt|dd�t|dd��tt|dd�t|dd��dS)N)�2�(rR)rfrerRrNrK�rrY�rJrH�rPrY)r4r^rr*r?�r`rar:r:r;�	test_axesPs
zTestRot90.test_axescCs�t�d��d�}ddgddggddgd	d
ggg}ddgddggd
dgd	dggg}d	dgddggd
dgddggg}d	d
gddggddgddggg}tt|dd�|�tt|d
d�|�tt|dd�|�tdd
�D]&}tt||dd�t||ddd��q�dS)N�rGrHrR��rrJrFrSrZrKr[rh)rHrr\)r4r5�reshaperr*r_)r`raZ
a_rot90_01Z
a_rot90_12Z
a_rot90_20Z
a_rot90_10rXr:r:r;�test_rotation_axesVsH�������������zTestRot90.test_rotation_axesN)�__name__�
__module__�__qualname__rdrkrpr:r:r:r;rE/s rEc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestFlipcCslttjtjt�d�dd�ttjtjt�d�dd�ttjtjt�d�dd�ttjtjt�d�dd�dS)NrFrJ��axis�rFrFrHrV�rrR)rr4�	AxisError�flipr^�r`r:r:r;rkuszTestFlip.test_axescCsftd�}|dd�ddd�f}tt�|d�|�gd�gd�g}gd�gd�g}tt�|d�|�dS)NrFrYrJrIrQrUrT�r<rr4rz�r`ra�br:r:r;�
test_basic_lr{s��zTestFlip.test_basic_lrcCsftd�}|ddd�dd�f}tt�|d�|�gd�gd�g}gd�gd�g}tt�|d�|�dS)NrFrYrrIrQr|r}r:r:r;�
test_basic_ud�s��zTestFlip.test_basic_udcCsbt�ddgddggddgddggg�}t�ddgddggddgddggg�}tt�|d�|�dS�	NrrJrHrRrFrSrmrn�r4�arrayrrzr}r:r:r;�test_3d_swap_axis0�s
���
���zTestFlip.test_3d_swap_axis0cCsbt�ddgddggddgddggg�}t�ddgddggddgddggg�}tt�|d�|�dSr�r�r}r:r:r;�test_3d_swap_axis1�s
���
���zTestFlip.test_3d_swap_axis1cCsbt�ddgddggddgddggg�}t�ddgddggddgddggg�}tt�|d�|�dSr�r�r}r:r:r;�test_3d_swap_axis2�s
���
���zTestFlip.test_3d_swap_axis2c	CsRt�d��dddd�}t|j�D],}tt�||�t�|�d|���|d��q dS)N�xrHrRrFrSr)	r4r5ror_�ndimrrzr�swapaxes)r`ra�ir:r:r;�test_4d�s
�zTestFlip.test_4dcCs@t�gd�gd�g�}t�gd�gd�g�}tt�|�|�dS)N�rJrHrR�rFrSrm)rmrSrF�rRrHrJr�r}r:r:r;�test_default_axis�s
�
�zTestFlip.test_default_axiscCs�t�ddgddggddgddggg�}ttj|d	d
�|�t�ddgddggddgddggg�}ttj|dd
�|�t�ddgddggddgddggg�}ttj|dd
�|�dS)
NrrJrHrRrFrSrmrnr:rurNrhr��r`rar~�cr:r:r;�test_multiple_axes�s0
���
���
���zTestFlip.test_multiple_axesN)rqrrrsrkrr�r�r�r�r�r�r�r:r:r:r;rtss




rtc@seZdZdd�Zdd�ZdS)�TestAnycCsHgd�}gd�}gd�}tt�|��tt�|��tt�|��dS)N�rrrJr�rrrr)rJrrJr)rr4�any�r`�y1�y2�y3r:r:r;rd�szTestAny.test_basiccCsXgd�gd�gd�g}tt�|��ttj|dd�gd��ttj|dd�gd��dS)N�rrr�rrJr�rJrJrrrurJ�rrJrJ)rr4r�rZsometrue�r`r�r:r:r;�test_nd�szTestAny.test_ndN�rqrrrsrdr�r:r:r:r;r��sr�c@seZdZdd�Zdd�ZdS)�TestAllcCs`gd�}gd�}gd�}tt�|��tt�|��tt�|��tt�t�|���dS)N)rrJrJrr��rJrJrJrJ)rr4�allr�r�r:r:r;rd�szTestAll.test_basiccCsZgd�gd�gd�g}tt�|��ttj|dd�gd��ttj|dd�gd��dS)N�rrrJr��rJrJrJrrurJ)rr4r�rZalltruer�r:r:r;r��szTestAll.test_ndNr�r:r:r:r;r��s	r�c@s$eZdZdd�Zdd�Zdd�ZdS)�TestCopycCsRt�ddgddgg�}t�|�}t||�d|d<t|dd�t|dd�dS)NrJrHrRrF�
)rr)r4r��copyrr)r`ra�a_copyr:r:r;rd�s

zTestCopy.test_basiccCs�t�ddgddgg�}t|jj�t|jj�tjddgddggdd�}t|jj�t|jj�t�|�}t|jj�t|jj�t�|�}t|jj�t|jj�dS)NrJrHrRrF�F��order)r4r�r�flags�c_contiguous�f_contiguousr�)r`raZa_fortr�Za_fort_copyr:r:r;�
test_orders

zTestCopy.test_ordercCsVt�d�}tt�tj|dd���tt�tj|dd���tt�t�|���dS)NrSF)ZsubokT)rr^rZ
isMaskedArrayr4r�)r`Zmxr:r:r;�
test_suboks
zTestCopy.test_subokN)rqrrrsrdr�r�r:r:r:r;r��sr�c@s�eZdZdd�Zej�dgd�ddggd�dgd	gfgd
�gd�gdgd
�gddggd�ggd�gfg�dd��Zdd�Zdd�Z	dd�Z
dd�Zdd�ZdS)�TestAveragecCs�t�gd��}tt|dd�dk�t�gd��}tt|dd�dk�gd�}tt|dd�dk�t�d�}d|d	<d
|d<t|�d�t|d��t|�d�t|d��td
d
�}t|�d�t|d��t|�d�t|d��dS)Nr�rru�@���?r��@)�r�r�r�rwrZrHr[rJrS)r4r�rrr^r	�meanr)r`r�r�r�Zy4Zy5r:r:r;rd"s

zTestAverage.test_basicz<x, axis, expected_avg, weights, expected_wavg, expected_wsumr�Nr�)rRrFrJ��?� @)rJrHrS)rJrm�r)r��@r�rJrR)r��@�#@�rFrFrFc
Cs�tj||dd�}|jt�|�ks$J�t||�tj|||dd�}|jt�|�ksTJ�t||�tj|||ddd�\}}	|jt�|�ks�J�t||�|	jt�|�ks�J�t|	|�dS)NT�rv�keepdims)rv�weightsr�)rvr��returnedr�)r4rr?r)
r`�xrvZexpected_avgr�Z
expected_wavgZ
expected_wsum�avgZwavgZwsumr:r:r;�test_basic_keepdims4s

�

zTestAverage.test_basic_keepdimscCs�t�d�}t�d�}t||d�}t�d�d��dt�d���}t||�t�gd�gd�g�}ddg}t||dd	�}t�gd
��}t||�gd�}t||dd	�}t�dd
g�}t||�gd�gd�g}t�dd
g�}tt||dd	�|�tt||d�d�td��	tj
�}	td��	tj�}
ttj|	|
d�j
t�|	|
�k�t�gd���dd�}t�gd���dd�}tj||ddd�}t�gd��}t||�tj||ddd�}t�dgdgdgg�}t||�dS)Nr��r�rHr�r�r�rJr)r�rv)r�r�r�r�r��@)rrrHr�rS�rHrRrFrRF)r�rvr�)r�r�r�Tr�r�)r4r5r�sumr	r�rrr�astype�float32�float64r�dtype�result_typero)r`�y�w�actualZdesiredr��w0�w1�w2r�Zw3r�r:r:r;�test_weightsKs:

$


 
zTestAverage.test_weightscCst�gd�gd�g�}t|dd�\}}t|d�t|ddd�\}}t|t�gd���t|ddd�\}}t|t�d	d	g��dd
g}t||ddd�\}}t|t�gd���gd�}t||ddd�\}}t|t�ddg��gd
�gd�g}t||ddd�\}}t|t�ddg��dS)Nr�r�T)r�r�r)r�r�r�rJr�rH)r�rvr�)r�r�r�r�r�)r4r�rrr)r`r�r�Zsclr�r�r�r:r:r;�
test_returnedws 
zTestAverage.test_returnedcCszGdd�dtj�}t�ddgddgg��|�}t�ddgddgg��|�}ttt�|��|�tttj||d��|�dS)Nc@seZdZdS)z-TestAverage.test_subclasses.<locals>.subclassN�rqrrrsr:r:r:r;�subclass�sr�rJrHrRrFr�)r4�ndarrayr��viewr�typer)r`r�rar�r:r:r;�test_subclasses�s
zTestAverage.test_subclassescCslgd�}|D]Z\}}}tjddgddgg|d�}tjddgddgg|d�}ttj||d�jt�|��qdS)N))�i4r��f8)r��f4r�)r�r�r�)r�r�r�)r�r�r�rJrHrRrF�r�r�)r4r�rrr�)r`ZtypsZatZwtZrtrar�r:r:r;�test_upcasting�s
zTestAverage.test_upcastingcCsXt�dd�td�D��}t�dd�td�D��}||��}t|�d�t||d��dS)NcSsg|]}t�|��qSr:��decimalZDecimal)�.0r�r:r:r;�
<listcomp>��z1TestAverage.test_object_dtype.<locals>.<listcomp>r�cSsg|]}t�d��qS�rJr�)r��_r:r:r;r��r�rr�)r4r�r_r�r	r�r)r`rar�r:r:r;�test_object_dtype�szTestAverage.test_object_dtype)
rqrrrsrd�pytest�mark�parametrizer�r�r�r�r�r�r:r:r:r;r� s���
,	r�c@s�eZdZe�gd��e�gd��e�gd��gZe�gd��e�gd��e�gd��gZddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�
TestSelectr�r��rnrl�	)FFF�FTF�FFTrcs<g}tt|��D]&�|�fdd�t||�D�p2|g7}q|S)Ncs g|]\}}|�r|��qSr:r:)r��V�C��mr:r;r��r�z&TestSelect._select.<locals>.<listcomp>)r_�len�zip)r`Zcond�values�default�outputr:r�r;�_select�s$zTestSelect._selectcCsL|j}|j}tt||dd�|j||dd��tt|�d�tt|�d�dS)N��r�rR)�choices�
conditionsrr+r�rr��r`rrr:r:r;rd�s�zTestSelect.test_basiccCsdt�d�t�gd��g}dt�d��dd�g}tt||�t�d��ttdgdgdgd	�jd
�dS)NTr�rJ�rFrR�rFrRrr�r�)	r4r�r5rorr+r^rr?�r`rrr:r:r;�test_broadcasting�szTestSelect.test_broadcastingcCs�tt|j|jd�jtj�dd�|jD�}tt|j|�jtj�t�dddtj	ddg�}t�
|�}tt|g|g�d	d	d	tj	d	d	g�dS)
N��?cSsg|]}|�tj��qSr:)r�r4�int8)r��choicer:r:r;r��r�z0TestSelect.test_return_dtype.<locals>.<listcomp>rJrHrRrSrnr)rr+rrr�r4r@rr��nanZisnan)r`r�dr�r:r:r;�test_return_dtype�s�
zTestSelect.test_return_dtypecCs"tttggd�tttgg�dS)N�@)rr]r+r{r:r:r;�test_deprecated_empty�sz TestSelect.test_deprecated_emptycCsj|j}|jdd�}|d�tj�|d<ttt||�|d�tj�|d<ttt||�ttt||�dS�Nr)	rrr�r4�int_r�	TypeErrorr+�uint8rr:r:r;�test_non_bool_deprecation�sz$TestSelect.test_non_bool_deprecationcCs2t�dg�gd}t�dg�gd}t||�dS)NF�drJ)r4r�r+rr:r:r;�test_many_arguments�szTestSelect.test_many_argumentsN)r)rqrrrsr4r�rrr�rdrrrrrr:r:r:r;r��s��
		r�c@s^eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
j�dddg�dd��Z
dS)�
TestInsertcCsvgd�}tt|dd�gd��tt|dd�gd��tt|gd�gd��gd��tt|dgd��gd��tt|gd	�d
�gd��tt|tddd�d
�gd
��tt|gd�gd��gd��tjddgtjd�}tt|d|d�gd��tt|gg�|�tjdd��R}t�ddt	�tt|t�dgd�d
�gd��t
|djt	u�Wd�n1�sh0YdS)Nr�rrJ)rJrJrHrRrR)rJrHrRrJr�)rJrJrHrRrHrR)rJrYrRr�)rJr�rHr�rRr�rY)r�rJr�rHr�rR�rYrJrRr�)rJrlrHrnrRr�r��r�r�r�T��record�always�rF)rJr�r�r�r�rHrR)rr#�slicer4r�r��warnings�catch_warnings�filterwarnings�
FutureWarningr�category)r`rar~r�r:r:r;rd�s"�zTestInsert.test_basicc
Cs~gd�g}gd�gd�g}tt|ddg�gd��tt|dgd�dd�|�tt|dddd�|�tt|dddd�gd�g�t�ddgddgd	d	gg�}t�dd
��d	��d	d	�}tj|dd�dd�ft�dd
��d	��d	d	�j|dd�dd�ffdd�}tt|dgdgdgd	ggdd�|�tt|dggd�dd�|�tt|dgd�dd�|�tt|ddgdgd	ggdd�|�t�d
��dd�}tt|dd�dd�fd|dd�dfdd�|�tt|dd�dd�fd|ddd�fdd�|�t�d��d
�}tt|d|dd�dd�d	fdd�t|d|dd�dd�d	fdd��tt|d|dd�ddd�fdd�t|d|dd�ddd�fdd��t	tj
t|d|dd�ddd�fd	d�t	tj
t|d|dd�ddd�fdd�t�d��d
�}tt|d|dd�dd�d	fdd�t|d|dd�dd�d	fdd��tt|d|dd�ddd�fdd�t|d|dd�ddd�fdd��dS)Nr�rGrrJr�rurH)rJrJrHrJrRrFr��r�rYrP���)rr#r4r�r5�repeatroZconcatenate�Trry)r`ra�rr~r�r:r:r;�
test_multidim�sN
�,��$"22" �" �((" �" �zTestInsert.test_multidimcCs�t�d�}t�tj�� t|gddd�Wd�n1s<0Yt�t�� t|gddd�Wd�n1sv0YdS)NrJrHrru�nonsense)r4r�r��raisesryr#rrjr:r:r;�test_0d&s

.zTestInsert.test_0dc	Cs�Gdd�dtj�}t�d��|�}ttt�|ddg�|��ttt�|gg�|��ttt�|ddgddg�|��ttt�|tdd�ddg�|��ttt�|tddd�g�|��t�d��|�}ttt�|ddg�|��dS)	Nc@seZdZdS)z*TestInsert.test_subclass.<locals>.SubClassNr�r:r:r:r;�SubClass.sr,r�rrJrHrPrY)	r4r�r5r�r�
isinstancer#rr��r`r,rar:r:r;�
test_subclass-s " zTestInsert.test_subclasscCs<t�gd��}t�gd�|gd��t|t�gd���dS)Nr�rIrQ)r4r�r#r�r`r�r:r:r;�test_index_array_copied:sz"TestInsert.test_index_array_copiedcCs�tjgd�ddgd�}d}t�|d|�}t|dtj||jd��dgd}t�|ddg|�}t|ddgtj||jd��dS)	N))rJra)rHr~)rRr�)�foor�)�bar�a1r�)rFrrrHrR)r4r�r#rr�)r`ra�valr~r:r:r;�test_structured_array?s
�
z TestInsert.test_structured_arraycCs�t�t��0t�gd�t�ddg�ddg�Wd�n1s@0Yt�t��,t�gd�tjgtd�g�Wd�n1s�0YdS)NrIr�r�r��r�)r�r*�
IndexErrorr4r#r��floatr{r:r:r;�test_index_floatsIs>zTestInsert.test_index_floats�idxrFr$cCsJtjtdd��(t�gd�|gddg�Wd�n1s<0YdS)Nz
out of bounds��matchrIrRrF)r�r*r8r4r#)r`r;r:r:r;�test_index_out_of_boundsOsz#TestInsert.test_index_out_of_boundsN)rqrrrsrdr(r+r/r1r6r:r�r�r�r>r:r:r:r;r�s*

rc@seZdZdd�ZdS)�TestAmaxcCsbgd�}tt�|�d�gd�gd�gd�g}ttj|dd�gd��ttj|d	d�gd
��dS)N�rRrFrSr�rV���r��$@�rRr��"@�rFrBr��rlr�r�rru)r�rBrDrJ)rDrBr�)rr4Zamaxr}r:r:r;rdWs�zTestAmax.test_basicN�rqrrrsrdr:r:r:r;r?Usr?c@seZdZdd�ZdS)�TestAmincCsbgd�}tt�|�d�gd�gd�gd�g}ttj|dd�gd��ttj|d	d�gd
��dS)Nr@g�rCrErFrru)r�r�r�rJ)r�r�r�)rr4Zaminr}r:r:r;rdcs�zTestAmin.test_basicNrGr:r:r:r;rHasrHc@seZdZdd�ZdS)�TestPtpcCs�t�gd��}t|jdd�d�t�gd�gd�gd�g�}t|jdd�gd��t|jd	d�gd
��t|jddd�gd�g�t|jd
dd�dgg�dS)Nr@rru�.@rCrErF)r��@rKrY)r�r�r�Tr�rZr�)r4r�rZptpr}r:r:r;rdos
�zTestPtp.test_basicNrGr:r:r:r;rImsrIc@seZdZdd�ZdS)�
TestCumsumc
Cs�gd�}gd�gd�gd�g}tjtjtjtjtjtjtjtjtj	tj
f
D]�}t�||�}t�||�}t�gd�|�}ttj
|dd�|�t�gd�gd�gd	�g|�}ttj
|dd�|�t�gd
�gd�gd�g|�}ttj
|d
d�|�qJdS)N�rJrHr�r�rmrSrF�rJrHrRrF�rSrmrnr��r�rRrFrS)rJrRrWr#��#�'rru)rmrlr�rW)�r���)rJrRrmr�)rSr�rV�)r�rW��rJ)r4rr�int16�uint16�int32�uint32r�r��	complex64�
complex128r�r�cumsum)r`�ba�ba2�ctypera�a2�tgtr:r:r;rd~s$���zTestCumsum.test_basicNrGr:r:r:r;rL|srLc@seZdZdd�ZdS)�TestProdcCs�gd�}gd�gd�gd�g}tjtjtjtjtjtjtjtjfD]�}t�	||�}t�	||�}|dvr�t
ttj|�t
ttj|d�qBt
|jdd�d	�t|jdd�t�	gd
�|��t|jdd�t�	gd�|��qBdS)
NrMrNrOrP��1r~rJrru� g�re�$�T�rY)r#�b�X)r4rZr[r\r]r�r�r^r_r�r�ArithmeticError�prodrr�r`rarbrcrardr:r:r;rd�s"���zTestProd.test_basicNrGr:r:r:r;rf�srfc@seZdZdd�ZdS)�TestCumprodc	Csgd�}gd�gd�gd�g}tjtjtjtjtjtjtjtjfD]�}t�	||�}t�	||�}|dvr�t
ttj|�t
ttj|d�t
ttj|�qBt
tj|dd�t�	gd	�|��t
tj|d
d�t�	gd�gd�gd�g|��t
tj|dd�t�	gd
�gd�gd�g|��qBdS)NrMrNrOrPrgrJrYru)rJrHr7��i(i�rir)rSr�rkrj)rJrHrmr#)rSrQ��rn)r�rQr�ro)r4rZr[r\r]r�r�r^r_r�rrpZcumprodrrrr:r:r;rd�s@�
��
���
���zTestCumprod.test_basicNrGr:r:r:r;rs�srsc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�TestDiffcCs�gd�}t�gd��}t�gd��}t�ddg�}tt|�|�tt|dd�|�tt|dd�|�gd	�}t�gd
��}tt|�|�gd�}t�gd��}t�d
d
g�}tt|�|�tt|dd�|�dS)N)rJrFrmrnr)rRrHrJrS)rYrYrFrrSrH�r8rR)皙�����?皙����@r�g������ɿ皙������)ryg�������?g������	�皙�����?)TTFFr�T)r4r�rrr	)r`r��out�out2�out3r:r:r;rd�szTestDiff.test_basiccCs�t�d�}d|dd�ddd�dd�f<t�d�}d|dd�ddd�dd�f<tt|�t�d��tt|dd�t�d��tt|dd�t�d	��tt|dd�|�tt|d
d�|�ttjt|dd�ttjt|dd�t�d
tj�}tt	t|�dS)N)r�r7rQrJrH)r��rQrY)r�r7�rur)r�r7rQrPrRr$g��q��?)
r4r=r^rrrryr�r�r])r`r��expr:r:r;�	test_axis�s

zTestDiff.test_axiscCs*dtddd�}|dd�dd�dd�f|dd�dd�dd�f}|dd�dd�dd�f|dd�dd�dd�f}|dd�dd�dd�f|dd�dd�dd�f}|dd�dd�dd�f|dd�dd�dd�f}tt|�|�tt|dd�|�tt|dd	�|�tt|ddd
�|�dS)Nr7r�rQrJrYrHrxrru)r8rv)rrr)r`r�Zout1r~rZout4r:r:r;r��s4444zTestDiff.test_ndcs�ttd���ttt�dd��fdd�tdd�D�}ddgdgggg}tt�dd��u�tt||�dd	�D]R\}\}}tt|�t	j
u�t||�t|j
t	j�tt|�tdt��|��qldS)
NrRrYrxcsg|]}t�|d��qS)rx)r)r�r8�r�r:r;r��r�z#TestDiff.test_n.<locals>.<listcomp>rJrSr��start)�listr_rr]rr�	enumerater�r�r4r�rrr�rr��max)r`r��expectedr8r}r:r�r;�test_n�s
zTestDiff.test_ncCs�tjddtjd�}tjddgdd�tjdgdd�g}|�tjgdd�gd�t|dd�D],\}}t||d	�}t||�t|j	|j	�qZdS)
Nz
1066-10-13z
1066-10-16r�rJ�timedelta64[D]rrRr�rx)
r4r5Z
datetime64r��extendr�rrrr�)r`r�r�r8r�r}r:r:r;�
test_times�s�
zTestDiff.test_timescCs�tjddgddgddgddgd	d
ggddgddgddgddgddggd
�}t|�}t|jdgdgdgdgdgg�t|jdgdgdgdgdgg�tt|�t|�u�t|dd�}t|jgggggg�t|jgggggg�tt|�t|�u�dS)NrJrHrRrFrSrmrnrlr�r�FT��maskrx)rr�rrr9r�rr�)r`r�r}rr:r:r;r/
s$�� �zTestDiff.test_subclasscCsNt�d�d}tt|dd�t�d��tt|dgd�t�d��tt�tj|dd��|�tt|ddgd�t�d��t�d��dd�}tj|ddd	�}ddgddgg}t||�tj|ddgdggd	�}t||�tj|ddd	�}ddgddgg}t||�tj|dddggd	�}t||�tttj|t�	d
�d�ttj
t|ddd�dS)
NrSrJr)�prependrYrmrFrH)rvr��rRrRrR)r�rv)r4r5rrr^r`rorr]r=ry�r`r��resultr�r:r:r;�test_prepends$



zTestDiff.test_prependcCs<t�d�}t|dd�}gd�}t||�t|dgd�}t||�t|ddgd�}|dg}t||�t�d��dd�}tj|ddd�}dd	gdd
gg}t||�tj|ddgdggd�}t||�tj|ddd�}ddgdd
gg}t||�tj|dddggd�}t||�tttj|t�d�d�ttjt|dd
d�dS)NrSr)�append)rJrJrJrJr$rHrFrJ)rvr�rYrVrPr�rR)r�rv)	r4r5rrrorr]r=ryr�r:r:r;�test_append1s,








zTestDiff.test_appendN)rqrrrsrdr�r�r�r�r/r�r�r:r:r:r;rw�srwc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zej
�de�dg�dgg�dd��Zdd�ZdS)�
TestDeletecCs,t�d�|_t�d��d��ddd�|_dS)NrSrHrJ)r4r5rar%ro�nd_ar{r:r:r;�setup_methodPszTestDelete.setup_methodcCs�t|j|�}t|j|dd�}d|}tt||j|f�|j|d�t|ddd�df|jd|df�}t||jddd�df|d�dS)NrJruzDelete failed for obj: %r)�err_msgr)rrar�rr,)r`�indices�a_del�nd_a_del�msg�xorr:r:r;�_check_inverse_of_slicingTs�$z$TestDelete._check_inverse_of_slicingcCsHgd�}gd�}|D].}|D]$}|D]}t|||�}|�|�q$qqdS)N)���rPrrJrHrFrS)rVrYrJrR)rr�)r`ZlimsZstepsr��stop�step�sr:r:r;�test_slices]szTestDelete.test_slicescCsX|�t�ddgddgg��t�t��t|jdg�Wd�n1sJ0Yt�t��t|jdg�Wd�n1s�0Y|�gd��|�gd��t�t��t|jd�Wd�n1s�0Yt�t��t|jd	�Wd�n1�s0Yt�t��"t|jd	gd
�Wd�n1�sJ0YdS)NrrJrHri����)rrYrHrH)TFFTFTFrF)	r�r4r�r�r*r8rrar]r{r:r:r;�
test_fancyfs,,*,zTestDelete.test_fancycCs|�d�|�d�dS)Nrr$)r�r{r:r:r;�test_single{s
zTestDelete.test_singlecCs�t�d�}t�tj��t|gdd�Wd�n1s:0Yt�t��t|gdd�Wd�n1sr0YdS)NrJrrur))r4r�r�r*ryrrrjr:r:r;r+s

,zTestDelete.test_0dcCs�Gdd�dtj�}|j�|�}ttt|d�|��ttt|g�|��ttt|ddg�|��ttt|tdd��|��ttt|tdd��|��dS)Nc@seZdZdS)z*TestDelete.test_subclass.<locals>.SubClassNr�r:r:r:r;r,�sr,rrJrHrP)r4r�rar�rr-rrr.r:r:r;r/�szTestDelete.test_subclasscCsRt�d�jdddd�}t|tdd�dd�}t|jj|jj�t|jj|jj�dS)	Nr�rHrSr�r��<rJru)	r4r5rorrrr�r�r�)r`rXr�r:r:r;�test_array_order_preserve�sz$TestDelete.test_array_order_preservecCs�t�t��*t�gd�t�ddg��Wd�n1s:0Yt�t��*t�gd�tjgtd��Wd�n1s~0YdS)NrIr�r�r�)r�r*r8r4rr�r9r{r:r:r;r:�s8zTestDelete.test_index_floats�indexerrJcCsXt|jd�}t|j|�}t||�t|jddd�}t|jt�dg�dd�}t||�dS)NrJru)rrarr�r4r�)r`r�Z	a_del_intr�Znd_a_del_intr�r:r:r;�test_single_item_array�s
z!TestDelete.test_single_item_arraycCs$tt�d�t�dg��}t|t�d��t�d�}tjdgtd�}tjdgtd�}t||dd�}t||�t||dd�}t||dd�dd�f�t�t��,tt�d	�tjdgt	d��Wd�n1s�0Yt�t��,tt�d	�tjdgd
d��Wd�n1�s0YdS)NrJF)rRrJr�TrYrurrHzm8[ns])
rr4r^r�r�boolr�r*r8�object)r`�resr�Z
false_maskZ	true_maskr:r:r;�test_single_item_array_non_int�s

:z)TestDelete.test_single_item_array_non_intN)rqrrrsr�r�r�r�r�r+r/r�r:r�r�r�r4r�r�r�r:r:r:r;r�Ns		


	r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
ej�dejejejejg�dd��Zej�dejejejejg�dd��Zej�dejejejejg�dd��Zej�dejejejejg�dd ��Zd!S)"�TestGradientcCsfddgddgg}t�|�}t�ddgddgg�t�ddgddgg�g}tt|�|�tt|�|�dS)NrJrRrFr�r�r�r�)r4r�rr�r`�vr��dxr:r:r;rd�s
�zTestGradient.test_basicc	Cs�t�t�d��}gd�}t�d��dd�}tt�d�d�tt�d�t�d��tt�d�|�t|d�t|t�d��t|||�t||d�t||dd�ttd	t|tj	|gdd
d�d�dS)NrS)r�r�r�rD�&@�r���?rHrJruz.*scalars or 1drY)
r4r`r^r5rorr�rr]�stack)r`r�Z	dx_uneven�f_2dr:r:r;�	test_args�s
�zTestGradient.test_argscCs�t�d��dd�}t�t�d��}ttt||t�d��ttt|dt�d��ttt|t�d�t�d��ttt||�ttt||dd�ttt||||�ttt|ddd�ttt|||dd�ttt|dddd�dS)Nr�rSrHrJrZru)	r4r5ror`r^rr]rr)r`r�r�r:r:r;�test_badargs�szTestGradient.test_badargscCsJtjgd�dd�}tjgd�dd�}tt|�|�t|jt�d�k�dS)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�)rArVr��=i�i�r��r4r�rrrr��r`r�r�r:r:r;�test_datetime64�s��zTestGradient.test_datetime64cCs�tjjddgddggddgddggd�}t|�d}tt|�t|��t|j|ju�tj�d�}tjj	|d<tj|dd	�t
|jgd
��dS)NrJrRrFFr�rrSrH��
edge_order)FFTFF)r4rr�rrr�rZ_maskr5�maskedrr�)r`r�r}�x2r:r:r;�test_maskeds�zTestGradient.test_maskedcCst�ddd�}|d|d}d|dd|dd|}d|dd|d}t�tj||dd	�|d�}tt�|d
k�dk�tj�d�t�tj�d��}d|dd|dd|}d|dd|d}t�tj||dd	�|d�}tt�|d
k�dk�dS)NrrJr�rHrRrFrmrlr�g���Q��?T)	r4�linspace�absrrr��randomZseed�sort)r`r�r�r�Z
analyticalZ	num_errorr:r:r;�test_second_order_accurates  z'TestGradient.test_second_order_accuratec
Cs�t�gd��}t�|d�|�dd�}t�gd��}t�d�}t�gd�d�}t�gd�d�}t�gd	�d�}t�gd
�d�}d|fd|ffD]�\}}	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||	�q�d|fd|ffD]�\}}	t|||d
|d�}
t|||d|d�}t|
|�t|
d|	j�t|
d|	�t||d|d�}
t|
|	j�t||d|d�}
t|
|	��q�t|||d
dd�}
t|||ddd�}t|
d|d�t|
d|d�t|
d|j�t|
d|�t|||d
dd�}
t|||ddd�}t|
d|d�t|
d|d�t|
d|j�t|
d|�dS)N)rr�r�r�r�r�)rmrJrYrJ)r���?r�r�r�rKr�)r�r�r�r�r�r�)�@r�r�r�r���)r�r��333333�?r���?r�)r�r�r�r�r�gпrHr�rZ)rvr�rr[)r4r�Ztileror5rrr	r&rr?)
r`�fZx_unevenZx_evenZ
fdx_even_ord1Z
fdx_even_ord2Zfdx_uneven_ord1Zfdx_uneven_ord2r�Zexp_res�res1�res2�res3r:r:r;�test_spacing%sl
��

��
zTestGradient.test_spacingcCs@ddgddgg}t�|�}t�ddgddgg�t�ddgddgg�g}tt|dd	�|d�tt|dd	�|d�tt|d
d	�|d�tt|dd	�|d|dg�tt|dd	�|d|dg�tt|dd	�t|��tt|dddd	�|dd|ddg�ttt|dddd	�ttjt|dd	�ttjt|d
d	�dS)NrJrRrFr�r�r�r�rrurYr[rHrV)r4r�rrr	rrryr�r:r:r;�test_specific_axeses"
��zTestGradient.test_specific_axescCsJtjgd�dd�}tjgd�dd�}tt|�|�t|jt�d�k�dS)N)rArVr�rr�iA�,r�r�)rHrnrnr���wi��r�r�r:r:r;�test_timedelta64s��zTestGradient.test_timedelta64cCsDtjtjtjfD].}tjgd�|d�}tt|�jt�|�j�qdS)Nr�r�)	r4�float16r�r�r�rrr�r)r`Zdtr�r:r:r;�test_inexact_dtypes�sz TestGradient.test_inexact_dtypescCs�tt�d�dd�tt�d�dd�tttt�d�dd�tttt�d�dd�tttt�d�dd�tttt�d�dd�tttt�d�dd�dS)NrHrJr�rRr)rr4r5rr]r{r:r:r;�test_values�szTestGradient.test_values�f_dtypecCs2tjgd�|d�}t|�}t|dgt|��dS)N)rSrFrRrHrJr�rY�r4r�rrr�)r`r�r��gr:r:r;�test_f_decreasing_unsigned_int�sz+TestGradient.test_f_decreasing_unsigned_intcCsRt�|�j}t�ddg�}tjd|g|d�}t||�}t||ddgd�dS)NrJrRrYr�rH)r4�iinfor�r�rr)r`r��maxintr�r��dfdxr:r:r;�test_f_signed_int_big_jump�s

z'TestGradient.test_f_signed_int_big_jump�x_dtypecCsBtjgd�|d�}t�gd��}t||�}t|dgt|��dS)Nr�r��rrHrFrPr�)r`r�r�r�r�r:r:r;�test_x_decreasing_unsigned�s
z'TestGradient.test_x_decreasing_unsignedcCsXt�|�j}t�|�j}tjd|g|d�}t�|ddg�}t||�}t|ddg�dS)NrYr�rHrr�)r4r��minr�r�rr)r`r�Zminintr�r�r�r�r:r:r;�test_x_signed_int_big_jump�s
z'TestGradient.test_x_signed_int_big_jumpN)rqrrrsrdr�r�r�r�r�r�r�r�r�r�r�r�r�r4rr[r]Zuint64r�rrZr\Zint64r�r�r�r:r:r:r;r��s6@�
�
�
�r�c@seZdZdd�Zdd�ZdS)�	TestAnglecCs�dt�d�ddt�d�ddddddd	g}t|�}t�d
�t�d�dtjdtjtjdt�d
�tjt�d
�g}t|d
d�}t�|�dtj}t||d�t||d�dS)N��?@rHr�rrJrY����?�y�@r�r�rT)Zdegrmr�)r4�sqrtr�arctan�pir�r
)r`r�r�Zyo�zZzor:r:r;rd�s � �zTestAngle.test_basiccCs�tj�ddt�d�ddg�}tjj|d<tj�t�d�dt�d�g�}tjj|d<t|�}tt|�t|��t|j	|j	�t||�dS)Nr�rJrH��?�?r�rr�)
r4rr�r�r�r�rrr�r�)r`r�r�r�r:r:r;r/�s zTestAngle.test_subclassN)rqrrrsrdr/r:r:r:r;r��s
r�c	@s�eZdZe�gd��Ze�e�Ze�e	�Z
e�e�Zdd�Z
dd�Zdd�Zdd	�Zd
d�Zdd
�Zej�de�gd��e�gd��e�gd��g�dd��Zdd�Zdd�ZdS)�
TestTrimZeros)rrrJrrHrRrFrcsd}�fdd�|D�S)N)rar~r�rc3s|]}t�|�VqdSr3)�getattr)r��namer{r:r;�	<genexpr>�r�z'TestTrimZeros.values.<locals>.<genexpr>r:)r`Z
attr_namesr:r{r;r��szTestTrimZeros.valuescCs6tjdd�}|��D]}t|�}t|||�qdS)NrHrY�r4�s_r�r/r�r`�slc�arrr�r:r:r;rd�szTestTrimZeros.test_basiccCs:tjdd�}|��D]}t|dd�}t|||�qdS)NrYr~�Ztrimr�r�r:r:r;�test_leading_skip�szTestTrimZeros.test_leading_skipcCs:tjdd�}|��D]}t|dd�}t|||�qdS)NrHr�r�r�r�r:r:r;�test_trailing_skip�sz TestTrimZeros.test_trailing_skipcCsZ|��D]L}tj||jd�}t|dd�}t|�dks8J�t|dd�}t|�dksJ�qdS)Nr��Br�rr�)r�r4Z
zeros_liker�r/r�)r`Z_arrr�r�r�r:r:r;�
test_all_zero�szTestTrimZeros.test_all_zerocCs t�d�}t|�}t||�dSr)r4r=r/r�r`r�r�r:r:r;�test_size_zeros
zTestTrimZeros.test_size_zeror�)rlr)rlr)rlrcCs(tjdd�}t|�}t|||�dS)NrJrH)r4r�r/r)r`r�r�r�r:r:r;�
test_overflowszTestTrimZeros.test_overflowcCs$t�gd��}t|�}t||�dS)N)NrJN)r4r�r/rrr:r:r;�test_no_trimszTestTrimZeros.test_no_trimcCs t|j���}t|t�sJ�dSr3)r/ra�tolistr-r�)r`r�r:r:r;�test_list_to_listszTestTrimZeros.test_list_to_listN)rqrrrsr4r�rar�r9r~�complexr�r�rr�rdr�r�rrr�r�r�rrrr:r:r:r;r��s(



��
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�
TestExtinscCs.t�gd��}t|dk|�}t|gd��dS)N)rJrRrHrJrHrRrRrJ)rRrHrHrRrR)r4r�rrr}r:r:r;rdszTestExtins.test_basiccs�tttgd�ddgddg�t�gd���t�gd�gd��t�gd	��t�t�d
�g�t�t�dd��t�gd�dd
g�t�gd��tt	d�fdd��t�ddg��t�ddgd�t�ddg�dS)Nr�TFrrJ)rJrFrRrHrSrlrn)rrJrrJrrJr�rHrFrm)rJrHrRrFrSrmrnrnrl)rJrrJrrJrrJr�)rlrHr�rFrlrmr�z!Cannot insert from an empty arraycst�gd�g�S)N)rrrrrrJr)r)r:�rar:r;�<lambda>0r�z'TestExtins.test_place.<locals>.<lambda>Z12Z34�9)
rrr)r4r�rr=r5rr]r{r:r
r;�
test_place!s
�zTestExtins.test_placecCsHtd�}|dk}|��}t||�}t||d�t|||�t||�dS)Nr�r�r)rr�rr)r)r`rar�Zacr�r:r:r;�	test_both7s
zTestExtins.test_bothN)rqrrrsrdr
rr:r:r:r;rsrr�cCs|t�|�Sr3��mathZfloor�r�r�r:r:r;�_foo1Csrr�cCs|t�|�|Sr3r)r�r�r�r:r:r;�_foo2Gsrc@s$eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGS)H�
TestVectorizecCs4dd�}t|�}|gd�gd��}t|gd��dS)NcSs||kr||S||SdSr3r:�rar~r:r:r;�addsubtractNsz.TestVectorize.test_simple.<locals>.addsubtract�rrRrmr��rJrRrSrn�rJrmrJrH�r2r�r`rr�r'r:r:r;�test_simpleMszTestVectorize.test_simplecCs0dd�}t|�}|gd�d�}t|gd��dS)NcSs||kr||S||SdSr3r:rr:r:r;rYsz.TestVectorize.test_scalar.<locals>.addsubtractrrS)rSrlrJrFrrr:r:r;�test_scalarXszTestVectorize.test_scalarcCs0t�ddd�}tdd��}||�}t||�dS)NrVrHi'cSs|Sr3r:r�r:r:r;rer�z*TestVectorize.test_large.<locals>.<lambda>)r4r�r2r)r`r�r�r�r:r:r;�
test_largecszTestVectorize.test_largecCsRttj�}t�ddtjtjdtjdtjg�}||�}t�|�}t||�dS)Nrr�r�rH)r2rZcosr4r�r�r
)r`r��args�r1�r2r:r:r;�
test_ufuncis

(
zTestVectorize.test_ufunccCsfddd�}t|�}t�gd��}||�}t�gd��}t||�||d�}t�gd��}t||�dS)	NrJcSs||Sr3r:rr:r:r;r2rsz(TestVectorize.test_keywords.<locals>.foor�r�rHrQ)rJ�r2r4r�r�r`r2r�rr r!r:r:r;�
test_keywordsps


zTestVectorize.test_keywordscCs:tttgd�}|t�d�d�}|t�d��}t||�dS�N��otypesr�r��r2rr9r4r5r�r`r�r r!r:r:r;� test_keywords_with_otypes_order1~sz.TestVectorize.test_keywords_with_otypes_order1cCs:tttgd�}|t�d��}|t�d�d�}t||�dSr&r)r*r:r:r;� test_keywords_with_otypes_order2�sz.TestVectorize.test_keywords_with_otypes_order2cCsTtttgd�}|t�d��}|t�d�dd�}|t�d��}t||�t||�dS)Nr'r�r��r�r)�r`r�r r!Zr3r:r:r;� test_keywords_with_otypes_order3�s
z.TestVectorize.test_keywords_with_otypes_order3cCsdtttgd�}|ddd�}|ddd�}|d�}t|tddd��t|tddd��t|td��dS)Nr'�������$@r)r�rYr-�r2rr9rr.r:r:r;�+test_keywords_with_otypes_several_kwd_args1�sz9TestVectorize.test_keywords_with_otypes_several_kwd_args1cCsRtttgd�}|dddd�}|ddd�}t|tdddd��t|tddd��dS)	Nr'rr0rY)r�r�r�rJrHrRr1r*r:r:r;�+test_keywords_with_otypes_several_kwd_args2�s
z9TestVectorize.test_keywords_with_otypes_several_kwd_args2cCs4ddl}zt|j�Wnty.t��Yn0dSr)r�r2Z	randrange�	Exception�AssertionError)r`r�r:r:r;�test_keywords_no_func_code�s
z(TestVectorize.test_keywords_no_func_codecCs�ddd�}t|�}t�gd��}||d�}t�gd��}t||�|d|d�}t||�||dd	�}t�gd
��}t||�dS)NrJcSs||Sr3r:rr:r:r;r2�sz5TestVectorize.test_keywords2_ticket_2100.<locals>.foor�r
r�)r~rarH�r~rQ)rJr#r$r:r:r;�test_keywords2_ticket_2100�s



z(TestVectorize.test_keywords2_ticket_2100cCsrdd�}tj|ddgd�}ddg}t||ddggd	�d
��t||ddggd	�d��t||ddggd	���dS)NcSs.t|�}|�d�}|r*|||�d�}q|Sr)r��pop)r��pZ_pr�r:r:r;�	mypolyval�s

z;TestVectorize.test_keywords3_ticket_2100.<locals>.mypolyvalr:rJ)�excludedrRrmrr�)r�r:)r:)r4r2r)r`r;ZvpolyvalZansr:r:r;�test_keywords3_ticket_2100�sz(TestVectorize.test_keywords3_ticket_2100cCs.tdd��}t|ddgddgd�ddg�dS)	Nc[sd}|D]}|||9}q|S�Nr�r:)�kwr�Z_kr:r:r;r��sz3TestVectorize.test_keywords4_ticket_2100.<locals>.frJrHrRrFrrlr�r`r�r:r:r;�test_keywords4_ticket_2100�s
z(TestVectorize.test_keywords4_ticket_2100cCs,tdd��}t|ddgddg�ddg�dS)NcWs
t�|�Sr3)r4rq)r�r:r:r;r��sz3TestVectorize.test_keywords5_ticket_2100.<locals>.frJrHrRrFrlrr@r:r:r;�test_keywords5_ticket_2100�s
z(TestVectorize.test_keywords5_ticket_2100cCs dd�}t|�}t|�d�dS)NcSsdS�NrJr:r:r:r:r;r2�sz5TestVectorize.test_coverage1_ticket_2100.<locals>.foorJr�r`r2r�r:r:r;�test_coverage1_ticket_2100�sz(TestVectorize.test_coverage1_ticket_2100cCs>dd�}t|�}t|j|j�d}t||d�}t|j|�dS)NcSs|S)zOriginal documentationr:r�r:r:r;r2�sz3TestVectorize.test_assigning_docstring.<locals>.foozProvided documentation)�doc)r2r�__doc__)r`r2r�rFr:r:r;�test_assigning_docstring�sz&TestVectorize.test_assigning_docstringcCs`Gdd�d�}tt|�j�t�d��t�d�d�tt|j�|�t�d��t�d�d�dS)Nc@seZdZdZdd�ZdS)z9TestVectorize.test_UnboundMethod_ticket_1156.<locals>.FoorHcSs
||jSr3r7rjr:r:r;r3sz=TestVectorize.test_UnboundMethod_ticket_1156.<locals>.Foo.barN)rqrrrsr~r3r:r:r:r;�Foo	srIr�rH)rr2r3r4r5)r`rIr:r:r;�test_UnboundMethod_ticket_1156s��z,TestVectorize.test_UnboundMethod_ticket_1156cCsltdd��}|t�d��}|t�dd��}tdd��}|t�dd��}|t�d��}t||�t||�dS)NcSs|Sr3r:r�r:r:r;rr�z@TestVectorize.test_execution_order_ticket_1487.<locals>.<lambda>rRr|cSs|Sr3r:r�r:r:r;rr�)r2r4r5r)r`�f1Zres1aZres1b�f2Zres2bZres2ar:r:r;� test_execution_order_ticket_1487s
z.TestVectorize.test_execution_order_ticket_1487cCs$t�dd��}d}t|||��dS)NcSs|Sr3r:r�r:r:r;r!r�z7TestVectorize.test_string_ticket_1892.<locals>.<lambda>Zd0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789)r4r2r)r`r�r�r:r:r;�test_string_ticket_1892sz%TestVectorize.test_string_ticket_1892csNdg�t�fdd��}d|_t�d�}t||�||�t�dt|��dS)Nrcs�dd7<|dS)NrrJrHr:r��Z_callsr:r;r�)sz#TestVectorize.test_cache.<locals>.fTrS)r2�cacher4r5rrr��r`r�r�r:rOr;�
test_cache%s
zTestVectorize.test_cachecCs0t�dd��}d|_t�d�}t||�|�dS)NcSs|Sr3r:r�r:r:r;r4r�z+TestVectorize.test_otypes.<locals>.<lambda>r�rS)r4r2r(r5rrQr:r:r;�test_otypes3s
zTestVectorize.test_otypescCs�tt�d�dgdgf�tt�d�dgdgf�tt�d�ddgdgf�tt�d�dgdgf�tt�d	�dgddgf�tt�d
�gd�dgf�tt�d
�dgdgf�tt�d�dgdgf�tt�d�ddgdgf�tt�d�dgdgf�tt�d�dgddgf�tt�d�gd�dgf�tt��t�d�Wd�n1�sV0Ytt��t�d�Wd�n1�s�0Ytt��t�d�Wd�n1�s�0YdS)Nz(x)->()r�r:z	(x,y)->()rz(x),(y)->()r-z(x)->(y)z(x)->(y),()z(),(a,b,c),(d)->(d,e))r:)rar~r�)r)r�ez(x )->()z( x , y )->(  )z
(x),( y) ->()z(  x)-> (y )  z (x)->( y),( )z*(  ), ( a,  b,c )  ,(  d)   ->   (d  ,  e)z
(x)(y)->()z	(x),(y)->z
((x))->(x))r�nfbZ_parse_gufunc_signaturerr]r{r:r:r;�test_parse_gufunc_signature9sP

�
�

�
�
�

�
�

�
���
*
*
z)TestVectorize.test_parse_gufunc_signaturecCs8dd�}t|dd�}|gd�gd��}t|gd��dS)NcSs||kr||S||SdSr3r:rr:r:r;r\sz8TestVectorize.test_signature_simple.<locals>.addsubtractz	(),()->()��	signaturerrrrrr:r:r;�test_signature_simple[sz#TestVectorize.test_signature_simplecCs:dd�}t|dd�}|ddgddgg�}t|ddg�dS)	NcSs|��Sr3�r�r
r:r:r;r�gsz4TestVectorize.test_signature_mean_last.<locals>.meanz(n)->()rWrJrRrHrFr)r`r�r�r'r:r:r;�test_signature_mean_lastfsz&TestVectorize.test_signature_mean_lastcCsBdd�}t|dd�}|ddgddgg�}t|d	dgd	dgg�dS)
NcSs||��Sr3rZr
r:r:r;�centerosz3TestVectorize.test_signature_center.<locals>.center�(n)->(n)rWrJrRrHrFrYr)r`r\r�r'r:r:r;�test_signature_centernsz#TestVectorize.test_signature_centercCs^tdd�dd�}|gd��}tt|t�o2t|�dk�t|dgd��t|dgd��dS)	NcSs||fSr3r:r�r:r:r;rwr�z:TestVectorize.test_signature_two_outputs.<locals>.<lambda>�	()->(),()rWr�rHrrJ)r2rr-�tupler�r�r`r�r'r:r:r;�test_signature_two_outputsvs
z(TestVectorize.test_signature_two_outputscCs�ttjdd�}|ddggd��}t|gd�gd�g�|ddggggd��}t|gd�gd�ggg�|ddgddgggd��}t|gd�gd�ggd�gd�gg�|ddggd�gd�g�}t|gd�gd�ggd�gd�gg�dS)	Nz(a),(b)->(a,b)rWrJrHr�r	rr�)r2r4r7rrar:r:r;�test_signature_outer}s��z"TestVectorize.test_signature_outercCsXtdd�dd�}|gd��}t|ddg�|gd�gd�g�}t|ddgdd	gg�dS)
NcSs|dd�S�NrYr:r�r:r:r;r�r�z<TestVectorize.test_signature_computed_size.<locals>.<lambda>z(n)->(m)rWr�rJrHr�rRrrar:r:r;�test_signature_computed_size�s
z*TestVectorize.test_signature_computed_sizecCsNddd�}t|ddhd�}t|gd��gd��t|gd�d	d
�gd��dS)NrJcSs||Sr3r:rr:r:r;r2�sz2TestVectorize.test_signature_excluded.<locals>.foo�()->()r~)rXr<r�r�rr7)rJrrDr:r:r;�test_signature_excluded�s
z%TestVectorize.test_signature_excludedcCsDtdd�ddgd�}|gd��}t|jt�d��t|gd��dS)NcSs|Sr3r:r�r:r:r;r�r�z5TestVectorize.test_signature_otypes.<locals>.<lambda>r]r��rXr(r�)r2rr�r4rrar:r:r;�test_signature_otypes�sz#TestVectorize.test_signature_otypescCs�ttjdd�}ttd��|ddg�Wd�n1s:0Yttd��|dd�Wd�n1sn0Yttd��"|ddggd��Wd�n1s�0Yttjd	d�}ttd��|dd�Wd�n1s�0YdS)
Nz(n),(n)->(n)rWzwrong number of positionalrJrHzdoes not have enough dimensions�$inconsistent size for core dimensionr�rf)r2�operatorr6rrr]r@r:r:r;�test_signature_invalid_inputs�s*�(�0z+TestVectorize.test_signature_invalid_inputscCs�tdd�dd�}ttd��|gd��Wd�n1s<0Ytdd�dd�}ttd	��|d
�Wd�n1s~0Ytdd�dd�}ttd	��|d
d
g�Wd�n1s�0YdS)NcSs|dd�Srdr:r�r:r:r;r�r�z>TestVectorize.test_signature_invalid_outputs.<locals>.<lambda>r]rWrjr�cSs|Sr3r:r�r:r:r;r�r�r_zwrong number of outputsrJcSs||fSr3r:r�r:r:r;r�r�rfrH)r2rr]r@r:r:r;�test_signature_invalid_outputs�s�*&z,TestVectorize.test_signature_invalid_outputscCs^t�dd��}tjddgtd�}ttd��||�Wd�n1sH0Yd|_t||�|�tjdd�d	d
�}ttd��||�Wd�n1s�0Ytjdd�d	dd�}t||�|�tjd
d�ddd�}t||�|�tjdd�dd
�}t||j�|j�tjdd�ddd�}ttd��||�Wd�n1�sP0YdS)NcSs|Sr3r:r�r:r:r;r�r�z5TestVectorize.test_size_zero_output.<locals>.<lambda>rrSr�r(r�cSs|Sr3r:r�r:r:r;r�r�rfrWcSs|Sr3r:r�r:r:r;r�r�rhcSs|Sr3r:r�r:r:r;r�r�r]cSs|Sr3r:r�r:r:r;r�r�cSs|gSr3r:r�r:r:r;r�r�z()->(n)znew output dimensions)	r4r2r=�intrr]r(rr&rQr:r:r;�test_size_zero_output�s$&&z#TestVectorize.test_size_zero_outputcCs�Gdd�dtj�}t�gd�gd�gd�g��|�}t�gd�gd�gd�g��|�}tjtjd	d
�}|||�}tt|�|�t|gd�gd�gd
�g�t�dd��}|||�}tt|�|�t|||�dS)Nc@seZdZdS)z/TestVectorize.test_subclasses.<locals>.subclassNr�r:r:r:r;r��sr�)r�r�r�r)r�r�r�r�)r�r�r�)rKr�rDz(m,m),(m)->(m)rW)r�r�r�)r�r�r�)rKrDr�cSs||Sr3r:rr:r:r;r�r�z/TestVectorize.test_subclasses.<locals>.<lambda>)r4r�r�r�r2�matmulrr�)r`r�r�r�Zmatvecr'Zmultr:r:r;r��s 
��"

zTestVectorize.test_subclassesN)&rqrrrsrrrr"r%r+r,r/r2r3r6r8r=rArBrErHrJrMrNrRrSrVrYr[r^rbrcrergrirlrmror�r:r:r:r;rKsF



"	rc@sLeZdZGdd�d�Zejjedd�ej�ddej	fdg�dd	���Z
d
S)�	TestLeaksc@s$eZdZdZdd�Zedd��ZdS)zTestLeaks.Ar7cGsdSrr:�r`rr:r:r;�bound�szTestLeaks.A.boundcGsdSrr:)rr:r:r;�unbound�szTestLeaks.A.unboundN)rqrrrs�itersrs�staticmethodrtr:r:r:r;�A�srw�Python lacks refcounts��reasonz
name, incrrs)rtrc	Cs�ddl}t|j|�}|��z�t�|�}t|jj�D]2}|��}t�	t||�dd�|_
|�
t�d��}q4d}tt�|�||�td�D]}|�
�q�tt�|�|�W|��n
|��0dS)NrrJr�rS)�gcr�rw�disable�sys�getrefcountr_rur4Z
frompyfuncr�r5rZcollect�enable)	r`r�Zincrr{ZA_funcZrefcountr�rar}r:r:r;�test_frompyfunc_leaks�s

zTestLeaks.test_frompyfunc_leaksN)rqrrrsrwr�r��skipifrr�rur�r:r:r:r;rq�s
�rqc@szeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
ejjdd�dd��ZdS)�TestDigitizecCs2t�dd�}t�dd�}tt||�t�d��dS)Nr�rSrAr��r4r5rr�r`r��binsr:r:r;�test_forwardszTestDigitize.test_forwardcCs6t�ddd�}t�ddd�}tt||�t�d��dS)NrSr�rYrAr�r�r�r:r:r;�test_reverse"szTestDigitize.test_reversecCs:td�}t�|��|��d�}tt�t||�dk��dS)Nr�r�rr4r�r�r�rr�r)r`r��binr:r:r;�test_random'szTestDigitize.test_randomcCsFgd�}gd�}gd�}tt||�|�gd�}tt||d�|�dS)N)rJrSrFr�rlr�r)rJrSr�)rJrHrJrRrHrRr)rrJrJrHrHrRrT)rr)r`r�r�Zdefault_answerZright_answerr:r:r;�test_right_basic,szTestDigitize.test_right_basiccCs4t�dd�}t�dd�}tt||d�t�d��dS)Nr�rSrFTr�r�r�r:r:r;�test_right_open4szTestDigitize.test_right_opencCs8t�ddd�}t�ddd�}tt||d�t�d��dS)NrSr�rYrFTr�r�r�r:r:r;�test_right_open_reverse9sz$TestDigitize.test_right_open_reversecCs<td�}t�|��|��d�}tt�t||d�dk��dS)Nr�Tr�r�r:r:r;�test_right_open_random>sz#TestDigitize.test_right_open_randomcCs�gd�}gd�}tt||d�gd��tt||d�gd��gd�}tt||d�gd��tt||d�gd	��gd
�}tt||d�gd��tt||d�gd��gd
�}ttt||�gd�}ttt||�dS)N)rYrrJrHr�F)rrHrRrRT)rrrHrRr�)rRrHrr)rRrRrHrr�)rrrFrF)rrrrFr�)rJrJrrJ)rrrr]r�r:r:r;�test_monotonicCszTestDigitize.test_monotoniccCs:gd�}gd�}ttt||�||}}ttt||�dS)N)rJrHy@�?r�)rrrr�r:r:r;�test_casting_errorSs

zTestDigitize.test_casting_errorcCshGdd�dtj�}t�d��|�}t�dd��|�}ttt||d�|��ttt||d�|��dS)Nc@seZdZdS)z(TestDigitize.test_return_type.<locals>.ANr�r:r:r:r;rw\srwrSrJrRFT)r4r�r5r�rr-r)r`rwrar~r:r:r;�test_return_typeZs
zTestDigitize.test_return_typecCs&d}tt�||d|dg�d�dS�NlrJ�rr4rr0r:r:r;�test_large_integers_increasingcsz+TestDigitize.test_large_integers_increasingz8gh-11022: np.core.multiarray._monoticity loses precisionrycCs&d}tt�||d|dg�d�dSr�r�r0r:r:r;�test_large_integers_decreasinghsz+TestDigitize.test_large_integers_decreasingN)rqrrrsr�r�r�r�r�r�r�r�r�r�r�r�r��xfailr�r:r:r:r;r�s	�r�c@seZdZdd�Zdd�ZdS)�
TestUnwrapcCsHttdddtjg�ddg�tt�tttd�d��tjk��dS)NrJrHr�r)rr0r4r�rr�rrr{r:r:r;rrs zTestUnwrap.test_simplecCs�ttddgdd�ddg�tt�tttd�ddd��dk��t�gd��}t�|d�}tt|dd�|�t�gd	��}t�|d
�}t|d
d�}t|gd��t|d
dd
�}t|gd	��|j	|j	ks�J�dS)NrJi���periodrHr���)r�K���r�)rr�r�r�r�i��)rr�r�r�r�rm�)r�Zdiscont)
rr0rr4r�rrr��modr�)r`Z
simple_seqZwrap_seqZ
uneven_seqZwrap_unevenZ
no_discontZ
sm_discontr:r:r;�test_periodxs&zTestUnwrap.test_periodN)rqrrrsrr�r:r:r:r;r�psr�r��O�
AllIntegerZFloat�M)rrJr�c@sfeZdZeedd�dd�Zeedd�dd�Zeedd�dd�Zeedd�d	d
�Zeedd�dd�Z	dS)
�TestFilterwindowsN)r�r��returncCs�tj||d�d}t|�}|dkr*tj}nt�|jtj�}|j|ksHJ�t|t|��|dkrpt|t�g��n0|dkr�t|t�	d��nt
tj|dd�dd�dS)	Nr�r:r�rJrru�@rF)r4r�r!r�r�r�rrrr^r	r��r`r�r�Zscalarr�Z	ref_dtyper:r:r;�test_hanning�szTestFilterwindows.test_hanningcCs�tj||d�d}t|�}|dkr*tj}nt�|jtj�}|j|ksHJ�t|t|��|dkrpt|t�g��n0|dkr�t|t�	d��nt
tj|dd�dd�dS)	Nr�r:r�rJrrug�(\��@rF)r4r�r r�r�r�rrrr^r	r�r�r:r:r;�test_hamming�szTestFilterwindows.test_hammingcCs�tj||d�d}t|�}|dkr*tj}nt�|jtj�}|j|ksHJ�t|t|��|dkrpt|t�g��n0|dkr�t|t�	d��nt
tj|dd�dd�dS)	Nr�r:r�rJrrug�^)��@rF)r4r�rr�r�r�rrrr^r	r�r�r:r:r;�
test_bartlett�szTestFilterwindows.test_bartlettcCs�tj||d�d}t|�}|dkr*tj}nt�|jtj�}|j|ksHJ�t|t|��|dkrpt|t�g��n0|dkr�t|t�	d��nt
tj|dd�dd�dS)	Nr�r:r�rJrrug=
ףp=@rF)r4r�rr�r�r�rrrr^r	r�r�r:r:r;�
test_blackman�szTestFilterwindows.test_blackmancCs�tj||d�d}t|d�}|dkr,tj}nt�|jtj�}|j|ksJJ�t|t|��|dkrrt|t�g��n0|dkr�t|t�	d��nt
tj|dd�dd�dS)	Nr�r:rr�rJrur�r�)r4r�r%r�r�r�rrrr^r	r�r�r:r:r;�test_kaiser�s
zTestFilterwindows.test_kaiser)
rqrrrs�strrnr�r�r�r�r�r:r:r:r;r��s
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�	TestTrapzcCsHt�ddd�}tt�d|d�t�dtj�dd�}t|dd�dS)	N���r�r|r�rH)r�rJrn)r4r5r.r�r�r�r	)r`r�r'r:r:r;r�s*zTestTrapz.test_simplecCs&t�ddd�}t�ddd�}t�ddd�}t�|�|d|d}|dd<|dd<t�|�|d|d}|dd<|dd<t�|�|d|d}|dd<|dd<|dd�ddf|ddd�df|dddd�f}||dd�ddfjdd�}||ddd�dfjdd�}	||dddd�fjdd�}
t||dd�ddfdd	�}t||�t||ddd�dfdd	�}t||	�t||dddd�fdd	�}t||
�t||dd	�}t||�t||dd	�}t||	�t||dd	�}t||
�dS)
NrrJrRrHrlrWrYru)r�rv)r4r�Z	ones_liker�r.r	)r`r�r�r�ZwxZwyZwz�qZqxZqyZqzr'r:r:r;�	test_ndims86




zTestTrapz.test_ndimcCs�t�d�}||}|dk}tjj||d�}d}tt||�|�tjj||d�}tt||�|�tjj||d�}tt||�|�dS)NrSrHr�g*@)r4r5rr�r	r.)r`r�r�r�Zymr'Zxmr:r:r;r�(s
zTestTrapz.test_maskedN)rqrrrsrr�r�r:r:r:r;r��s%r�c@seZdZdd�Zdd�ZdS)�TestSinccCs6ttd�dk�tt�ddd��}t|t|�d�dS)NrrJrYrrn)rr-r4r�r
r�r`r�r:r:r;r;szTestSinc.test_simplecCsFddg}tt�|��}tt|��}tt|��}t||�t||�dS)Nrr�)r-r4r�r�r`r)r`r�r�r�r�r:r:r;�test_array_likeAs
zTestSinc.test_array_likeN)rqrrrsrr�r:r:r:r;r�9sr�c@seZdZdd�ZdS)�
TestUniquecCs�t�gd��}tt�t|�gd�k��ttt�gd���t�dg�k�gd�}tt�t|�gd�k��t�gd��}tt�t|�gd�k��dS)	N)	rFrRrHrJrJrHrRrFr)rrJrHrRrF)rJrJrJrJrJrJ)�widget�hamr2r3r2r�)r3r2r�r�)�@@r���?$@r�r�)r�r�r�r�)r4r�rr�r1r0r:r:r;rLs"zTestUnique.test_simpleN�rqrrrsrr:r:r:r;r�Jsr�c@seZdZdd�Zdd�ZdS)�TestCheckFinitecCsPgd�}ddtjg}ddtjg}tj�|�tttjj|�tttjj|�dS)Nr�rJrH)r4�infr
�lib�asarray_chkfiniterr]r�r:r:r;rXszTestCheckFinite.test_simplecCs0gd�}tjj|dtjd�}t|jtjk�dS)Nr�r�)r�r�)r4r�r�r�rr�rjr:r:r;�test_dtype_order`sz TestCheckFinite.test_dtype_orderN)rqrrrsrr�r:r:r:r;r�Vsr�c	@s�eZdZe�gd�gd�gd�g�Ze�gd�gd�gd�g�Ze�gd�gd�gd	�g�Ze�gd
�gd�gd�gd
�gd�gd�g�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zej�d ejejejejg�d!d"��Zd#S)$�TestCorrCoef)g����^��?g�.{�<�?g���$,�?)g���4��?gp�)��?g�J��G��?)gY�����?g������?g�ވ0v��?)gة����?gB�F�U�?g�G)t��?)g3�TB��?gL�\���?g��A��?)g>
���?gq�F�E`�?g�5��?)r��ޛ����?����r@��)r�r��p��]�4�?)r�r�r�)r�r�r��?�'L�?���(��8�?���4V�}�?)r�r�r����w�{���,H��5�?�jS�,
��?)r�r�r�������)h����?��5#A���?)r�r�r�r���t��o��BC��,�)r�r�r�r�r��@��02v�?)r�r�r�r�r�r�cCs*tt�gd�gd��ddgddgg�dS)Nr�)rJrrJr���)r	r4rr{r:r:r;�test_non_array|s�zTestCorrCoef.test_non_arraycCsdt|j�}t||j�tt�t�|�dk��t|j|j�}t||j	�tt�t�|�dk��dSr>)
rrwr	r�rr4r�r�r�r�)r`Ztgt1Ztgt2r:r:r;r�s
zTestCorrCoef.test_simplecCs�t���}t�d�ttt|jdd�|�t�tt|jdd�|j	�tt|j|j
dd�|j�tt|jdd�|j	�tt|j|j
dd�|j�Wd�n1s�0YdS)NrrY�ZddofrR)rr�simplefilterr�DeprecationWarningrrw�filterr	r�r�r��r`�supr:r:r;�	test_ddof�s

zTestCorrCoef.test_ddofcCs|t��b}t�d�ttt|j|jdd�ttt|jdd�|�t�t	t|jdd�|j
�Wd�n1sn0YdS)NrrJr)Zbias)rrr�rr�rrwr�r�r	r�r�r:r:r;�	test_bias�s

zTestCorrCoef.test_biascCsZt�gd�gd�g�}t|�}t�ddgddgg�}t||�tt�t�|�dk��dS�Nr��ry@r
r�r�r)r4r�rrrr�r�)r`r�r�rer:r:r;�test_complex�s

zTestCorrCoef.test_complexcCsHt�gd�g�}t�gd�g�}tt�||�t�ddgddgg��dSr�)r4r�rr�r`r�r�r:r:r;�test_xy�szTestCorrCoef.test_xycCs�tjdd���t�dt�ttt�g��tj�ttt�g��	dd��t�g��	dd��ttt�g��	dd��t�tjtjgtjtjgg��Wd�n1s�0YdS�NTrrrrH)
rrr��RuntimeWarningrrr4r�r
ror{r:r:r;�
test_empty�s��zTestCorrCoef.test_emptycCs|ddgddgg}tjdd��t|�}Wd�n1s:0Yt|t�ddgddgg��tt�t�|�dk��dS)Ng0��.�++g}Ô%�I�T�raise)r�r�r�)r4Zerrstaterr
r�rr�r�)r`r�r�r:r:r;�test_extreme�s
&zTestCorrCoef.test_extreme�	test_typecCs*|j�|�}t||d�}||jks&J�dS�Nr�)rwr�rr�)r`r�Zcast_Ar�r:r:r;�test_corrcoef_dtype�sz TestCorrCoef.test_corrcoef_dtypeN)rqrrrsr4r�rwr�r�r�r�rr�r�r�r�r�r�r�r�r��half�single�double�
longdoubler�r:r:r:r;r�gsJ��������	
	r�c@s\eZdZe�ddgddgddgg�jZe�ddgddgg�Zejgd�dd�Ze�gd��Z	e�d	gdgdgdgdgd
gg�jZ
e�ddgddgg�Zejd
ej
d�Ze�gd��Ze�ddgddgg�Ze�d
�Ze�gd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zej�d'ej ej!ej"ej#g�d(d)��Z$d*S)+�TestCovrrHrJr�r�)r�r�r�)�ndmin)rJrFrJr�r�皙�����?g������ٿrRr�)r�r�r�gUUUUUU�?gUUUUUU�)g&S��:�?g�o_��?g#�~j��?g���ZӼ�?g�Q�|�?cCstt|j�|j�dSr3)rr�x1r�r{r:r:r;rd�szTestCov.test_basiccCsVt�gd�gd�g�}t�ddgddgg�}tt|�|�tt|t�d�d�|�dS)Nr�r�r�r�rrR��aweights)r4r�rrr^)r`r�r�r:r:r;r��szTestCov.test_complexcCsFt�gd�g�}t�gd�g�}tt||�t�ddgddgg��dSr�)r4r�rrr�r:r:r;r��szTestCov.test_xycCs�tjdd���t�dt�ttt�g��tj�ttt�g��	dd��t�g��	dd��ttt�g��	dd��t�tjtjgtjtjgg��Wd�n1s�0YdSr�)
rrr�r�rrr4r�r
ror{r:r:r;r��s��zTestCov.test_emptycCsntjdd��Nt�dt�tt|jdd�t�tj	tj	gtj	tj	gg��Wd�n1s`0YdS)NTrrrSr�)
rrr�r�rrr�r4r�r�r{r:r:r;�test_wrong_ddof�s��zTestCov.test_wrong_ddofcCsJtt|j�t|jdd��t�gd��}tt|j|�t|j|dd��dS)NF)Zrowvar)g+����?g4��@���?g��&S�?g�o_��?g�J�4�?)rr�x3r4r��r`r�r:r:r;�test_1D_rowvar�szTestCov.test_1D_rowvarcCs$tt|jdd�tj|jdd��dS)NrJr�)rrr�r4�varr{r:r:r;�test_1D_variance�szTestCov.test_1D_variancecCs�tt|j|jd�t|j��tt|j|jd�|j�tt|j|jd�|j�|jd}t	t
t|j|d�tjdtj
d�}t	tt|j|d�tjdtj
d�}t	tt|j|d�dtjdtj
d�}t	tt|j|d�dS)N)�fweightsr��rHrRr�rHrYrR)rrr��frequencies�
x2_repeatsr�r��unit_frequenciesr�rrr4r^r�RuntimeErrorr])r`Znonintr�r:r:r;�
test_fweights�s"���
zTestCov.test_fweightscCs�tt|j|jd�|j�tt|jd|jd�t|j|jd��tt|j|jd�|j�t�d�}t	t
t|j|d�t�d�}t	t
t|j|d�dt�d�}t	tt|j|d�dS)Nr�r�r�rHr�rR)rrr�r�r��unit_weightsr�r4r^rr�r]r�r:r:r;�
test_aweights	s�

zTestCov.test_aweightscCs�tt|j|j|jd�t|j��tt|j|j|jd�|j�tt|j|j|jd�|j	�tt|j|j|j
d�|j�tt|j|jd|j
d�t|j|j
d��tt|j|j|jd�|j	�dS)N)r�r�r�r�)rrr�r�rr�r�r�r�r�r�r�r{r:r:r;�test_unit_fweights_and_aweights	s<������������z'TestCov.test_unit_fweights_and_aweightsr�cCs*|j�|�}t||d�}||jks&J�dSr�)r�r�rr�)r`r�Zcast_x1r�r:r:r;�test_cov_dtype%	szTestCov.test_cov_dtypeN)%rqrrrsr4r�r&r�r�r�r�r�r�r^rr�r�r�rr�rdr�r�r�r�r�r�r�rrr�r�r�r�r�r�r�rr:r:r:r;r��s.$
	r�c@s$eZdZdd�Zdd�Zdd�ZdS)�Test_I0c
Cs�ttd�t�d��t�gd��}t�gd��}tt|�|�tt|�|�t�ddgddgd	d
gddgd
dgg�}tt|�t�ddgddgddgddgddgg��t�dg�}t|jd�tt�dg�t�dg��dS)Nr�g�ǒ#�?)gC��7��?g�m�M�?g��3a�,�?g�$WV?ۏ?rB)g�ֿN^�?gE��?g閡�1�?g�%�m?�?gD��n��@g>@���v�?g�u�ͥ��?gV�X�˳�?g�ua�&�?gB-�sJ�?g-^���?g�_��V�?g
�X��.�?gV��aX��?g�j���?gp����?g~-��@�?g��D/b�?gݦ�����?g,�Y1ؔ�?g�[!���?g�Q�L��?gW�sU+�?g���@��?g�fx�w�?r�r�r�)r	r"r4r�rr?r)r`rwr�r�Zi0_0r:r:r;r.	s4�
�
��zTest_I0.test_simplecsVt�d��G�fdd�d�}tt�|��|�s2J�t���}t�|��}t||�dS)NrFcseZdZ�jZdd�ZdS)z*Test_I0.test_non_array.<locals>.array_likecSs|Sr3r:)r`r�r:r:r;�__array_wrap__P	sz9Test_I0.test_non_array.<locals>.array_like.__array_wrap__N)rqrrrsZ__array_interface__rr:r
r:r;�
array_likeM	sr)r4r5r-r�r"r)r`rr�r�r:r
r;r�J	s

zTest_I0.test_non_arraycCsHt�ddg�}tjtdd��t|�}Wd�n1s:0YdS)Nry�?@z#i0 not supported for complex valuesr<)r4r�r�r*rr")r`rar�r:r:r;r�Z	szTest_I0.test_complexN)rqrrrsrr�r�r:r:r:r;r,	src@seZdZdd�Zdd�ZdS)�
TestKaisercCs|tt�tdd���ttdd�t�g��ttdd�t�ddg��ttdd�t�gd���ttdd�t�gd	���dS)
NrJr�rrH� ��oF�?rS)r�vT�=�?r�r	rgg���?)�����?��Y�J�?r�rr
)rr4Zisfiniter%r	r�r{r:r:r;rb	s
�
�
�
�zTestKaiser.test_simplecCstdd�dS)NrRrF)r%r{r:r:r;�
test_int_betao	szTestKaiser.test_int_betaN)rqrrrsrrr:r:r:r;r`	s
rc@seZdZdd�ZdS)�	TestMsortcCsFt�gd�gd�gd�g�}tt|�t�gd�gd�gd�g��dS)N)��\��?�b��CQ�?�ה�s��?)�w�����?��kl��?�*dta��?)���ӯ��?�6H����?�ܘC��?)rrr)rrr)rrr)r4r�r	r')r`rwr:r:r;ru	s
�
��zTestMsort.test_simpleNr�r:r:r:r;r
s	sr
c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TestMeshgridc	Csjtgd�gd��\}}t|t�gd�gd�gd�gd�g��t|t�gd�gd�gd�gd�g��dS)Nr��rFrSrmrnr�)rSrSrS)rmrmrm)rnrnrn�r&rr4r��r`�X�Yr:r:r;r�	s��zTestMeshgrid.test_simplecCs&tgd��\}t|t�gd���dS)NrNr)r`rr:r:r;�test_single_input�	szTestMeshgrid.test_single_inputcCs*g}tgt|��tgt|ddi��dS)Nr�F)rr&rrr:r:r;�
test_no_input�	szTestMeshgrid.test_no_inputcCs�gd�}gd�}t||dd�\}}t|t�gd�gd�gd�g��t|t�gd�gd�gd�g��dd	g}tt||�d
jdk�tt||dd�d
jdk�tt|||�d
jd
k�tt|||dd�d
jdk�ttt||dd�dS)Nr�r�ij�Zindexingr�)rHrHrHrH)rRrRrRrRrlr�rr�rRrF)rFrRrH)rRrFrHZnotvalid)r&rr4r�rr?rr])r`r�r�rrr�r:r:r;�
test_indexing�	s"��zTestMeshgrid.test_indexingcCsTtgd�gd�dd�\}}t|t�gd�g��t|t�dgdgdgdgg��dS)	Nr�rT��sparserFrSrmrnrrr:r:r;�test_sparse�	szTestMeshgrid.test_sparsecCstttgd�gd�dd�dS)Nr�rr)r�)rrr&r{r:r:r;�test_invalid_arguments�	s�z#TestMeshgrid.test_invalid_argumentscCs�tjddtjd�}tjddtjd�}t�||�\}}t|j|jk�t|j|jk�tj||dd�\}}t|j|jk�t|j|jk�tj||dd�\}}t|j|jk�t|j|jk�dS)Nrr�r�r7T)r�r#)r4r5r�r�r&rr�)r`r�r�rrr:r:r;r��	szTestMeshgrid.test_return_typecCsrt�ddg�}t�ddg�}tj||ddd�\}}d|ddd�f<t|ddd�fd�t|d	dd�f|�dS)
Nryrzgffffff
@g������@FT)r$r�rrJ)r4r�r&r)r`rrr�r�r:r:r;�test_writeback�	szTestMeshgrid.test_writebackcCshtjdd�tdd�D��\}}}}}d}t|j|�t|j|�t|j|�t|j|�t|j|�dS)Ncss|]}dg|VqdS)rNr:�r�r�r:r:r;r��	r�z-TestMeshgrid.test_nd_shape.<locals>.<genexpr>rJrm)rHrJrRrFrS)r4r&r_rr?)r`rar~r�rrTZexpected_shaper:r:r;�
test_nd_shape�	s$zTestMeshgrid.test_nd_shapecCspt�dgddggd��\}}}t|gd�ggd�gg�t|gd�ggd�gg�t|gd�ggd�gg�dS)NrrJrHrQr�r�rG�r4r&rr�r:r:r;�test_nd_values�	szTestMeshgrid.test_nd_valuescCsntjdgddggd�dd�\}}}t|gd�gd�gg�t|gd�gd	�gg�t|gd�gd�gg�dS)
NrrJrHrQrr r�r�rGr*r�r:r:r;�test_nd_indexing�	s"zTestMeshgrid.test_nd_indexingN)rqrrrsrrrr"r%r&r�r'r)r+r,r:r:r:r;r�	s
	rc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
TestPiecewisecCs4tddgddgdg�}t|ddg�tddgddggdg�}t|ddg�tddgt�ddg�dg�}t|ddg�tddgt�ddg�dg�}t|ddg�tddgt�ddg�gdg�}t|ddg�tddgddggdd�g�}t|ddg�ttdtddgddggg�ttdtddgddgggd	��dS)
NrTFrJcSsdSrdr:r�r:r:r;r
r�z+TestPiecewise.test_simple.<locals>.<lambda>rYz1 or 2 functions are expectedr�)r(rr4r�rr]r0r:r:r;r�	s$��zTestPiecewise.test_simplecCs2tddgddgddggddg�}t|ddg�dS)NrJrHTFrRrF�r(rr0r:r:r;�test_two_conditions
s z!TestPiecewise.test_two_conditionscCs"tdgd�gd��}t|d�dS)NrR)TFF)rFrHrrF)r(rr0r:r:r;�$test_scalar_domains_three_conditions
sz2TestPiecewise.test_scalar_domains_three_conditionscCsNtddgddgdg�}t|ddg�tddgddgddg�}t|ddg�dS)NrJrHTFrrRr.r0r:r:r;�test_default
szTestPiecewise.test_defaultcCs�t�d�}t||dkddg�}t|jdk�t|dk�d}t|ddgddg�}t|jdk�t|dk�t|gd�gd	��}t|d�dS)
NrRrFrrSTFrJr�r�)r4r�r(rr�rr�r:r:r;r+
s
zTestPiecewise.test_0dcCs�d}t||dk|dkgddg�}t|d�d}t||dk|dk|dk|dkggd��}t|d�ttdt||dk|dkgdg�ttdt||dk|dkggd	��dS)
NrRrFrrSr�rHz2 or 3 functions are expectedrJr�)r(rrrr]r�r:r:r;�test_0d_comparison-
s
*
��z TestPiecewise.test_0d_comparisoncCs8t�d�}t�|dk�}t||gddg�}t|d�dS)NrRrJrH)r4r�r(r)r`r�r�r�r:r:r;�test_0d_0d_condition<
s
z"TestPiecewise.test_0d_0d_conditioncCsRt�gd�gd�g�}t||dk|dkggd��}t|t�gd�gd�g��dS)N)g�g��r�)r�r�r�rrHr)r�r�r�)r�r�r�)r4r�r(rr�r:r:r;�test_multidimensional_extrafuncB
s
��z-TestPiecewise.test_multidimensional_extrafunccCs^Gdd�dtj�}t�d��|�}t||dk|dkggd��}tt|�|�t|gd��dS)Nc@seZdZdS)z/TestPiecewise.test_subclasses.<locals>.subclassNr�r:r:r:r;r�J
sr�r�r�rF)r�r�r�)r�r�r�r�r�)r4r�r5r�r(rr�)r`r�r�r'r:r:r;r�I
s
zTestPiecewise.test_subclassesN)rqrrrsrr/r0r1r+r2r3r4r�r:r:r:r;r-�	s	r-c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Ze
jjedd�dd��Ze
j�dddggdg�dd��ZdS)�TestBincountcCs$t�t�d��}t|t�d��dS)NrF)r4�bincountr5rr^r�r:r:r;rT
szTestBincount.test_simplecCs,t�t�gd���}t|t�gd���dS)N)rJrSrHrFrJ)rrHrJrrJrJ)r4r6r�rr�r:r:r;�test_simple2X
szTestBincount.test_simple2cCs2t�d�}t�gd��}t�||�}t||�dS)NrF)皙�����?�333333�?r�r|)r4r5r�r6r�r`r�r�r�r:r:r;�test_simple_weight\
s
zTestBincount.test_simple_weightcCs@t�gd��}t�gd��}t�||�}t|t�gd���dS)N�rJrHrFrSrH�r8r9r�r|r8)rr8r�rr�r|�r4r�r6rr:r:r:r;�test_simple_weight2b
sz TestBincount.test_simple_weight2cCsVt�gd��}tj|dd�}t|t�gd���g}tj|dd�}t|t�g��dS)N)rrJrrJrJrR�Z	minlength)rHrRrrr>r�r:r:r;�test_with_minlengthh
sz TestBincount.test_with_minlengthcCsVt�gd��}tj|dd�}t|t�gd���tj|dd�}t|t�gd���dS)N)rrJrJrHrHrRrRrHr@)rJrHrHrHrr>r�r:r:r;�)test_with_minlength_smaller_than_maxvaluep
s
z6TestBincount.test_with_minlength_smaller_than_maxvaluecCsBt�gd��}t�gd��}t�||d�}t|t�gd���dS)Nr<r=rl)rr8r�rr�r|rrr>r:r:r:r;�test_with_minlength_and_weightsw
sz,TestBincount.test_with_minlength_and_weightscCs&tjgtd�}t�|�}t||�dSr�)r4r�rnr6rr�r:r:r;r�}
s
zTestBincount.test_emptycCs4tjgtd�}tj|dd�}t|tjdtd��dS)Nr�rSr@)r4r�rnr6rr=r�r:r:r;�test_empty_with_minlength�
sz&TestBincount.test_empty_with_minlengthcsltjgtd��ttd�fdd��ttd�fdd��t�d��ttd�fdd��ttd�fd	d��dS)
Nr�z"'str' object cannot be interpretedcstj�dd�S�N�foobarr@�r4r6r:r�r:r;r�
r�z<TestBincount.test_with_incorrect_minlength.<locals>.<lambda>zmust not be negativecstj�dd�S�NrYr@rGr:r�r:r;r�
r�rScstj�dd�SrErGr:r�r:r;r�
r�cstj�dd�SrHrGr:r�r:r;r�
r�)r4r�rnrrr]r5r{r:r�r;�test_with_incorrect_minlength�
s$
�
�

�
�z*TestBincount.test_with_incorrect_minlengthrxrycCs�t�t�tj��}t�t�tj��}td�D]}t�gd��q,tt�t�tj��|�tt�t�tj��|�td�D]}t�gd�gd��qxtt�t�tj��|�tt�t�tj��|�dS)Nr�r�r�)	r}r~r4r�Zintpr�r_r6r)r`Z
intp_refcountZdouble_refcount�jr:r:r;�test_dtype_reference_leaks�
sz'TestBincount.test_dtype_reference_leaks�valsrHcCsrt�|�}tt��t�|�Wd�n1s20Ytt��t�|�Wd�n1sd0YdSr3)r4�asarrayrr]r6)r`rLZvals_arrr:r:r;�test_error_not_1d�
s


(
zTestBincount.test_error_not_1dN)rqrrrsrr7r;r?rArBrCr�rDrIr�r�r�rrKr�rNr:r:r:r;r5R
s
r5c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	dd�d
d�dd�dd�ggd�d�dd��Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&S)'�
TestInterpcCsttttdgg�tttddgddg�tttdddgddgdd�tttdggdd�tttddgddgdd�dS)NrrJrHr��h)rr]r$r{r:r:r;�test_exceptions�
s
zTestInterp.test_exceptionscCsBt�ddd�}t�ddd�}t�ddd�}tt�|||�|�dS)NrrJrSre)r4r�r	r$�r`r�r��x0r:r:r;rd�
szTestInterp.test_basicc
Cs�tdd�D�]�}tj|tjd�}tj|tjd�}tjdd|d|gtjd�}|ddd�}t|||�}t|||�}tjgd�td�}|ddd�}	t||�t||	�t|||dd�}t|||dd�}tjgd�td�}|ddd�}	t||�t||	�t|||d	d
�}t|||d	d
�}tjgd�td�}|ddd�}	t||�t||	�t|||dd	d�}t|||dd	d�}tjgd
�td�}|ddd�}	t||�t||	�q
dS)NrJr�r�rYrr���left)rrJrJrJrH��right)rJrJrJrH)rUrW)rrJrJrH)	r_r4r5r�r^r�r$r9r)
r`�size�xpZypZincptsZdecptsZincresZdecresZinctgtZdectgtr:r:r;�test_right_left_behavior�
s:






z#TestInterp.test_right_left_behaviorcCs�t�ddd�}t�ddd�}d}tt�|||�|�d}tt�|||�|�t�d�}tt�|||�|�t�d�}tt�|||�|�tj}tt�|||�|�dS)NrrJrSr9)r4r�r	r$r�r�r
rRr:r:r;�test_scalar_interpolation_point�
s

z*TestInterp.test_scalar_interpolation_pointcCstgd�}gd�}ddtjdg}tt�|||�ddtjtjdg�ddtjdg}tt�|||�ddtjtjdg�dS)N�rJrHr�rRrFrNrJrHrF)r4r�r	r$r
)r`r�rY�fpr:r:r;� test_non_finite_behavior_exact_x�
s"z+TestInterp.test_non_finite_behavior_exact_xcCs
t�|�Sr3)r4Zfloat_r�r:r:r;r�
r�zTestInterp.<lambda>cCs
t|d�Sr�rDr�r:r:r;r�
r�cCs
td|�Srr_r�r:r:r;rr�cCst|t�|d��S)NrP)rDr4Zmultiplyr�r:r:r;rr�)rAzcomplex-realzcomplex-imagzcomplex-both)�paramsZidscCs|jS)z( scale function used by the below tests )Zparam)r`Zrequestr:r:r;�sc�
s
z
TestInterp.sccCs�tt�dtjdg|ddg��|tj��tt�ddtjg|ddg��|tj��tt�dddg|tjdg��|tj��tt�dddg|dtjg��|tj��dS)z test that nans are propagated r�rJrr�N)rr4r$r
�r`rar:r:r;�test_non_finite_any_nans(((z"TestInterp.test_non_finite_any_nancCs�tt�dtjtj
g|ddg��|tj��tt�dddg|tjtj
g��|tj��tt�dddg|tj
tjg��|tj��tt�dtjtj
g|ddg��|d��dS)z2 Test that interp between opposite infs gives nan r�rr�rJN�rr4r$r�r
rbr:r:r;�test_non_finite_infs...zTestInterp.test_non_finite_infcCsttt�dtjdg|tjdg��|tj��tt�dtjdg|tj
dg��|tj��tt�dtjdg|dtjg��|tj��tt�dtjdg|dtj
g��|tj��tt�ddtj
g|tjdg��|tj��tt�ddtj
g|tj
dg��|tj��tt�ddtj
g|dtjg��|tj��tt�ddtj
g|dtj
g��|tj��dS)z@ Test that interp where both axes have a bound at inf gives nan r�rJr�rNrdrbr:r:r;�test_non_finite_half_inf_xfs.......z&TestInterp.test_non_finite_half_inf_xfcCs�tt�dtjtjg|ddg��|d��tt�dtjdg|ddg��|d��tt�ddtj
g|ddg��|d��tt�dtj
tj
g|ddg��|d��dS)z1 Test interp where the x axis has a bound at inf r�rr�rJN�rr4r$r�rbr:r:r;�test_non_finite_half_inf_x's,((z%TestInterp.test_non_finite_half_inf_xcCstt�dddg|dtjg��|tj��tt�dddg|dtj
g��|tj
��tt�dddg|tjdg��|tj��tt�dddg|tj
dg��|tj
��tt�dddg|tjtjg��|tj��tt�dddg|tj
tj
g��|tj
��dS)z1 Test interp where the f axis has a bound at inf r�rrJr�Nrgrbr:r:r;�test_non_finite_half_inf_f.s,,,,0z%TestInterp.test_non_finite_half_inf_fc	Cst�ddd�}t�ddd�dt�ddd�d}d}|d|d}tt�|||�|�d}d}ttj||||d�|�d	}d}ttj||||d
�|�gd�}gd�}dd
tjdg}dd
tjdtjdg}tt�|||�|�gd�}gd�}gd�}gd�}ttj|||dd�|�dS)NrrJrSrr9rY�@@rTr�rVr\rN�@�?rFy�?�iL���iV���iG����r�rArim��iB���i^i����)�@�?y$@@�@@y@@)y@�?rpy�!@�?y@�?rqy
@
@y@@y@@rPr�)r4r�r	r$r�)	r`r�r�rSZy0rUrWrYr]r:r:r;�test_complex_interp7s*$zTestInterp.test_complex_interpcCs�t�ddd�}t�ddd�}t�d�}tt�|||�|�t�gd��}t�gd��}t�t�d�||�}t|d�tt|tj��tjt�d�||dd	�}t|d
�tt|tj��dS)NrrJrSr9r�)rJrYrJr�rFr�r�)	r4r�r�r	r$rrr-r�)r`r�r�rSrYr]r�r:r:r;�)test_zero_dimensional_interpolation_pointSs


z4TestInterp.test_zero_dimensional_interpolation_pointcCs2t�ddd�}t�|�}tt�tj||�d�dS)Nrr�g-C��6?r�)r4r5Zsinr	r$r�)r`rYr]r:r:r;�test_if_len_x_is_smallds
z!TestInterp.test_if_len_x_is_smallcCs�gd�}gd�}gd�}gd�}ttj|||dd�|�tj|dd��d	d
�}tj|dd��d	d
�}ttj|||dd�|�dS)Nrlrn)rSr�rRrF)g@r���!@g@r�g
@�@g@rPr�r�r�rHrYr�)r	r4r$r�ro)r`r�rYr]r�r:r:r;r�iszTestInterp.test_periodN)rqrrrsrQrdrZr[r^r�Zfixturerarcrerfrhrirrrsrtr�r:r:r:r;rO�
s.&��
		rOc@s�eZdZdd�Zdd�Zdd�Zdd�Zej�	d	e
jd
�dd��Zd
d�e
jdD�e
j
e
jfe
je
jfe
je
jfe
je
jfe
je
jfe
je
jfe
je
jfe
�d�e
jfgZej�	ddge�ej�	ddggd��dd���Ze
jde
jd
dZej�	d	e�dd��Zej�	d	e�dd��Zej�	d	e�dd��Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(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�TestPercentilecCs~t�d�d}tt�|d�d�tt�|d�d�tt�|d�d�tj|d	<tt�|d�tj�ttj|dd
d�tj�dS)Nrlr�rr�rrvrer�rJ�nearest��method)r4r5r�
percentiler
r0r:r:r;rdvs
zTestPercentile.test_basiccCs�dd�td�D�}t�|td��}t|td��tt|�t�t�|td��}t|tdd��tt|�t�t�|td��}t|tdd	��tt|�t�t�|td�g�}t|t�tdd	�g��tt|�tj�dS)
NcSsg|]}t|d��qS�rHrr(r:r:r;r��r�z0TestPercentile.test_fraction.<locals>.<listcomp>rlrrrnrHrerF)r_r4r{rrr�r�r�)r`r�r:r:r:r;�
test_fractionszTestPercentile.test_fractioncCsRt�d�}t�|dddd�t�|ddddd�t�d�}t�|dd|dd�dS)NrSF�linearr�)r4r^r{)r`r�or:r:r;�test_api�s


zTestPercentile.test_apicCsFt�gd�gd�gd�gd�gd�g�}ttj|ddd�gd��dS)Nr�)rFrFrRrerru)r4r�rr{r0r:r:r;�test_2D�s
�zTestPercentile.test_2Dr�ZAllFloatcCsPtjdtjdddg|d�}tj|ddd�}tj�|tj�tj�|j|j�dS)NrJ��A@�D@�I@r�r~ry)r4rMZNANr{�testingrr�)r`r�r�r�r:r:r;�test_linear_nan_1D�s�z!TestPercentile.test_linear_nan_1DcCsg|]}|tjf�qSr:)r4r�)r�Zint_typer:r:r;r��s�zTestPercentile.<listcomp>r�r��input_dtype�expected_dtyperzr�)	)�inverted_cdfr7)�averaged_inverted_cdf��;@)�closest_observationr7)�interpolated_inverted_cdfr7)�hazenr�)�weibull�)r~r�)�median_unbiasedrW)�normal_unbiasedg ;@cCs�tjgd�|d�}tj|d|d�}tj�||d�|dvrz|dkr\tj�t�|�jtj�q�tj�t�|�jt�|��ntj�t�|�jt�|��dS)N)rJg4@r�r�r�r�r�ryrU)r�r�r�)r4rMr{r�r	rr�r�)r`rzr�r�r�r�r�r:r:r;�test_linear_interpolation�s��z(TestPercentile.test_linear_interpolationcCsDttjtjd|d�ddd�d�ttjtjd|d�ddd�d�dS)	Nr�r�re�lowerryrF�higherrS�rr4r{r5�r`r�r:r:r;�test_lower_higher�s����z TestPercentile.test_lower_highercCs�ttjtjd|d�ddd�d�ttjtjd|d�dd	dd�d
�ttjtjd|d�ddd�d�ttjtjd|d�d	dd�d
�dS)
Nr�r��3�midpointryr�r�rJrerSr��@r�r�r:r:r;�
test_midpoint�s(��������zTestPercentile.test_midpointcCsDttjtjd|d�ddd�d�ttjtjd|d�ddd�d�dS)	Nr�r�r�rxryrS�1rFr�r�r:r:r;�test_nearest�s����zTestPercentile.test_nearestcCsLtj�d�}t�|d�}tj�||���t�|d�}tj�||���dS)NrSrr)r4r�rr{r�rr�r�)r`r�r�r:r:r;�'test_linear_interpolation_extrapolation�s
z6TestPercentile.test_linear_interpolation_extrapolationcCs,t�d�d}tt�|gd��gd��dS)Nrlr�)rrre)rrvr�)r4r5rr{r0r:r:r;�
test_sequence�szTestPercentile.test_sequencecCs�t�d��dd�}tt�|d�gd��gd�gd�gd�g}ttj|dd	d
�|�gd�gd�gd
�g}ttj|ddd
�t�|�j�t�d��dddd�}tt�|d�jd�tt�|d�jd�ttj|dd	d
�jd�ttj|ddd
�jd�ttj|ddd
�jd�ttj|ddd
�jd�ttj|ddd
�jd�ttj|ddd�jd�ttj|ddd�jd�ttj|dd	dd�jd�ttj|dddd�jd�ttj|dddd�jd�ttj|dddd�jd�ttj|dddd�jd�dS)NrrRrF)r�rer)g@r�r�)rHrRrFrSr)rlr�r�r�rru)��?r�rR)�@r�rn)rur�r�rJrPrSrm�r�rer|)r�rer��rR)rHrFrSrm)rHrRrSrmrH)rHrRrFrm)rRrRrSrmr�ry�rvrz)r4r5rorr{r�r&r?)r`r��r0r r:r:r;r��sf�
��
������������zTestPercentile.test_axiscCs�t�d��dd�}tt�|d�d�tt�t�|d���t�gd��}ttj|ddd�|�ttj|ddd�j|j�t�gd	��}t	tj|dd
d�|�ttj|dd
d�j|j�t�
d
�}ttj|d|d�d�t|d�t�
d�}ttj|dd|d�|�t||�t�
d�}ttj|dd
|d�|�t||�t�d��dd�}ttj|dd
d�d�tt�t�|d���t�gd��}tj|dd
dd�}t||�t|j|j�t�gd��}tj|dd
d
d�}t	||�t|j|j�tj
d|jd�}tj|dd
|d�}t|d�t|d�tj
d|jd�}tj|dd
d|d�}t||�t||�tj
d|jd�}tj|dd
d
|d�}t||�t||�dS)NrrRrFrer��r�r�r�rKrru�r�r�r�rJ�r}�rvr}r�ryr�)rzrv)r�r�rDr:r��rzr}rS�rzrvr})r4r5rorr{r�isscalarr�r?r	�emptyr�)r`r�r�r r}Zc0Zc1r�r:r:r;�
test_scalar_q#sR












zTestPercentile.test_scalar_qcCs�tttjddgddd�tttjdgd�tttjdgd�tttjdgttd��dg�tttjdgttd��d	g�dS)
NrJrH�8rFry�erYrer{)rr]r4r{r�r_r{r:r:r;�test_exceptionSs� zTestPercentile.test_exceptioncCstt�gd�d�d�dS)Nr�rrJ)rr4r{r{r:r:r;�test_percentile_list[sz#TestPercentile.test_percentile_listcCs�t�gd��}t�d�}d}tj|||d�tt�||�|�t�gd�gd�g�}t�d�}tj||d|d�ttj||dd�|�t�d	�}tj||d
|d�ttj||d
d�|�t�d��dd
�}t�gd�gd�g�}t�d�}ttj|dd|d�|�t||�t�gd�gd�g�}t�d�}ttj|dd
|d�|�t||�t�gd�gd�g�}tjd|jd�}tj|ddd|d�}t||�t||�t�gd�gd�g�}tjd|jd�}tj|ddd
|d�}t||�t||�dS)Nr�r�r�r�r�rr�ru�rRrHrJrrRrF)r�r�r�r�r�)rHrFr�)r�r�rur�r��rrJrHrRrr�r�r�)rrFrl)rJrSr�)	r4r�r=r{rr5ror�r�)r`r�r�r:r�r}r r�r:r:r;�test_percentile_out^sB

�








z"TestPercentile.test_percentile_outcCs�t�d��dddd�}ttj|ddd�jd�ttj|ddd�jd	�ttj|ddd�jd
�ttj|ddd�jd�ttj|dd
d�jd�ttj|ddd�jd
�ttj|ddd�jd	�ttj|ddd�jd�ttj|dddd�jd
�ttj|dddd�jd
�tt�tj|ddgdd��jd�tt�tj|ddgdd��jd�tt�tj|ddgdd��jd�tt�tj|ddgdd��jd�dS)NrYr�rJrHrerru)rJrHrJ)r�rHrJ)r�rJrJrR)r�rJrHrYrPrVr$r�r�r�)rHrJrHrJ)rHr�rHrJ)rHr�rJrJ)rHr�rJrH)r4r5rorr{r?r��r`rr:r:r;�test_percentile_empty_dim�s>��������z(TestPercentile.test_percentile_empty_dimcCsht�gd��}tj|dgdd�t|t�gd���t�gd��}t�|dg�t|t�gd���dS)N�rHrRrFrJreF��overwrite_input�r4r�r{rrjr:r:r;�test_percentile_no_overwrite�sz+TestPercentile.test_percentile_no_overwritecCs�tjdddd�}tjt�d�|dd�t|tjdddd��tjdddd���}tjt�d�|dd�t|tjdddd����dS)Nr��Y@rS)Znumr�ry)r4r�r{r5rr)r`r:r:r:r;�test_no_p_overwrite�sz"TestPercentile.test_no_p_overwritecCs^t�gd��}tj|dgdd�}t|t�dg��tjgd�dgdd�}t|t�dg��dS)Nr�reTr�r�r�r}r:r:r;�test_percentile_overwrite�s
z(TestPercentile.test_percentile_overwritec
Cs�tjjdd�}t�|gd�}ttj|ddd�t�|d��t�|dd�}ttj|dd	d�t�|d��|�dd
���}ttj|ddd�t�|d��|�dd
���}ttj|dd
gdd�tj|dd
gdd��ttj|dd
gdd�tj|dd
gdd��t�	d��
d�}tj�|���ttj|ddd�dt�|dd�dd�dd�df�
�d��ttj|ddgdd�dd�d
ft�|dd�dd�d
dd�f�
�ddg��ttj|ddd�dt�|dd�dd�ddd�f�
�d��ttj|ddd�dt�|ddd�dd�dd�f�
�d��ttj|ddd�dt�|dd
dd�dd�f�
�d��ttj|ddd�dt�|ddd�dd�d
f�
�d��ttj|ddd�dt�|ddd�ddd�f�
�d��dS)N��G��rXr�rQrZrurYrrirJrgr�r�rI�r��rRrSrnr��Z�rrJrR�rRrJr$rH�rRrJrHr��rHrJ�rJrP�rJrRrM)r4r��normal�dstackrr{�moveaxisr�r�r5ro�shuffle�ravel�flatten�r`rr�rr:r:r;�test_extended_axis�sJ��&� *�&�&�"�"�"�z!TestPercentile.test_extended_axiscCs�t�d�}ttjtj|ddd�ttjtj|ddd�ttjtj|ddd�ttjtj|ddd�tttj|ddd�tttj|d	dd�tttj|d
dd�dS)Nr�rAr�)rvr��rrArF�rrFrO)rYrY)rRrY)r4r^rryr{r]r�r:r:r;�test_extended_axis_invalid�s
z)TestPercentile.test_extended_axis_invalidcCs�t�d�}ttj|dddd�jd�ttj|dddd�jd�ttj|dddd�jd	�ttj|dd
dd�jd�ttj|dddd
�jd�ttj|dddd�jd�ttj|ddgddd�jd�ttj|ddgddd�jd�dS)Nr�rnTr�r�rZ�rJrJrnr�rx�rJrSrnrJr��rRrJrnr�r�)r�r��rJrJrnrJrJ)rHrJrJrnrJ)rHrJrSrnrJ)r4r^rr{r?r�r:r:r;�
test_keepdims�s:
����������zTestPercentile.test_keepdimscCs�t�d�}t�d�}ttj|dd|d�|�ttj|ddd|d�|�t�d�}ttj|dd|d�|�ttj|ddd|d�|�t�d	�}ttj|d
|d�|�ttj|d
d|d�|�dS)N�rFr!rr�rxr�r�rJr:rH)r4r=r^rr{�r`rrr:r:r;�test_out�s



zTestPercentile.test_outc	Cstjdd���t�ddt�t�d�}t�d�}tj|d<ttj	|dd|d	�|�ttj	|ddd
|d�|�t�d�}ttj	|d
d
|d	�|�ttj	|d
d
d
|d�|�t�d�}ttj	|d
|d	�|�ttj	|d
d
|d�|�Wd�n1s�0YdS)NTrrrr�r!r�rr�rxr�r�rJr:)
rrr r�r4r=r^r
rr{r�r:r:r;�test_out_nan
s&


�
�
�zTestPercentile.test_out_nancCs:tjdtd�}tj|d<tt�|d�tj�ttj|ddd�tj�ttj|ddgdd�t�tjgd��tjdtd��ddd	�}tj|d
<tj|d<tt�|d�tj�tt�|d�jd�t�tjdtd��ddd	�dd�}tj|d<tj|d
<tt�|dd�|�t�tjdtd��ddd	�ddgd�}tj|dd�ddf<tj|dd�ddf<tt�|ddgd�|�t�tjdtd��ddd	�dd�}tj|d<tj|d
<tt�|dd�|�t�tjdtd��ddd	�ddgd�}tj|dd�ddf<tj|dd�ddf<tt�|ddgd�|�t�tjdtd��ddd	�dd�}tj|d<tj|d<tt�|dd�|�t�tjdtd��ddd	�ddgd�}tj|dd�df<tj|dd�df<tt�|ddgd�|�tjtjdtd��ddd	�ddgddd�}tj|dd�df<tj|dd�df<ttj|ddgddd�|�dS)Nr#r�rHr9rrug333333�?rRrFr��rJrJrHr�rhrJr�rNrxry)	r4r5r9r
rr{r�ror�r}r:r:r;�test_nan_behavior
sl
�

"

�"

��

�
���z TestPercentile.test_nan_behaviorcCs�tjtdd��"t�gd�tj�Wd�n1s60Ytjtdd��$t�gd�tjg�Wd�n1sx0Yt�ddd�}tj|d<tjtdd�� t�gd�|�Wd�n1s�0YdS)NzPercentiles must be inr<)rJrHrRr�r�g�X@rTr)r�r*r]r4r{r
r�)r`r�r:r:r;�
test_nan_qW
s02
zTestPercentile.test_nan_qN)-rqrrrsrdr}r�r�r�r�r�r4�	typecodesr�r�r�r�r�r^r_Zclongdoubler�ZH_F_TYPE_CODESr�Z
TYPE_CODESr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r:r:r:r;rwtsb	

�






���



	$0)	 
=rwc
@s�eZdZdd�Zdd�Zejjdd�dd��Zd	d
�Z	dd�Z
ej�d
ej
d�dd��Zej�dgd��dd��Zejeejejddd�ejddddd�d�d�dd��Zd d!�Zd"S)#�TestQuantilecCs*gd�}t�|d�}tjj|ddd�dS)N)r�r8r�g�������?g
ףp=
�?rJ)Zmaxulp)r4�quantiler�Zassert_array_max_ulp)r`r�rar:r:r;�test_max_ulpf
szTestQuantile.test_max_ulpcCsHt�d�d}tt�|d�d�tt�|d�d�tt�|d�d�dS)Nrlr�rr�rJrvr�)r4r5rr�r0r:r:r;rdn
szTestQuantile.test_basiczSee gh-19154rycCslt�dg�}t�dd�}t||d�tt|�|j�t�gd��}t�||�}t||�t|j|j�dS)NTFr)FTT)r4r�r�rr�r�r)r`raZtf_quantZ	quant_resr:r:r;�test_correct_quantile_valuet
s
z(TestQuantile.test_correct_quantile_valuecCs8dd�td�D�}t�|d�}t|d�tt|�t�t�|d�}t|tdd��tt|�t�t�|tdd��}t|tdd��tt|�t�t�|tdd�g�}t|t�tdd�g��tt|�tj�t�|tdd�gg�}t|t�tdd�gg��tt|�tj�t�d�}tt�|tdd��tdd��dS)	NcSsg|]}t|d��qSr|rr(r:r:r;r��
r�z.TestQuantile.test_fraction.<locals>.<listcomp>rlrrJrnrHrF)	r_r4r�rr�rr�r�r5)r`r�r�r:r:r;r}
s$

zTestQuantile.test_fractioncCsjt�gd��}|��}tjt�d�|dd�t||�|��}|��}tjt�d�|dd�t||�dS)N)rr�r�r�r�r�r�ry)r4r�r�r�r5rr)r`�p0r:r:r:r;r��
s
z TestQuantile.test_no_p_overwriter�r�cCs2tjtjddg|d�dgdd�}|j|ks.J�dS)NrJrHr�r�rxry)r4r�r�r�)r`r�r�r:r:r;�test_quantile_preserve_int_type�
s�z,TestQuantile.test_quantile_preserve_int_typerz)
r�r�r�r�r�r�r~r�r�rxr�r�r�cCsdt�ddd�}tjt�gd��d||d�}tt�|�|�tjgd�||d�}tt�|�|�dS)NrrJr�)rrJrJrHrHrRrRrFrSrSrJrJr�r�r�rlrlrnr|ry)r�r�r�r�)r4r�r�r�rr�)r`rzr�r�r:r:r;�test_quantile_monotonic�
s	��z$TestQuantile.test_quantile_monotonicrRr�)�	min_value�	max_valueF�u�<�7��u�<�7~)�allow_infinity�	allow_nanr�r�)r�r?�elements)r�cCs.t�ddd�}t�||�}tt�|�|�dS)NrrJg{�G�z�?)r4r5r�rr�)r`r�r�r�r:r:r;�test_quantile_monotonic_hypo�
sz)TestQuantile.test_quantile_monotonic_hypocCsVt�gd�gd�g�}tj|dd<t�|d�}t�|�s>J�tt�|d�tj�dS)N)rBrKr�)r�r�r�rrJr�)r4r�r
r�r�r)r`rar�r:r:r;�test_quantile_scalar_nan�
s
z%TestQuantile.test_quantile_scalar_nanN)rqrrrsr�rdr�r�r�r�r}r�r�r4r�r�r��
hypothesis�givenrr��stZintegers�floatsr�r�r:r:r:r;r�c
s,


�

���
r�c
@s�eZdZejejddddd�ejddddd�ejddddd�ejddddd�d�dd	��Zejejddddd�ejddddd�ejddddd�d
�dd��Zejejddddd�ejddddd�ejddddd�d
�d
d��Z	dd�Z
dS)�TestLerpFrrJ)r�r�r�r�r�r�)�t0�t1rar~cCsht�|||�}t�|||�}||ks,||kr:||ksdJ�n*||k||kkrX||ksdJ�n||ksdJ�dSr3�rU�_lerp)r`r�r�rar~Zl0�l1r:r:r;�+test_linear_interpolation_formula_monotonic�
s	z4TestLerp.test_linear_interpolation_formula_monotonic)�trar~cCsV||kr.|t�|||�kr&|ksRnJ�n$|t�|||�krL|ksRnJ�dSr3r�)r`rrar~r:r:r;�)test_linear_interpolation_formula_bounded�
s&z2TestLerp.test_linear_interpolation_formula_boundedcCs6t�||dd|�}t�||d|�}t||�dSrC)rUr�r)r`rrar~rUrWr:r:r;�+test_linear_interpolation_formula_symmetric�
sz4TestLerp.test_linear_interpolation_formula_symmetriccCs8t�d�}t�d�}t�d�}t�|||�dks4J�dS)NrHrSr8g������@)r4r�rUr�)r`rar~rr:r:r;�+test_linear_interpolation_formula_0d_inputs�
s


z4TestLerp.test_linear_interpolation_formula_0d_inputsN)rqrrrsr�r�r�r�rrrrr:r:r:r;r��
sJ�����

����
����
r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	�
dgd�d
ejdgejdf�dd��Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)#�
TestMediancCs>t�d�}t�d�}t�d��dd�}tt�|�d�tt�|�d�tt�|�d�ttj|dd�gd	��ttj|dd�dd
g�ttj|dd�d�t�gd��}t|d|ddt�|��t�gd
��}t|dt�|��t�gd��}t|dt�|��tt�|�jd�tj	|d<tt�|�jd�dS)NrJrHrmrRr�r�rru�r�r�rvrF)��6-¦?��0���?���}r�?g��4�?r�)r	rr
)rr
r	rY)
r4r�r5ror�medianrr	r�r
)r`�a0r4rdrar:r:r;rds$

 
zTestMedian.test_basiccCs�t�ddgddgddgddgg�}|tjjdd	d
d�fD]B}|��}tj|dd�t|j�D]}tj||d�q\t||�q8t	tj|dd�ddg�t	tj|j
dd�ddg�t	t�|�d
�t	tj|dd�d
�t	t�|j
�d
�dS)NrHrRrrJrmrnrFrSrr�r�rurv)r4r�r�Zrandintr�rr_r�rrr&)r`�a3raZorig�axr:r:r;�test_axis_keywords 
�zTestMedian.test_axis_keywordcCs�t�ddgddgddgddgg�}t�d�}t�d�}t�d��dd�}ttj|��d	d
�d�ttj|��d	d
�d�ttj|��d	d
�d�ttj|��d	dd
�gd��ttj|��d	dd
�ddg�ttj|��d	dd
�d�ttj|��d	dd
�ddg�ttj|j��d	dd
�ddg�tjdtjd��d�}tj	�
|���ttj|dd�tj|��dd	d��ttj|dd�tj|��dd	d��ttj|dd�tj|��dd	d��ttj|dd�tj|��dd	d��dS)NrHrRrrJrmrnrFrSTr�r�r�)r�rvrr�r�rQru)rvr�)r4r�r5rorrr�r&r�r�r�r�)r`r
rr4rdZa4r:r:r;�test_overwrite_keyword,sP
�

���������z!TestMedian.test_overwrite_keywordcCsFgd�}tt�|�d�|g}tt�|�d�ttj|dd�|�dS)Nr�rHrru)r	r4rr)r`r�r�r:r:r;r�Ms
zTestMedian.test_array_likecCs2Gdd�dtj�}|gd��}tt�|�d�dS)Nc@s eZdZddd�Zddd�ZdS)z,TestMedian.test_subclass.<locals>.MySubClassNcSst�|��|�}||_|Sr3)r4rMr��info)�clsZinput_arrayr�objr:r:r;�__new__Xsz4TestMedian.test_subclass.<locals>.MySubClass.__new__cSsdS)N���r:)r`rvr�r}r:r:r;r�]sz1TestMedian.test_subclass.<locals>.MySubClass.mean)N)NNN)rqrrrsrr�r:r:r:r;�
MySubClassVs
rr�r)r4r�rr)r`rrar:r:r;r/Ts
zTestMedian.test_subclassr�r�r�r�r�cCs:Gdd�dtj�}t�t�|��|��}t||�s6J�dS)z6Check that we return subclasses, even if a NaN scalar.c@seZdZdS)z-TestMedian.test_subclass2.<locals>.MySubclassNr�r:r:r:r;�
MySubclassgsrN)r4r�rr�r�r-)r`r�rr�r:r:r;�test_subclass2cszTestMedian.test_subclass2cCslt�d�}t�d�}ttj|d|d�|�t�d�}ttj|d|d�|�t�d�}ttj||d�|�dS)Nr�r!rr�r�rJr:)r4r=r^rrr�r:r:r;r�ms



zTestMedian.test_outcCs�tjdd���t�ddt�t�d�}t�d�}tj|d<ttj	|d|d	�|�t�d
�}ttj	|d|d	�|�t�d�}ttj	||d	�|�Wd�n1s�0YdS)
NTrrrr�r!r�rr�r�rJr:)
rrr r�r4r=r^r
rrr�r:r:r;r�vs




zTestMedian.test_out_nancCsftjdtd�}tj|d<tt�|�tj�ttj|dd�tj�tjdtd��ddd�}tj|d<tj|d	<tt�|�tj�tt�|�jd�t�tjdtd��ddd�d�}tj|d
<tj|d<tt�|d�|�t�tjdtd��ddd�d�}tj|d
<tj|d<tt�|d�|�t�tjdtd��ddd�d�}tj|d<tj|d<tt�|d�|�dS)Nr#r�rHrrurRrFr�r�r�rhrJr�rN)r4r5r9r
rrror�r}r:r:r;r��s*


 

 

 

zTestMedian.test_nan_behaviorcCs�tjgtd�}tjdd��P}t�ddt�tt�|�tj	�t
|djtu�tt|�d�Wd�n1sp0Ytjgtdd	�}tjdd��B}t�ddt�tt�|�tj	�t
|djtu�Wd�n1s�0Ytjgtdd	�}ttj|dd
�|�ttj|dd
�|�tjtj	tdd	�}tjdd��D}t�ddt�ttj|dd
�|�t
|djtu�Wd�n1�s�0YdS)Nr�TrrrrrHrR)r�r�rurJ)
r4r�r9rrr r�rrr
rr"r�)r`rar�r~r:r:r;r��s&,0zTestMedian.test_emptycCsLt�d�}ttt�|�t���t�tj|d<ttt�|�t���t�dS)NrKrH)	r4r5rr�rr�r�r9r
)r`rr:r:r;�test_object�s

zTestMedian.test_objectc
Cs�tjjdd�}t�|gd�}ttj|dd�t�|��t�|dd�}ttj|dd�t�|��|�dd	���}ttj|d
d�t�|��ttj|dd�tj|dd��ttj|dd�tj|dd��ttj|d
d�tj|dd��t�	d��
d�}tj�|���ttj|dd�dt�|dd�dd�dd�df�
���ttj|dd�d	t�|dd�dd�d	dd�f�
���ttj|dd�dt�|dd�dd�ddd�f�
���ttj|dd�dt�|ddd�dd�dd�f�
���ttj|dd�dt�|dd	dd�dd�f�
���ttj|dd�dt�|ddd�dd�d	f�
���ttj|dd�dt�|ddd�ddd�f�
���dS)Nr�r�r�rZrurYrrirJrgrIr�)rYr�r�r�r�rHr�r�r�r�r�rM)r4r�r�r�rrr�r�r�r5ror�r�r�r�r:r:r;r��sB$�$�$�$� � � �zTestMedian.test_extended_axiscCspt�d�}ttjtj|dd�ttjtj|dd�ttjtj|dd�ttjtj|dd�tttj|dd�dS)Nr�rArur�rFr�rO)r4r^rryrr]r�r:r:r;r��s
z%TestMedian.test_extended_axis_invalidcCs�t�d�}ttj|ddd�jd�ttj|ddd�jd�ttj|ddd�jd�ttj|d	dd�jd
�ttj|ddd�jd�ttj|ddd�jd
�dS)Nr�Tr�r�rZr�rxr�r�r�r�r�r�)r4r^rrr?r�r:r:r;r��s&
������zTestMedian.test_keepdimsN)rqrrrsrdrrr�r/r�r�r�r4r
rr�r�r�r�rr�r�r�r:r:r:r;rs"!�
	 rc@seZdZdd�Zdd�ZdS)�TestAdd_newdoc_ufunccCs"tttdd�ttttjd�dS)NrHZblah)rrrr]r4r6r{r:r:r;�test_ufunc_arg�sz#TestAdd_newdoc_ufunc.test_ufunc_argcCsttttjd�dS)NrR)rrrr4r6r{r:r:r;�test_string_argsz$TestAdd_newdoc_ufunc.test_string_argN)rqrrrsrrr:r:r:r;r�src@s\eZdZejjejjdkdd�ejj	e
dd�dd���Zejjejjdkdd�dd��Zd	S)
�TestAdd_newdocrH�Python running -OOry�PyPy does not modify tp_doccCsVd}ttjjjjdt|��|�tttjjj	j�dk�tttj
jjj�dk�dS)Nz"Current flat index into the array.r�)
rr4�core�flatiter�indexrGr�rZufunc�identityr�Zindex_tricksZmgrid)r`rer:r:r;�test_add_docszTestAdd_newdoc.test_add_doccCs2tjjjj}t�ddd�|tjjjjks.J�dS)Nz
numpy.corer!)r"z
bad docstring)r4r r!r"rGZ
add_newdoc)r`Zprev_docr:r:r;�test_errors_are_ignoredsz&TestAdd_newdoc.test_errors_are_ignoredN)
rqrrrsr�r�r�r}r��optimizer�r
r$r%r:r:r:r;rs
rc@s\eZdZejjejjdkdd�ejje	dd�dd���Z
ejjejjdkdd�dd��Zd	S)
�TestAddDocstringrHrryrcCs0t�tjjtjjj�dd�}t�||j�dS)NcSsdS�Z	docstringNr:r:r:r:r;�func"sz6TestAddDocstring.test_add_same_docstring.<locals>.func)r4�
add_docstringr��flatrG�r`r)r:r:r;�test_add_same_docstringsz(TestAddDocstring.test_add_same_docstringcCsxtt�� t�tjjd�Wd�n1s.0Ydd�}tt��t�|d�Wd�n1sj0YdS)Nzdifferent docstringcSsdSr(r:r:r:r:r;r).sz=TestAddDocstring.test_different_docstring_fails.<locals>.func)rr�r4r*r�r+r,r:r:r;�test_different_docstring_fails(s

.
z/TestAddDocstring.test_different_docstring_failsN)rqrrrsr�r�r�r}r�r&r
r-r.r:r:r:r;r's

r'c@s.eZdZej�dgd��dd��Zdd�ZdS)�TestSortComplexztype_in, type_out))�l�D)�hr�)�Hr�)r~r�)r�r�)r��GcCsHtjgd�|d�}t�|�}t�|��|�}t||�t|j|j�dS)N)rSrRrmrHrJr�)r4r��sort_complexr�r�rr�)r`Ztype_inZtype_outrar�r�r:r:r;�test_sort_real8s



zTestSortComplex.test_sort_realcCsJtjgd�dd�}tjgd�dd�}t�|�}t||�t|j|j�dS)N)rj��?�r�rkr1r�)r�r7rkrj)r4r�r5rr�)r`rar�r�r:r:r;�test_sort_complexHs


z!TestSortComplex.test_sort_complexN)rqrrrsr�r�r�r6r8r:r:r:r;r/6s
r/)r�)r�r�)zrkrr}r�Z	fractionsrrr�r�Zhypothesis.extra.numpyrZhypothesis.strategiesZ
strategiesr�Znumpyr4rZ
numpy.testingrrrr	r
rrr
rrrrZnumpy.lib.function_baser�Z
function_baserUZnumpy.randomrZ	numpy.librrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r<rDrErtr�r�r�r�r�rr?rHrIrLrfrsrwr�r�r�r�rrrrrqr�r�r�r�r�r�r�r�r�r�r�r�rrr
rr-r5rOrwr�r�rrrr'r/r:r:r:r;�<module>s�8�Dg#	>o
u}A)

*)U�l>[j4
nd`Crm2z


Zerion Mini Shell 1.0