https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/numpy/lib/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/numpy/lib/tests/__pycache__/test_nanfunctions.cpython-310.pyc
o

6��a���@srddlZddlZddlZddlmZmZddlmZm	Z	m
Z
mZmZm
Z
mZe�dejddejdgdd	ejd
ddgejejejd
ejdgdejejddejgg�Ze�gd��e�gd��e�d
dg�e�gd��gZe�gd�gd�gd�gd�g�Ze�gd�gd�gd�gd�g�ZGdd�d�ZGdd �d �ZGd!d"�d"�ZGd#d$�d$�ZGd%d&�d&e�ZGd'd(�d(e�ZGd)d*�d*e�Zd+Zeejd,�Zed-d.�eD�7ZGd/d0�d0�Z Gd1d2�d2�Z!Gd3d4�d4�Z"ej#�$d5e�ejd6ejej%g�e�gd7��fejgd8�ej&d9�d:fe�gd7��d:fejejd6gejej%ggej'd9�e�d;d:gd;d:gg�fg�d<d=��Z(d>d?�Z)dS)@�N)�	_nan_mask�_replace_nan)�assert_�assert_equal�assert_almost_equal�assert_no_warnings�
assert_raises�assert_array_equal�suppress_warnings��s���?�&S��:�?������?�ʡE��?��	��?绸�����z�G��?�L�
F%u�?�6<�R�!�?�[B>�٬�?�:M�
���S㥛�?�z�):���?���	h"�?)rrr
r)rrrrr)rrr)r��?rr
rr)rrrrrr)rrrrrr)rrrrrr)r�rr
rr)rrrrrr)rrrrrr)rrrrrrc@steZdZejejgZejejgZ	dd�Z
dd�Zdd�Zdd�Z
d	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�ZdS)�TestNanFunctions_MinMaxcC�*t��}|jD]}||�t|t�qdS�N��_ndat�copy�nanfuncsr��self�ndat�f�r&�C/usr/lib/python3/dist-packages/numpy/lib/tests/test_nanfunctions.py�
test_mutation+�

�z%TestNanFunctions_MinMax.test_mutationcC�\t�d�}t|j|j�D]\}}dD]}|||dd�}|||dd�}t|j|jk�qqdS�N��Nr�T��axis�keepdims��np�eye�zipr!�stdfuncsr�ndim�r#�mat�nf�rfr0�tgt�resr&r&r'�
test_keepdims2�
��z%TestNanFunctions_MinMax.test_keepdimscC�^t�d�}t|j|j�D] \}}t�d�}||dd�}||d|d�}t||�t||�qdS�Nr,r.�r0�r0�out�r3r4r5r!r6�zerosr�r#r9r:r;�resoutr<r=r&r&r'�test_out:�


�z TestNanFunctions_MinMax.test_outcCs�d}t|j|j�D]<\}}|D]5}tjd|d�}||dd�jj}||dd�jj}t||u�||dd�jj}||dd�jj}t||u�qq	dS)N�efdgFDGr,��dtyper.rB�r5r!r6r3r4rM�typer�r#�codesr:r;�cr9r<r=r&r&r'�test_dtype_from_inputCs��z-TestNanFunctions_MinMax.test_dtype_from_inputc�Dt|j|j�D]\}��fdd�tD�}|tdd�}t||�qdS)Nc�g|]}�|��qSr&r&��.0�d�r;r&r'�
<listcomp>R�z>TestNanFunctions_MinMax.test_result_values.<locals>.<listcomp>r.rB�r5r!r6�_rdatrr�r#r:r<r=r&rYr'�test_result_valuesP�
�z*TestNanFunctions_MinMax.test_result_valuesc
Cst�tjgd��dd�}|jD]z}dD]=}tjdd��-}t�d�tt�	|||d���
��tt|�dkd	�tt|d
j
t��Wd�n1sLwYqtjdd��*}t�d�tt�	|tj���tt|�dkd	�tt|d
j
t��Wd�n1s�wYqdS)N�	r,r-T��record�alwaysrBr.�no warning raisedr�r3�array�nan�reshaper!�warnings�catch_warnings�simplefilterr�isnan�all�len�
issubclass�category�RuntimeWarning�r#r9r%r0�wr&r&r'�test_allnansVs$

��
���z$TestNanFunctions_MinMax.test_allnanscCsjtj�t�}|j��}tjfD]#}||dd�}|tdd�}t||�t|j|�tt�	|��
��qdS)Nr.rB)r3�ma�fix_invalidr�_maskr �nanminrr�isinf�any)r#r9�mskr%r=r<r&r&r'�test_maskedfs

�z#TestNanFunctions_MinMax.test_maskedcC� |jD]
}t|d�dk�qdS�Nr�r!r�r#r%r&r&r'�test_scalarp�
�z#TestNanFunctions_MinMax.test_scalarc	Cs8Gdd�dtj�}t�d��|�}|jD]5}||dd�}tt||��t|jdk�||dd�}tt||��t|jdk�||�}t|jdk�qtj|d<|jD]�}t	j
d	d
��-}t	�d�||dd�}tt||��tt�t�
|���tt|�dk�Wd�n1s�wYt	j
d	d
��F}t	�d�||dd�}tt||��tt�
|d�o�t�
|d�o�t�
|d��tt|�dkd
�tt|djt��Wd�n1s�wYt	j
d	d
��'}t	�d�||�}t|jdk�t|tjk�tt|�dk�Wd�n	1�swYqRdS)Nc@�eZdZdS)z8TestNanFunctions_MinMax.test_subclass.<locals>.MyNDArrayN��__name__�
__module__�__qualname__r&r&r&r'�	MyNDArrayu�r�r,rrB�r,r.r&Trbrd�re)r3�ndarrayr4�viewr!r�
isinstance�shaperhrjrkrlr{rmrorprqrr)r#r��miner%r=rtr&r&r'�
test_subclasstsN



�
 ��	
���z%TestNanFunctions_MinMax.test_subclasscCs�tjddgtjdgtjtjggtd�}tt�|�d�ttj|dd�ddg�tjdd��1}t�d	�tt	tj|d
d��ddtjg�t
t|�d
kd�t
t|dj
t��Wd�dS1sawYdS)Nrg@�@rLrrBTrbrdr.re)r3rgrh�objectrryrjrkrl�listrrorprqrr)r#�arrrtr&r&r'�test_object_array�s&
 "�z)TestNanFunctions_MinMax.test_object_arrayN)r�r�r�r3ry�nanmaxr!�min�maxr6r(r>rIrSr_rur}r�r�r�r&r&r&r'r&s	

+rc@sHeZdZejejgZdd�Zdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
S)�TestNanFunctions_ArgminArgmaxcCrrrr"r&r&r'r(�r)z+TestNanFunctions_ArgminArgmax.test_mutationc
Cs�t|jtjtjg�D]K\}}tD]D}t��7}|�td�||�}||}t	t�
|��t	|||����t	t�||d|�����Wd�n1sOwYqq
dS)Nzinvalid value encountered in)
r5r!r3�greater�lessrr
�filterrrrrmr{�equal)r#r%�fcmp�row�sup�ind�valr&r&r'r_�s ����z0TestNanFunctions_ArgminArgmax.test_result_valuescCsRt�tjgd��dd�}|jD]}dD]
}tt|||d�qtt|tj�qdS)Nrar,r-rB)r3rgrhrir!r�
ValueError)r#r9r%r0r&r&r'ru�s
�z*TestNanFunctions_ArgminArgmax.test_allnanscCsZt�d�}|jD]"}dD]
}tt|||d�qdD]}|||d�}t|t�d��qqdS)N�rr,�rNrB�r.r)r3rFr!rr�r)r#r9r%r0r=r&r&r'�
test_empty�s

��z(TestNanFunctions_ArgminArgmax.test_emptycCr~rr�r�r&r&r'r��r�z)TestNanFunctions_ArgminArgmax.test_scalarcCs�Gdd�dtj�}t�d��|�}|jD]5}||dd�}tt||��t|jdk�||dd�}tt||��t|jdk�||�}t|jdk�qdS)	Nc@r�)z>TestNanFunctions_ArgminArgmax.test_subclass.<locals>.MyNDArrayNr�r&r&r&r'r��r�r�r,rrBr�r.r&)r3r�r4r�r!rr�r�)r#r�r�r%r=r&r&r'r��s
�z+TestNanFunctions_ArgminArgmax.test_subclassN)
r�r�r�r3�	nanargmin�	nanargmaxr!r(r_rur�r�r�r&r&r&r'r��s
	r�c@s�eZdZejejejejejej	ej
ejfZe�
gd��Zdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�TestNanFunctions_IntTypes)��'�]�W�.ccs �|jD]	}|j�|�VqdSr)�	int_typesr9�astype)r#rMr&r&r'�integer_arrays�s�
�z(TestNanFunctions_IntTypes.integer_arrayscC�.t�|j�}|��D]
}tt�|�|�q
dSr)r3r�r9r�rry�r#r<r9r&r&r'�test_nanmin���z%TestNanFunctions_IntTypes.test_nanmincCr�r)r3r�r9r�rr�r�r&r&r'�test_nanmax�r�z%TestNanFunctions_IntTypes.test_nanmaxcCr�r)r3�argminr9r�rr�r�r&r&r'�test_nanargmin�r�z(TestNanFunctions_IntTypes.test_nanargmincCr�r)r3�argmaxr9r�rr�r�r&r&r'�test_nanargmaxr�z(TestNanFunctions_IntTypes.test_nanargmaxcCr�r)r3�sumr9r�r�nansumr�r&r&r'�test_nansum	r�z%TestNanFunctions_IntTypes.test_nansumcCr�r)r3�prodr9r�r�nanprodr�r&r&r'�test_nanprodr�z&TestNanFunctions_IntTypes.test_nanprodcCr�r)r3�cumsumr9r�r�	nancumsumr�r&r&r'�test_nancumsumr�z(TestNanFunctions_IntTypes.test_nancumsumcCr�r)r3�cumprodr9r�r�
nancumprodr�r&r&r'�test_nancumprodr�z)TestNanFunctions_IntTypes.test_nancumprodcCr�r)r3�meanr9r�r�nanmeanr�r&r&r'�test_nanmeanr�z&TestNanFunctions_IntTypes.test_nanmeancCs^t�|j�}|��D]
}tt�|�|�q
tj|dd�}|��D]}ttj|dd�|�q dS�Nr.��ddof)r3�varr9r�r�nanvarr�r&r&r'�test_nanvar"s�z%TestNanFunctions_IntTypes.test_nanvarcCs`t�|j�}|��D]
}tt�|�|�q
tj|jdd�}|��D]}ttj|dd�|�q!dSr�)r3�stdr9r�r�nanstdr�r&r&r'�test_nanstd+s�z%TestNanFunctions_IntTypes.test_nanstdN)r�r�r�r3�int8�int16�int32�int64�uint8�uint16�uint32�uint64r�rgr9r�r�r�r�r�r�r�r�r�r�r�r�r&r&r&r'r��s"�	r�c@�TeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�SharedNanFunctionsTestsMixincCrrrr"r&r&r'r(6r)z*SharedNanFunctionsTestsMixin.test_mutationcCr*r+r2r8r&r&r'r>=r?z*SharedNanFunctionsTestsMixin.test_keepdimscCr@rArErGr&r&r'rIErJz%SharedNanFunctionsTestsMixin.test_outc	
Cs�t�d�}d}t|j|j�D]j\}}|D]c}t��V}|tjtjhvr,|dvr,|�tj	�||t�
|�dd�j
j}||t�
|�dd�j
j}t||u�||t�
|�dd�j
j}||t�
|�dd�j
j}t||u�Wd�n1srwYqqdS�Nr,rK�FDGr.)rMr0�
r3r4r5r!r6r
r�r�r��ComplexWarningrMrOr�	r#r9rQr:r;rRr�r<r=r&r&r'�test_dtype_from_dtypeNs"
����z2SharedNanFunctionsTestsMixin.test_dtype_from_dtypec	
Cs�t�d�}d}t|j|j�D]^\}}|D]W}t��J}|tjtjhvr,|dvr,|�tj	�|||dd�j
j}|||dd�j
j}t||u�|||dd�j
j}|||dd�j
j}t||u�Wd�n1sfwYqqdSr�r�r�r&r&r'�test_dtype_from_char_s"
����z1SharedNanFunctionsTestsMixin.test_dtype_from_charcCs�d}t|j|j�D]A\}}|D]:}tjd|d�}||dd�jj}||dd�jj}t||ud||f�||dd�jj}||dd�jj}t||u�qq	dS)NrKr,rLr.rBzres %s, tgt %srNrPr&r&r'rSps��z2SharedNanFunctionsTestsMixin.test_dtype_from_inputcrT)NcrUr&r&rVrYr&r'rZr[zCSharedNanFunctionsTestsMixin.test_result_values.<locals>.<listcomp>r.rBr\r^r&rYr'r_}r`z/SharedNanFunctionsTestsMixin.test_result_valuescCr~rr�r�r&r&r'r��r�z(SharedNanFunctionsTestsMixin.test_scalarcCs�Gdd�dtj�}t�d�}|�|�}|jD]O}||dd�j}||dd�}tt||��t|j|k�||dd�j}||dd�}tt||��t|j|k�||�j}||�}tt||��t|j|k�qdS)Nc@r�)z=SharedNanFunctionsTestsMixin.test_subclass.<locals>.MyNDArrayNr�r&r&r&r'r��r�r�r,rrBr.)r3r�r4r�r!r�rr�)r#r�rgr�r%�expected_shaper=r&r&r'r��s"



�z*SharedNanFunctionsTestsMixin.test_subclassN)r�r�r�r(r>rIr�r�rSr_r�r�r&r&r&r'r�5s	
r�c@s4eZdZejejgZejejgZ	dd�Z
dd�ZdS)�TestNanFunctions_SumProdcCs�tjdd��R}t�d�tjtjgddd�}t|dkd�tt|�dkd�t�tj�}t|dkd�tt|�dkd�tjdgddd�tt|�dkd	�Wd�dS1s[wYdS)
NTrbrdr,rBrzresult is not 0zwarning raisedzunwanted warning raised)rjrkrlr3r�rhrro)r#rtr=r&r&r'ru�s
"�z%TestNanFunctions_SumProd.test_allnanscCs�ttjtjgddg�D]3\}}t�d�}|gd}||dd�}t||�g}||dd�}t||�|}||dd�}t||�qdS)Nrr.r�r,rB)r5r3r�r�rFr�r#r%�	tgt_valuer9r<r=r&r&r'r��s



�z#TestNanFunctions_SumProd.test_emptyN)r�r�r�r3r�r�r!r�r�r6rur�r&r&r&r'r��s
r�c@sLeZdZejejgZejejgZ	dd�Z
dd�Zdd�Zdd�Z
d	d
�ZdS)�TestNanFunctions_CumSumProdc	Cs�t|jddg�D]S\}}t��D|tjgddd�}|t�d�}tt�||�d|�|tj�}|t�d�}tt�||�d|�|dgddd�Wd�n1sVwYqdS)Nrr.r,rBzresult is not %s * np.ones((3))zresult is not %s * np.ones((1)))r5r!rr3rh�onesr�array_equal)r#r%r�r=r<r&r&r'ru�s
���z(TestNanFunctions_CumSumProd.test_allnanscCs�t|jddg�D]8\}}t�d�}|t�d�}||dd�}t||�|}||dd�}t||�t�d�}||dd�}t||�qdS)Nrr.r�rB)r5r!r3rFr�rr�r&r&r'r��s



�z&TestNanFunctions_CumSumProd.test_emptyc	Cs�t|j|j�D]$\}}t�d�}dD]}|||dd�}|||dd�}t|j|jk�qq|jD]8}t�d�}tj�	d�}tj
||j|j�dk<||dd�}t
|jd�t�d	�D]}|||d�}t
|jd�qXq/dS)
Nr,r-rC�r,���r��?rB)i��)r5r!r6r3r4rr7r��random�RandomStaterh�randr�r�arange)	r#r%�gr9r0r<r=rX�rsr&r&r'r>�s$
�

��z)TestNanFunctions_CumSumProd.test_keepdimscCsZdD](}tjt|d�}tjt|d�}t||�tjt|d�}tjt|d�}t||�qdS)N)������rr.NrB)	r3r��
_ndat_onesr�rrr��_ndat_zerosr�)r#r0r<r=r&r&r'r_�s
�z.TestNanFunctions_CumSumProd.test_result_valuescCsht�d�}t|j|j�D]%\}}t�d�}dD]}|||d�}||||d�}t||�t||�qqdS)Nr,)r�r�rr.rBrC)r3r4r5r!r6r)r#r9r:r;rHr0r<r=r&r&r'rI�s


��z$TestNanFunctions_CumSumProd.test_outN)r�r�r�r3r�r�r!r�r�r6rur�r>r_rIr&r&r&r'r��s
	r�c@s\eZdZejejejgZejej	ej
gZdd�Zdd�Z
dd�Zdd�Zd	d
�Zdd�Zd
S)�TestNanFunctions_MeanVarStdc	Cs8|jD]}tjtjtjfD]}tt|td|d�q
qdS)Nr.)r0rM)r!r3�bool_�int_�object_r�	TypeErrorr)r#r%rMr&r&r'�test_dtype_errors

��z,TestNanFunctions_MeanVarStd.test_dtype_errorc	CsL|jD] }tjtjtjfD]}tjtjd|d�}tt	|td|d�q
qdS)NrrLr.rC)
r!r3r�rr�emptyrr�rr)r#r%rMrDr&r&r'�test_out_dtype_errors
��z0TestNanFunctions_MeanVarStd.test_out_dtype_errorcsftjtjg}tjtjg}t||�D]\}�dD]���fdd�tD�}|td�d�}t||�qqdS)N�rr.csg|]}�|�d��qS)r�r&rV�r�r;r&r'rZ�z9TestNanFunctions_MeanVarStd.test_ddof.<locals>.<listcomp>r.�r0r�)	r3r�r�r�r�r5r]rr)r#r!r6r:r<r=r&rr'�	test_ddofs��z%TestNanFunctions_MeanVarStd.test_ddofc	
s�tjtjg}tjtjg}dd�tD�}t||�D]X\}}td�D]O�t��B}|�	t
�|�tj��fdd�|D�}|t
d�d�}tt�|�|�t|�rWtt|j�dk�n	tt|j�dk�Wd�n1sjwYq qdS)NcSsg|]}t|��qSr&)rorVr&r&r'rZ#r[zATestNanFunctions_MeanVarStd.test_ddof_too_big.<locals>.<listcomp>r�csg|]}�|k�qSr&r&rVr�r&r'rZ)r[r.r	r)r3r�r�r�r�r]r5�ranger
rcrrr�r�rrrmr{rro�log)	r#r!r6�dsizer:r;r�r<r=r&r�r'�test_ddof_too_big s&
�����z-TestNanFunctions_MeanVarStd.test_ddof_too_bigc
Cs�t�tjgd��dd�}|jD]]}dD]X}tjdd��H}t�d�tt�	|||d���
��tt|�dk�tt|d	j
t��tt�	|tj���tt|�d
k�tt|d	j
t��Wd�n1sgwYqqdS)Nrar,r-TrbrdrBr.rr�rfrsr&r&r'ru1s

����z(TestNanFunctions_MeanVarStd.test_allnansc
Cst�d�}|jD]u}dD]<}tjdd��,}t�d�tt�|||d�����tt	|�dk�tt
|djt��Wd�n1sCwYqd	D]1}tjdd��!}t�d�t
|||d�t�g��tt	|�dk�Wd�n1swwYqKqdS�
Nr�r�TrbrdrBr.rr�)r3rFr!rjrkrlrrmrnrorprqrrrrsr&r&r'r�?s&


��
����z&TestNanFunctions_MeanVarStd.test_emptyN)r�r�r�r3r�r�r�r!r�r�r�r6rrr
rrur�r&r&r&r'r�s	r�)
�Y�M�W�D�h�m�s�ms�us�ns�ps�fs�as�AllFloatcCsg|]}d|�d��qS)zm8[�]r&)rW�unitr&r&r'rZUrrZc@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	�
dgd��ej	�
d
e�dd���Zdd�Z
dd�Zdd�Zdd�ZdS)�TestNanFunctions_MediancCs t��}t�|�t|t�dSr)rr r3�	nanmedianr�r#r$r&r&r'r(Zs
z%TestNanFunctions_Median.test_mutationcCsnt�d�}dD]}tj||ddd�}tj||ddd�}t|j|jk�qt�d�}tj�d�t�|j	�dd�df}|�
tj�}tj|t
|�<t��b}|�t�tj|ddd�}t|j	d	�tj|d
dd�}t|j	d�tj|ddd�}t|j	d
�tj|ddd�}t|j	d�tj|ddd�}t|j	d	�tj|ddd�}t|j	d�Wd�dS1s�wYdS)Nr,r-F�r0rD�overwrite_inputr��r���Tr/�r.r.r.r.r�r.r.r�r�r��r.r�r�r.r��r,r.r�r��rr.r�r,�rr.r,�r.r.r�r.)r3r4�medianr!rr7r�r�rgr�r��intprh�tupler
r�rrr�r#r9r0r<r=rXrtr�r&r&r'r>`s0

$
"�z%TestNanFunctions_Median.test_keepdimscCs�tj�dd�}tj|ddgtjdd�}t�d�}tj|dd�}tj|d|d�}t||�t||�t�d�}tj|dd�}tj|d|d�}t||�t||�tj|d|d�}t||�t||�dS)	Nr,rr�r.rBrCr&r)	r3r�r��insertrhrFr.r!r�r#r9�nan_matrHr<r=r&r&r'rI{s






z TestNanFunctions_Median.test_outcCs�dD]J}tj�d|�}tjjd|j|jdd�}tj|��|<d|dd�df<g}|D]}t�t�|�|�}|�	tj
|dd��q+ttj|d	d
�|�qdS)N)r���3r&i�r�rr�)�sizerT)r$r�rB)
r3r��randn�randintr7rh�ravel�compressrm�appendr.r	r!)r#rrXrtr<�x�nonanr&r&r'�test_small_large�s�z(TestNanFunctions_Median.test_small_largecCs*dd�tD�}tjtdd�}t||�dS)NcSsg|]}t�|��qSr&)r3r.rVr&r&r'rZ�sz>TestNanFunctions_Median.test_result_values.<locals>.<listcomp>r.rB)r]r3r!rr�r#r<r=r&r&r'r_�sz*TestNanFunctions_Median.test_result_valuesr0r-rMcCs$t�dtj��|�}t��{}|�t�tj||d�}|j|jks"J�t�	|��
�s+J�|dur9tt|j
�dk�n	tt|j
�dk�t�tj��|�d}t�|�}|j|jksZJ�t�	|�saJ�|durott|j
�dk�ntt|j
�dk�Wd�dSWd�dS1s�wYdS)N)r,r,rBr.r,r&r�r�)r3�fullrhr�r
rcrrr!rMrmrnrrorrg)r#rMr0r9r��output�scalar�
output_scalarr&r&r'ru�s&

�"�z$TestNanFunctions_Median.test_allnansc	Cs�t�d�}dD]=}tjdd��-}t�d�tt�tj||d�����tt	|�dk�tt
|djt��Wd�n1s?wYqd	D]2}tjdd��"}t�d�t
tj||d�t�g��tt	|�dk�Wd�n1stwYqGdSr)r3rFrjrkrlrrmr!rnrorprqrrr�r#r9r0rtr&r&r'r��s"

��
���z"TestNanFunctions_Median.test_emptycCstt�d�dk�dSr)rr3r!)r#r&r&r'r��sz#TestNanFunctions_Median.test_scalarcCspt�d�}ttjtj|dd�ttjtj|dd�ttjtj|dd�ttjtj|dd�tttj|dd�dS)Nr����rB�rrFr��rr��r.r.)r3r�r�	AxisErrorr!r��r#rXr&r&r'�test_extended_axis_invalid�s
z2TestNanFunctions_Median.test_extended_axis_invalidc	Cs�t���l}|�t�tjtjfD�]U}t�|tjgtjtjgg�}ttj|dd�|tjg�ttj|dd�|tjg�tt�|�|�t�tjtj|gtjtj|gg�}tt�|�|�ttj|dd�tjtj|g�ttj|dd�|�t�||g||gg�}ttj|dd�|�tj|d|dgdtjtjdgdtjtj|ggtj	d	�}|dkr�ttj|dd�d
d|dg�tt�|�d
�nttj|dd�dd|dg�tt�|�d�ttj|dd�dd|g�t
dd�D]z}t
dd�D]r}t�tjg||g|gd�}tt�|�|�ttj|dd�|�ttj|dd�tjg||g|�t�tjg||g|gd�}tt�|�|�ttj|dd�|�ttj|dd�tjg||g|�q�q�qWd�dS1�stwYdS)NrrBr.r�i����i����r�r�rLr�g@�@g@g$�g"�g�r�g��
r�)r
r�rrr3�infrgrhrr!�float32r)r#r�rO�a�i�jr&r&r'�test_float_special�sZ

���"�$����$�z*TestNanFunctions_Median.test_float_specialN)r�r�r�r(r>rIr?r_�pytest�mark�parametrize�_TYPE_CODESrur�r�rLrTr&r&r&r'r Xsr c@r�)�TestNanFunctions_PercentilecCs"t��}t�|d�t|t�dS)N�)rr r3�
nanpercentilerr"r&r&r'r(sz)TestNanFunctions_Percentile.test_mutationcCs~t�d�}dD]}tj|d|ddd�}tj|d|ddd�}t|j|jk�qt�d�}tj�d�t�|j	�dd�df}|�
tj�}tj|t
|�<t��h}|�t�tj|ddd	d
�}t|j	d�tj|ddd	d
�}t|j	d
�tj|ddd	d
�}t|j	d�tj|ddd	d
�}t|j	d�tj|ddd	d
�}t|j	d�tj|ddd	d
�}t|j	d�Wd�dS1s�wYdS)Nr,r-�FFr#r�r%�ZTr/r'rr(r�r)r�r*r+r,r-)r3r4�
percentiler[rr7r�r�rgr�r�r/rhr0r
r�rrrr1r&r&r'r>
s8
��
$
"�z)TestNanFunctions_Percentile.test_keepdimscCs�tj�dd�}tj|ddgtjdd�}t�d�}tj|ddd�}tj|dd|d�}t||�t||�t�d�}tj|ddd�}tj|dd|d�}t||�t||�tj|dd	|d�}t||�t||�dS)
Nr,rr�r.rB�*rCr&r)	r3r�r�r2rhrFr^r[rr3r&r&r'rI*s






z$TestNanFunctions_Percentile.test_outcCsZdd�tD�}tjtddd�}t||�t�dd�tD��}tjtddd�}t||�dS)NcS�g|]}t�|d��qS)��r3r^rVr&r&r'rZ=rzBTestNanFunctions_Percentile.test_result_values.<locals>.<listcomp>rar.rBcSr`)�ra�brbrVr&r&r'rZArrc)r]r3r[rr�	transposer@r&r&r'r_<s
z.TestNanFunctions_Percentile.test_result_valuesc
Cst�tjgd��dd�}dD]v}tjdd��f}t�d�tt�tj	|d|d���
��|dur9tt|�d	k�ntt|�dk�tt|d
j
t��tt�t�	tjd���|durdtt|�dk�ntt|�dk�tt|d
j
t��Wd�n1s�wYqdS)
Nrar,r-Trbrd�<rBr.rr�r�)r3rgrhrirjrkrlrrmr[rnrorprqrrrEr&r&r'ruEs"
���z(TestNanFunctions_Percentile.test_allnansc
Cs�t�d�}dD]>}tjdd��.}t�d�tt�tj|d|d�����tt	|�dk�tt
|d	jt��Wd�n1s@wYqd
D]3}tjdd��#}t�d�t
tj|d|d�t�g��tt	|�d	k�Wd�n1svwYqHdS)Nr�r�Trbrd�(rBr.rr�)r3rFrjrkrlrrmr[rnrorprqrrrrEr&r&r'r�Xs"

��
���z&TestNanFunctions_Percentile.test_emptycCsHtt�dd�d�t�d�}tj|ddd�}t|d�tt�|��dS)Nr�d��2rrBg@)rr3r[r�r�isscalar)r#rQ�rr&r&r'r�fs


z'TestNanFunctions_Percentile.test_scalarcCszt�d�}ttjtj|ddd�ttjtj|ddd�ttjtj|ddd�ttjtj|ddd�tttj|ddd�dS)	Nr�r�rF��qr0rGr�rHrI)r3r�rrJr[r�rKr&r&r'rLms
z6TestNanFunctions_Percentile.test_extended_axis_invalidc
Cs0ddg}t�d�}tj|}t�d�}d|dd�ddd�dd�f<|dd�dd�dd�fd9<d	D]P}d
D]K}t��>}|�td�tj||||d�}tj||||d�}	t|	j	|j	�tj||||d�}tj||||d�}	t|	|�Wd�n1s~wYq8q4t�d
�}
ttj|
|dd�j	d�dS)Nrjrh)r�r,)r,r�r�rr�r�r,r-)FTzAll-NaN slice encounteredr/)r,r�r�ri)r.r�rB)r�r,ri)
r3r�rhr
r�rrr^r[rr�)r#�percr9r4�	large_matr0�keepdimr�r��nan_val�megamatr&r&r'�test_multiple_percentilesus6


"
�
�
����
z5TestNanFunctions_Percentile.test_multiple_percentilesN)r�r�r�r(r>rIr_rur�r�rLrtr&r&r&r'rYs	rYc@s$eZdZdd�Zdd�Zdd�ZdS)�TestNanFunctions_QuantilecCs�t�d��ddd��t�}tj|dd<ttj|dd�tj|d	d��ttj|ddd
�tj|d	dd
��ttj|ddd
�tj|d	dd
��ttj|dgdd
�tj|d	gdd
��ttj|gd�dd
�tj|gd�dd
��dS)
N�r�r,r�rr.r�)rnrjrm)��?r���?)�rj�K)	r3r�rir��floatrhr�nanquantiler[)r#�arr&r&r'�test_regression�s����z)TestNanFunctions_Quantile.test_regressioncCsHt�d�d}tt�|d�d�tt�|d�d�tt�|d�d�dS)N�r�rrr.g@g�?)r3r�rr|)r#r=r&r&r'�
test_basic�sz$TestNanFunctions_Quantile.test_basiccCsjt�gd��}|��}tjt�d�|dd�t||�|��}|��}tjt�d�|dd�t||�dS)N)rrxrwr�rgY@�midpoint)�
interpolation)r3rgr r|r�r	�tolist)r#�p0�pr&r&r'�test_no_p_overwrite�s
z-TestNanFunctions_Quantile.test_no_p_overwriteN)r�r�r�r~r�r�r&r&r&r'ru�sruz
arr, expectedrM)FTFT)r.r�r�rarLTFcCsPdtj|jtjd�fD]}t||d�}t||�t|�tjur%|dus%J�qdS)NrL)rDT)r3rr�r�rrrOr�)r��expectedrD�actualr&r&r'�test__nan_mask�s
��r�cCstjtjtjfD]}tjddg|d�}t|d�\}}|dus J�||us&J�qtjtjfD]Z}tjddg|d�}t|d�\}}|dk��sGJ�||usMJ�t	||�tjddtj
g|d�}t|d�\}}t	|t�gd���||ustJ�t	|t�gd���t�|d	�s�J�q-dS)
z] Test that _replace_nan returns the original array if there are no
    NaNs, not a copy.
    rr.rLNr�F)FFT)rr.r�r�)r3r�r�r�rgrrP�float64rnrrhrm)rMr��result�mask�arr_nan�
result_nan�mask_nanr&r&r'�test__replace_nan�s$
�r�)*rjrU�numpyr3�numpy.lib.nanfunctionsrr�
numpy.testingrrrrrr	r
rgrhrr]r�r�rr�r�r�r�r�r��_TIME_UNITSr��	typecodesrXr rYrurVrWrOr��	complex64r�r�r&r&r&r'�<module>s~$��
�
�>Ki"GH.#���
��
���


https://t.me/RX1948 - 2025