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/testing/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

6��a]��@sddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlm Z Gdd�d�Z!Gdd�de!�Z"Gdd	�d	�Z#Gd
d�de"�Z$Gdd
�d
e!�Z%Gdd�de!�Z&Gdd�d�Z'Gdd�d�Z(ej)j*dd�Gdd�d��Z+Gdd�d�Z,Gdd�d�Z-Gdd�d�Z.Gdd�d�Z/Gd d!�d!�Z0d?d"d#�Z1d$d%�Z2d&d'�Z3d(d)�Z4d*d+�Z5d,d-�Z6d.d/�Z7d0d1�Z8d2d3�Z9d4d5�Z:d6d7�Z;Gd8d9�d9e�Z<d:d;�Z=ej)j>ed<d�Gd=d>�d>��Z?dS)@�N)�assert_equal�assert_array_equal�assert_almost_equal�assert_array_almost_equal�assert_array_less�
build_err_msg�raises�
assert_raises�assert_warns�assert_no_warnings�assert_allclose�assert_approx_equal�assert_array_almost_equal_nulp�assert_array_max_ulp�clear_and_catch_warnings�suppress_warnings�assert_string_equal�assert_�tempdir�temppath�assert_no_gc_cycles�HAS_REFCOUNT)�ARRAY_FUNCTION_ENABLEDc@�LeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�_GenericTestcCs|�||�dS�N��_assert_func��self�a�b�r"�@/usr/lib/python3/dist-packages/numpy/testing/tests/test_utils.py�_test_equal�z_GenericTest._test_equalcCs:tt��|�||�Wd�dS1swYdSr)r	�AssertionErrorrrr"r"r#�_test_not_equals
"�z_GenericTest._test_not_equalcCs,t�ddg�}t�ddg�}|�||�dS)z/Test two equal array of rank 1 are found equal.��N��np�arrayr$rr"r"r#�test_array_rank1_eq�z _GenericTest.test_array_rank1_eqcCs,t�ddg�}t�ddg�}|�||�dS)z7Test two different array of rank 1 are found not equal.r(r)N�r+r,r'rr"r"r#�test_array_rank1_noteq$r.z#_GenericTest.test_array_rank1_noteqcCs<t�ddgddgg�}t�ddgddgg�}|�||�dS)z/Test two equal array of rank 2 are found equal.r(r)��Nr*rr"r"r#�test_array_rank2_eq+sz _GenericTest.test_array_rank2_eqcCs4t�ddg�}t�ddgddgg�}|�||�dS)�:Test two arrays with different shapes are found not equal.r(r)Nr/rr"r"r#�test_array_diffshape2sz!_GenericTest.test_array_diffshapecCs"tjddgtd�}|�|d�dS)zTest object arrays.r(��dtypeN)r+r,�objectr$�rr r"r"r#�
test_objarray9sz_GenericTest.test_objarraycCs|�gd�d�dS)N�r(r)r1)r$�rr"r"r#�test_array_likes>�z_GenericTest.test_array_likesN)�__name__�
__module__�__qualname__r$r'r-r0r3r5r:r=r"r"r"r#rsrc@sneZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zej
jedd�dd��ZdS)�TestArrayEqualcC�
t|_dSr)rrr<r"r"r#�setupD�
zTestArrayEqual.setupc�4�fdd�}dD]}||�qdD]}||�qdS)z!Test rank 1 array for all dtypes.c�Lt�d|�}|�d�|��}|��}|�d���||���||�dS)Nr)r(r�r+�empty�fill�copyr$r'��tr r!�cr<r"r#�fooI�

z.TestArrayEqual.test_generic_rank1.<locals>.foo�?bhilqpBHILQPfdgFDG��S1�U1Nr"�rrOrMr"r<r#�test_generic_rank1G�


�z!TestArrayEqual.test_generic_rank1cCslt�d�}t�d�}tt|j||�|}|�||�t�d�}t�d�}tt|j||�|}|�||�dS)NlCj�<T"3��w�
�-l(M$c7u��v��+�
)r+r,r	r&r�r�x�yr"r"r#�test_0_ndim_arrayZs



z TestArrayEqual.test_0_ndim_arraycrF)z!Test rank 3 array for all dtypes.crG)N)r2r)r1r(rrHrLr<r"r#rOkrPz.TestArrayEqual.test_generic_rank3.<locals>.foorQrRNr"rUr"r<r#�test_generic_rank3irWz!TestArrayEqual.test_generic_rank3cCsNt�ddtjg�}t�ddtjg�}|�||�t�gd��}|�||�dS)z$Test arrays with nan values in them.r(r)r;N)r+r,�nanr$r'�rr r!rNr"r"r#�test_nan_array|s
zTestArrayEqual.test_nan_arraycCsFt�ddg�}t�ddg�}|�||�t�ddg�}|�||�dS)r4�floupi�floupa�floupipiN)r+r,r$r'r`r"r"r#�test_string_arrays�s
z!TestArrayEqual.test_string_arrayscCs�t�ddtfdtfg�}ddg|d<ddg|d<|��}|�||�t�ddtfdtfg�}|d��|d<|d��|d<t��}|jtdd�}|�||�t	t
|�d�Wd�dS1sawYdS)	zTest record arrays.r)rbrcr(rdzelementwise == ��messageN)r+rI�floatrKr$r�record�
FutureWarningr'r�len)rr r!rN�sup�lr"r"r#�test_recarrays�s"�zTestArrayEqual.test_recarrayscCs�tjjgd�gd�d�}t�dtjdg�}|�||�|�||�tjjgd�gd�d�}t�tjddg�}|�||�|�||�dS)N��@�@�@)FTF��maskrprr)TFFrq)r+�ma�MaskedArrayr,r_r$�infrr"r"r#�test_masked_nan_inf�sz"TestArrayEqual.test_masked_nan_infcCs�Gdd�dtj�}t�ddg��|�}t�ddg��|�}tt||k�t�t||k�t||k�|�||�|�||�|�||�dS)Nc@�eZdZdd�Zdd�ZdS)z?TestArrayEqual.test_subclass_that_overrides_eq.<locals>.MyArraycSstt�||����Sr)�boolr+�equal�all�r�otherr"r"r#�__eq__�r>zFTestArrayEqual.test_subclass_that_overrides_eq.<locals>.MyArray.__eq__cSs
||kSrr"r}r"r"r#�__ne__�rEzFTestArrayEqual.test_subclass_that_overrides_eq.<locals>.MyArray.__ne__N)r?r@rArr�r"r"r"r#�MyArray�sr���?�@rp)	r+�ndarrayr,�viewr�typerzr$r'�rr�r r!r"r"r#�test_subclass_that_overrides_eq�sz.TestArrayEqual.test_subclass_that_overrides_eqzrequires __array_function__��reasoncCs�Gdd�dtj�}t�ddg��|�}t�ddg��|�}tt��
t�|�Wd�n1s1wY|�||�|�||�|�||�dS)Nc@�eZdZdd�ZdS)zKTestArrayEqual.test_subclass_that_does_not_implement_npall.<locals>.MyArrayc_stSr)�NotImplemented�r�args�kwargsr"r"r#�__array_function__��z^TestArrayEqual.test_subclass_that_does_not_implement_npall.<locals>.MyArray.__array_function__N)r?r@rAr�r"r"r"r#r���r�r�r�rp)	r+r�r,r�r	�	TypeErrorr|r$r'r�r"r"r#�+test_subclass_that_does_not_implement_npall�s
�z:TestArrayEqual.test_subclass_that_does_not_implement_npallN)r?r@rArDrVr]r^rarernrxr��pytest�mark�skipifrr�r"r"r"r#rBBs
�rBc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestBuildErrorMessagecCs@t�gd��}t�gd��}d}t||g|�}d}t||�dS)N�gr�Z|
�?�r�Z|
@�&��@�g㈵��?�&��@�㈵�@�There is a mismatchz�
Items are not equal: There is a mismatch
 ACTUAL: array([1.00001, 2.00002, 3.00003])
 DESIRED: array([1.00002, 2.00003, 3.00004])�r+r,rr�rr[r\�err_msgr r!r"r"r#�test_build_err_msg_defaults�sz1TestBuildErrorMessage.test_build_err_msg_defaultscC�Dt�gd��}t�gd��}d}t||g|dd�}d}t||�dS)Nr�r�r�F)�verbosez)
Items are not equal: There is a mismatchr�r�r"r"r#�test_build_err_msg_no_verbose�sz3TestBuildErrorMessage.test_build_err_msg_no_verbosecCr�)Nr�r�r�)�FOO�BAR)�namesz{
Items are not equal: There is a mismatch
 FOO: array([1.00001, 2.00002, 3.00003])
 BAR: array([1.00002, 2.00003, 3.00004])r�r�r"r"r#�test_build_err_msg_custom_names��z5TestBuildErrorMessage.test_build_err_msg_custom_namescCr�)N)g0�D�?r�r�)g_p��?r�r�r�rY)�	precisionz�
Items are not equal: There is a mismatch
 ACTUAL: array([1.000000001, 2.00002    , 3.00003    ])
 DESIRED: array([1.000000002, 2.00003    , 3.00004    ])r�r�r"r"r#�#test_build_err_msg_custom_precision�r�z9TestBuildErrorMessage.test_build_err_msg_custom_precisionN)r?r@rAr�r�r�r�r"r"r"r#r��s
	r�c@�\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�	TestEqualcCrCr)rrr<r"r"r#rDrEzTestEqual.setupcCsH|�tjtj�|�tjgtjg�|�tjtjg�|�tjd�dS�Nr()rr+r_r'r<r"r"r#�test_nan_itemsszTestEqual.test_nan_itemscCs:|�tjtj�|�tjgtjg�|�tjtjg�dSr)rr+rwr'r<r"r"r#�test_inf_itemsszTestEqual.test_inf_itemscCst|�t�dd�t�dd��|�t�dd�t�dd��|�t�dd�t�dd��|�t�dd�t�dd��dS)N�
2017-01-01�s�mz
2017-01-02)r$r+�
datetime64r'r<r"r"r#�
test_datetimes 

�

�

�

�zTestEqual.test_datetimecCstt�d�}t�dd�}t�dd�}t�d�}t�dd�}t�dd�}|||g}|||g}t�||�D]\}	}
|�|	|
�|�|	g|
g�|�|	g|
�q2t�||�D]\}	}
|�|	|
�|�|	g|
g�|�|	g|
�qRt�||�D]E\}	}
|�|	|
�|�|	|
g�|�|	g|
g�|�|	gt�dd��|�|
gt�dd��|�|	gt�dd��|�|
gt�dd��qrdS)N�NaTr��nsr��{)r+r��timedelta64�	itertools�productrr')r�nadt_no_unit�nadt_s�nadt_d�natd_no_unit�natd_s�natd_d�dts�tdsr r!r"r"r#�test_nat_items$s2



�zTestEqual.test_nat_itemscCs|�dd�|�dd�dS)N�ab�abb)rr'r<r"r"r#�test_non_numericCszTestEqual.test_non_numericcCs�|�tdd�tdd��|�tdtj�tdtj��|�tdtj�tdd��|�ttjd�tdtj��|�ttjtj�ttjd��dS�Nr(r))r�complexr+r_r'rwr<r"r"r#�test_complex_itemGs
"zTestEqual.test_complex_itemcCs|�tjtj�dSr)r'r+�PZERO�NZEROr<r"r"r#�test_negative_zeroNr>zTestEqual.test_negative_zerocCsRt�tdd�tdtj�g�}t�tdd�tdd�g�}|�||�|�||�dSr��r+r,r�r_rr'rZr"r"r#�test_complexQszTestEqual.test_complexcCsDddl}t�|�ddd�|�ddd�g�}|�||ddd��dS)Nri�r(r)���)�datetimer+r,r')rr�r r"r"r#�test_objectWs
�zTestEqual.test_objectN)
r?r@rArDr�r�r�r�r�r�r�r�r�r"r"r"r#r�sr�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestArrayAlmostEqualcCrCr)rrr<r"r"r#rDarEzTestArrayAlmostEqual.setupc�L�jdddd�tt�fdd���jdgdgdd�tt�fdd��dS)N���?�r��decimalc��jdddd�S�Ng�?r�rr�rr"r<r"r#�<lambda>n�z5TestArrayAlmostEqual.test_closeness.<locals>.<lambda>c��jdgdgdd�Sr�rr"r<r"r#r�s��rr	r&r<r"r<r#�test_closenessd�
�
�z#TestArrayAlmostEqual.test_closenesscsRt�dg��t�dg���j��dd��j��dd�tt���fdd��dS)Ng��e��H�@g�w���H�@r1r�r2c��j��dd�S)N�r�rr"rZr"r#r�|r�z2TestArrayAlmostEqual.test_simple.<locals>.<lambda>�r+r,rr	r&r<r"rZr#�test_simpleus�z TestArrayAlmostEqual.test_simplecszt�tjg��t�dg��t�tjg�������tt���fdd��tt���fdd��tt���fdd��dS)Nr(c������Srrr"��anan�aonerr"r#r���z/TestArrayAlmostEqual.test_nan.<locals>.<lambda>c������Srrr"��ainfr�rr"r#r��r�cr�rrr"r�r"r#r��r��r+r,r_rwrr	r&r<r"�r�r�r�rr#�test_nan~s���zTestArrayAlmostEqual.test_nancsdt�ddgddgg������tj�d<tt���fdd��tj�d<tt���fdd��dS)	Nr�r�rprq)rrcr�rrr"�r r!rr"r#r��r�z/TestArrayAlmostEqual.test_inf.<locals>.<lambda>cr�rrr"r�r"r#r��r�)r+r,rKrwr	r&r<r"r�r#�test_inf�s
��zTestArrayAlmostEqual.test_infcCs@t�ddgddgg�}tj�ddgddggddgddgg�}|�||�|�||�|�||�tjjddd	�}t�gd
��}|�||�|�||�tjj}t�gd
��}|�||�|�||�tjjgd
�gd�d	�}t�gd��}|�||�|�||�tjjgd
�gd�d	�}t�d�}|�||�|�||�dS)
Nr�r�rprqr�FTg@rsro)TTT)r�r�rp)r+r,ru�masked_arrayrrvr$�maskedrr"r"r#�
test_subclass�s.�
z"TestArrayAlmostEqual.test_subclasscC�6Gdd�dtj�}t�ddg��|�}|�||�dS)Nc�0eZdZ�fdd�Z�fdd�Zdd�Z�ZS)zGTestArrayAlmostEqual.test_subclass_that_cannot_be_bool.<locals>.MyArrayc�t��|��tj�Sr��superrr�r+r�r}��	__class__r"r#r�r>zNTestArrayAlmostEqual.test_subclass_that_cannot_be_bool.<locals>.MyArray.__eq__cr�r�r��__lt__r�r+r�r}r�r"r#r�r>zNTestArrayAlmostEqual.test_subclass_that_cannot_be_bool.<locals>.MyArray.__lt__c_�t�r��NotImplementedErrorr�r"r"r#r|�r�zKTestArrayAlmostEqual.test_subclass_that_cannot_be_bool.<locals>.MyArray.all�r?r@rArrr|�
__classcell__r"r"r�r#r���r�r�r��r+r�r,r�r�rr�r r"r"r#�!test_subclass_that_cannot_be_bool��
z6TestArrayAlmostEqual.test_subclass_that_cannot_be_boolN)
r?r@rArDr�r�r�r�r�r	r"r"r"r#r�_s	
r�c@r�)�TestAlmostEqualcCrCr)rrr<r"r"r#rD�rEzTestAlmostEqual.setupcr�)Nr�r�rr�cr�r�rr"r<r"r#r��r�z0TestAlmostEqual.test_closeness.<locals>.<lambda>cr�r�rr"r<r"r#r��r�r�r<r"r<r#r��r�zTestAlmostEqual.test_closenesscsJ��tjtj�tt�fdd��tt�fdd��tt�fdd��dS)Nc���tjd�Sr�)rr+r_r"r<r"r#r���z/TestAlmostEqual.test_nan_item.<locals>.<lambda>c���tjtj�Sr)rr+r_rwr"r<r"r#r��r�crr)rr+rwr_r"r<r"r#r��r�)rr+r_r	r&r<r"r<r#�
test_nan_item�s
�
�
�zTestAlmostEqual.test_nan_itemcsL��tjtj���tjtj�tt�fdd��tt�fdd��dS)Ncrr��rr+rwr"r<r"r#r��r
z/TestAlmostEqual.test_inf_item.<locals>.<lambda>cs��tjtj�Srrr"r<r"r#r��s)rr+rwr	r&r<r"r<r#�
test_inf_item�s
�
�zTestAlmostEqual.test_inf_itemcCs|�dd�dSr�)r'r<r"r"r#�test_simple_item�r%z TestAlmostEqual.test_simple_itemcCs�|�tdd�tdd��|�tdtj�tdtj��|�ttjtj�ttjtj��|�tdtj�tdd��|�ttjd�tdtj��|�ttjtj�ttjd��dSr�)rr�r+r_rwr'r<r"r"r#r��s "z!TestAlmostEqual.test_complex_itemcCszt�tdd�tdtj�g�}t�tdd�ttjd�g�}t�tdd�tdd�g�}|�||�|�||�|�||�dSr�r�)rr[�zr\r"r"r#r��szTestAlmostEqual.test_complexcCsvt�gd��}t�gd��}t�t��}|j||dd�Wd�n1s&wYt|j��d�}t	|dd�t	|d	d
�t	|dd�t	|d
d�t	|dd�t�t��}|�||�Wd�n1slwYt|j��d�}t	|dd�t	|d	d
�t	|dd�t	|d
d�t	|dd�t�tj
dg�}t�tj
dg�}t�t��}|�||�Wd�n1s�wYt|j��d�}t	|dd�t	|d	d�t	|dd�t	|d
d�t	|dd�t�ddg�}t�ddg�}t�t��}|�||�Wd�n	1�swYt|j��d�}t	|dd�t	|d	d�t	|dd�dS)z�Check the message is formatted correctly for the decimal value.
           Also check the message when input includes inf or nan (gh12200))g��?g�@r�)g�_�?g�@r��r�N�
r1z!Mismatched elements: 3 / 3 (100%)r2zMax absolute difference: 1.e-05r�z'Max relative difference: 3.33328889e-06�z8 x: array([1.00000000001, 2.00000000002, 3.00003      ])�z8 y: array([1.00000000002, 2.00000000003, 3.00004      ])z"Mismatched elements: 1 / 3 (33.3%)z& x: array([1.     , 2.     , 3.00003])z& y: array([1.     , 2.     , 3.00004])rr(z Mismatched elements: 1 / 2 (50%)�Max absolute difference: 1.�Max relative difference: 1.z x: array([inf,  0.])z y: array([inf,  1.])r)z!Mismatched elements: 2 / 2 (100%)zMax absolute difference: 2zMax relative difference: inf)r+r,r�rr&r�str�value�splitrrw�rr[r\�exc_info�msgsr"r"r#�test_error_message�s\������z"TestAlmostEqual.test_error_messagecCsd}t�d�}t�t��}|�||�Wd�n1swYt|j��d�}t	|dd�t	|dd�t	|d	d
�d}t�d�}t�t��}|�||�Wd�n1s\wYt|j��d�}t	|dd�t	|dd�t	|d	d�dS)zHCheck the message is formatted correctly when either x or y is a scalar.r)�Nrr1z#Mismatched elements: 20 / 20 (100%)r2rr�r�Max relative difference: 0.5)
r+�onesr�rr&rrrrrrr"r"r#�test_error_message_21s$
�
�z$TestAlmostEqual.test_error_message_2cCr�)Ncr�)zBTestAlmostEqual.test_subclass_that_cannot_be_bool.<locals>.MyArraycr�rr�r}r�r"r#rKr>zITestAlmostEqual.test_subclass_that_cannot_be_bool.<locals>.MyArray.__eq__cr�rr�r}r�r"r#rNr>zITestAlmostEqual.test_subclass_that_cannot_be_bool.<locals>.MyArray.__lt__c_rrrr�r"r"r#r|Qr�zFTestAlmostEqual.test_subclass_that_cannot_be_bool.<locals>.MyArray.allrr"r"r�r#r�Jrr�r�r�rrr"r"r#r	Er
z1TestAlmostEqual.test_subclass_that_cannot_be_boolN)
r?r@rArDr�rrrr�r�r r$r	r"r"r"r#r�s	6rc@�4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestApproxEqualcCrCr)r
rr<r"r"r#rDZrEzTestApproxEqual.setupcsNt�d��t�d���j��dd��j��dd�tt���fdd��dS)N�{�G�H�@�R���H�@r���significantrcr��Nrr)rr"rZr"r#r�dr�z7TestApproxEqual.test_simple_0d_arrays.<locals>.<lambda>r�r<r"rZr#�test_simple_0d_arrays]s

�z%TestApproxEqual.test_simple_0d_arrayscsRd�d��j��dd��j��dd��j��dd�tt���fdd��dS)	Nr'r(r2r)r�rcr�r+rr"rZr"r#r�nr�z3TestApproxEqual.test_simple_items.<locals>.<lambda>r�r<r"rZr#�test_simple_itemsfs�z!TestApproxEqual.test_simple_itemsc�tt�tj��t�d��t�tj�������tt���fdd��tt���fdd��tt���fdd��dS)Nr(cr�rrr"r�r"r#r�ur�z0TestApproxEqual.test_nan_array.<locals>.<lambda>cr�rrr"r�r"r#r�vr�cr�rrr"r�r"r#r�wr�r�r<r"r�r#rap�
zTestApproxEqual.test_nan_arraycr.)Nr(cr�rrr"r�r"r#r�~r�z0TestApproxEqual.test_nan_items.<locals>.<lambda>cr�rrr"r�r"r#r�r�cr�rrr"r�r"r#r��r�r�r<r"r�r#r�yr/zTestApproxEqual.test_nan_itemsN)r?r@rArDr,r-rar�r"r"r"r#r&Xs	
	r&c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestArrayAssertLesscCrCr)rrr<r"r"r#rD�rEzTestArrayAssertLess.setupcs|t�ddg��t�ddg�������tt���fdd��t�ddg��tt���fdd��tt���fd	d��dS)
N皙�����?皙����@�333333�?�ffffff@c������Srrr"rZr"r#r��r�z8TestArrayAssertLess.test_simple_arrays.<locals>.<lambda>r�c������Srrr"rZr"r#r��r�cr5rrr"rZr"r#r��r�r�r<r"rZr#�test_simple_arrays�sz&TestArrayAssertLess.test_simple_arrayscs�t�ddgddgg��t�ddgddgg�������tt���fd	d
��t�ddgddgg��tt���fdd
��tt���fd
d
��dS)Nr1r2�ffffff
@g������@r3r4g333333@g@cr5rrr"rZr"r#r��r�z0TestArrayAssertLess.test_rank2.<locals>.<lambda>r�cr6rrr"rZr"r#r��r�cr5rrr"rZr"r#r��r�r�r<r"rZr#�
test_rank2�szTestArrayAssertLess.test_rank2csvtjdd��tjdd�d������tt���fdd��d�d<tt���fdd��tt���fd	d��dS)
N)r)r)r))�shaper(cr5rrr"rZr"r#r��r�z0TestArrayAssertLess.test_rank3.<locals>.<lambda>r)rrrcr6rrr"rZr"r#r��r�cr5rrr"rZr"r#r��r�)r+r#rr	r&r<r"rZr#�
test_rank3�szTestArrayAssertLess.test_rank3cs�d�d������tt���fdd��t�ddg�������tt���fdd��t�ddg��tt���fdd��dS)	Nr1r2cr5rrr"rZr"r#r��r�z7TestArrayAssertLess.test_simple_items.<locals>.<lambda>r8cr5rrr"rZr"r#r��r�r�cr6rrr"rZr"r#r��r�)rr	r&r+r,r<r"rZr#r-�sz%TestArrayAssertLess.test_simple_itemscs�t�tj��t�d��t�tj�������tt���fdd��tt���fdd��tt���fdd��tt���fdd��dS)Nr(cr�rrr"r�r"r#r��r�z9TestArrayAssertLess.test_nan_noncompare.<locals>.<lambda>cr�rrr"r�r"r#r��r�cr�rrr"r�r"r#r��r�cr�rrr"r�r"r#r��r�r�r<r"r�r#�test_nan_noncompare�s
z'TestArrayAssertLess.test_nan_noncomparecs�t�gd���t�tj��tt���fdd��tt���fdd��t�ddtjg��tt���fdd��tt���fdd��t�d	d
tjg�������tt���fdd��dS)N)r1r2r8c������Srrr"�r�rr[r"r#r��r�z?TestArrayAssertLess.test_nan_noncompare_array.<locals>.<lambda>c������Srrr"r>r"r#r��r�r1r2cr=rrr"r>r"r#r��r�cr?rrr"r>r"r#r��r�r�r�cr6rrr"rZr"r#r��r�)r+r,r_r	r&rr<r")r�rr[r\r#�test_nan_noncompare_array�sz-TestArrayAssertLess.test_nan_noncompare_arraycs�t�d��t�tj�����������������tt���fdd��tt���fdd��tt��fdd��tt��fdd��tt��fdd��dS)Nr(cr�rrr"�r�r�rr"r#r��r�z6TestArrayAssertLess.test_inf_compare.<locals>.<lambda>cs�����Srrr"rAr"r#r��r
cs�����Srrr"�r�rr"r#r��r�cs�����Srrr"rBr"r#r��r
cs�����Srrr"rBr"r#r��r�)r+r,rwrr	r&r<r"rAr#�test_inf_compare�s
z$TestArrayAssertLess.test_inf_comparecs�t�ddtjg��t�tj��tt���fdd��tt���fdd��tt���fdd��tt���fdd��tt���fdd�������dS)	Nr1r2cr=rrr"�r�rr[r"r#r��r�z<TestArrayAssertLess.test_inf_compare_array.<locals>.<lambda>cr?rrr"rDr"r#r��r�cs�����Srrr"rDr"r#r��r
cs�����Srrr"rDr"r#r��r�cs�����Srrr"rDr"r#r��r�)r+r,rwr	r&rr<r"rDr#�test_inf_compare_array�sz*TestArrayAssertLess.test_inf_compare_arrayN)r?r@rArDr7r9r;r-r<r@rCrEr"r"r"r#r0�s

r0z$The raises decorator depends on Noser�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
TestRaisescCsGdd�dt�}||_dS)Nc@�eZdZdS)z%TestRaises.setup.<locals>.MyExceptionN�r?r@rAr"r"r"r#�MyException��rI)�	Exception�e)rrIr"r"r#rD�s
zTestRaises.setupcCs|�rr")rrLr"r"r#�raises_exception�r�zTestRaises.raises_exceptioncC�dSrr"r<r"r"r#�does_not_raise_exception�r�z#TestRaises.does_not_raise_exceptioncCst|j�|j�|j�dSr)rrLrMr<r"r"r#�test_correct_catch�szTestRaises.test_correct_catchcCs4zt|j�|j�t�Wtd��tyYdSw)Nzshould have caught RuntimeError)rrLrM�RuntimeErrorr&r<r"r"r#�test_wrong_exceptions��zTestRaises.test_wrong_exceptioncCs2zt|j�|j��Wtd��tyYdSw)Nz$should have raised an AssertionError)rrLrOr&r<r"r"r#�test_catch_no_raise
s��zTestRaises.test_catch_no_raiseN)	r?r@rArDrMrOrPrRrSr"r"r"r#rF�srFc@s$eZdZdd�Zdd�Zdd�ZdS)�	TestWarnscCshdd�}tjdjdd�}ttt|�d�tjdj}ttt|�ttdd�d�d�t||d�dS)	NcSst�d�dS)N�yor1��warnings�warnr"r"r"r#�fs
zTestWarns.test_warn.<locals>.frWr1cSs|Srr")r[r"r"r#r��z%TestWarns.test_warn.<locals>.<lambda>r(�.assert_warns does not preserver warnings state)	�sys�modules�filtersrr
�UserWarningr	r&r)rrY�before_filters�
after_filtersr"r"r#�	test_warns�zTestWarns.test_warncCsttjdjdd�}tt��
t�d�Wd�n1swYtjdj}dd�}tt|�t	||d�dS)NrWrUcSs6t��t�d�Wd�dS1swYdS�NrU)rrWrXr"r"r"r#�no_warnings,s"�z3TestWarns.test_context_manager.<locals>.no_warningsr[)
r\r]r^r
r_rWrXr	r&r)rr`rardr"r"r#�test_context_manager%s
�
�zTestWarns.test_context_managerc	Csvdd�}d}t���!t�dt�z	tt|�d}Wn	ty#YnwWd�n1s.wY|r9td��dS)NcSst�dt�dSrc)rWrX�DeprecationWarningr"r"r"r#rY5r%z,TestWarns.test_warn_wrong_warning.<locals>.fF�errorTz#wrong warning caught by assert_warn)rW�catch_warnings�simplefilterrfr
r_r&)rrY�failedr"r"r#�test_warn_wrong_warning4s

���	�z!TestWarns.test_warn_wrong_warningN)r?r@rArbrerkr"r"r"r#rTsrTc@r)�TestAssertAllclosecCs�d}d}t||dd�ttt||�t�||||g�}t�||||g�}t||dd�ttt||�|d|d<t||�ttt||dd�tdd	d
d�tttd	dd
d�dS)Ng����MbP?g��&�.>r()�atolg�1��?r�)�rtolrrYg�?)rr	r&r+r,)rr[r\r r!r"r"r#r�Hs
zTestAssertAllclose.test_simplecCs*tjt�tj�jgtjd�}t||�dS)Nr6)r+r,�iinfo�int_�minrr9r"r"r#�test_min_int\szTestAssertAllclose.test_min_intcCsjt�gd��}t�gd��}t�t��
}t||�Wd�n1s#wYt|j�}td|v�dS)N)r(r(r(r()r(r(r(r)zXMismatched elements: 1 / 4 (25%)
Max absolute difference: 1
Max relative difference: 0.5�	r+r,r�rr&rrrr�rr r!r�msgr"r"r#�test_report_fail_percentageas�

�z.TestAssertAllclose.test_report_fail_percentagecCs.t�tjg�}t�tjg�}t||dd�dS)NT��	equal_nan)r+r,r_rrr"r"r#�test_equal_nanlsz!TestAssertAllclose.test_equal_nancCs2t�tjg�}t�tjg�}ttt||dd�dS)NFrw)r+r,r_r	r&rrr"r"r#�test_not_equal_nanrsz%TestAssertAllclose.test_not_equal_nancCsHt�tjg�}t�tjg�}t||�t||�t||�t||�dSr)r+r,r_rrrrrr"r"r#�test_equal_nan_defaultws


z)TestAssertAllclose.test_equal_nan_defaultcCsjt�ddg�}t�ddg�}t�t��
}t||�Wd�n1s#wYt|j�}td|v�dS)Nrr(r)r"rsrtr"r"r#�test_report_max_relative_error�s�
z1TestAssertAllclose.test_report_max_relative_errorcCs"tjgd�gdd�}t||�dS)N)r(r)r1r�zm8[ns]r6)r+r,rr9r"r"r#�test_timedelta�sz!TestAssertAllclose.test_timedeltaN)r?r@rAr�rrrvryrzr{r|r}r"r"r"r#rlFs	rlc@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�TestArrayAlmostEqualNulpcC�d}tjdddtjd�}d|}tj||f}t�|j�j}||||d}t|||�t�|j�j}||||d}t|||�dS�Nr����r!�2r6rYr��	r+�linspace�float64�r_�finfor7�epsr�epsneg�r�nulpr[r�r\r�r"r"r#�test_float64_pass�sz*TestArrayAlmostEqualNulp.test_float64_passcC�d}tjdddtjd�}d|}tj||f}t�|j�j}||||d}ttt	|||�t�|j�j
}||||d}ttt	|||�dSr��r+r�r�r�r�r7r�r	r&rr�r�r"r"r#�test_float64_fail����z*TestArrayAlmostEqualNulp.test_float64_failcC�Tt�d�}tjtjtjd��tj�}||A}|�tj�}|�tj�}t||d�dS)Nl��r6r)r+�uint64r,r_r�r�r)r�offset�nan1_i64�nan2_i64�nan1_f64�nan2_f64r"r"r#�test_float64_ignore_nan��
z0TestArrayAlmostEqualNulp.test_float64_ignore_nancCrr��	r+r��float32r�r�r7r�rr�r�r"r"r#�test_float32_pass��z*TestArrayAlmostEqualNulp.test_float32_passcCr�r��r+r�r�r�r�r7r�r	r&rr�r�r"r"r#�test_float32_fail�r�z*TestArrayAlmostEqualNulp.test_float32_failcCr�)Ni��r6r)r+�uint32r,r_r�r�r)rr��nan1_i32�nan2_i32�nan1_f32�nan2_f32r"r"r#�test_float32_ignore_nan�r�z0TestArrayAlmostEqualNulp.test_float32_ignore_nancCs�d}tjdddtjd�}d|}tj||f}t�|j�j}||||d}t|||�t�|j�j}||||d}t|||�dS�Nr����r2rYr6r�)	r+r��float16r�r�r7r�rr�r�r"r"r#�test_float16_pass�r�z*TestArrayAlmostEqualNulp.test_float16_passcCs�d}tjdddtjd�}d|}tj||f}t�|j�j}||||d}ttt	|||�t�|j�j
}||||d}ttt	|||�dSr�)r+r�r�r�r�r7r�r	r&rr�r�r"r"r#�test_float16_fail�r�z*TestArrayAlmostEqualNulp.test_float16_failcCr�)N�r6r)r+�uint16r,r_r�r�r)rr��nan1_i16�nan2_i16�nan1_f16�nan2_f16r"r"r#�test_float16_ignore_nanr�z0TestArrayAlmostEqualNulp.test_float16_ignore_nancC�$d}tjdddtjd�}d|}tj||f}||d}t�|j�j}||||d}t|||d|�t|||d|�||||d	}t|||d|�t�|j�j}||||d}t|||d|�t|||d|�||||d	}t|||d|�dS�
Nr�r�r!r�r6rY��?r�rqr��rr�r[�xir�r\r�r"r"r#�test_complex128_passs"z-TestArrayAlmostEqualNulp.test_complex128_passcC�4d}tjdddtjd�}d|}tj||f}||d}t�|j�j}||||d}ttt	|||d|�ttt	|||d|�||||}ttt	|||d|�t�|j�j
}||||d}ttt	|||d|�ttt	|||d|�||||}ttt	|||d|�dS�	Nr�r�r!r�r6rYr�r�r�r�r"r"r#�test_complex128_fail)s:������z-TestArrayAlmostEqualNulp.test_complex128_failcCr�r�r�r�r"r"r#�test_complex64_passFs"z,TestArrayAlmostEqualNulp.test_complex64_passcCr�r�r�r�r"r"r#�test_complex64_fail[s:������z,TestArrayAlmostEqualNulp.test_complex64_failN)r?r@rAr�r�r�r�r�r�r�r�r�r�r�r�r�r"r"r"r#r~�sr~c@r%)�TestULPcCstj�d�}t||dd�dS)NrYr��maxulp)r+�random�randnr)rr[r"r"r#�
test_equalyszTestULP.test_equalcC�Rt�d��tj�}|dtj�d��tj�7}t�tj�j}t|||dd�dS)NrY�{�G�z�?r!r�)	r+r#�astyper�r�r�r�r�r�rr[r�r"r"r#�test_single}�zTestULP.test_singlecCr�)NrYr���r�)	r+r#r�r�r�r�r�r�rr�r"r"r#�test_double�r�zTestULP.test_doublecCsLtjtjfD]}t�tjg��|�}t�t�|�jg�}t||dd�qdS)Nr�r�)	r+r�r�r,rwr�r��maxr)r�dtrw�bigr"r"r#r��s
�zTestULP.test_infcstjtjfD]}|tjkrd�nd�t�tjg��|��t�tjg��|��t�t�|�jg��t�t�|�j	g��t�tj
g��|��t�tjg��|��tt
���fdd��tt
���fdd��tt
���fdd��tt
���fdd��tt
���fdd��qdS)	Ng��.Ag��mBc�t���d�S�Nr��rr")rwr�r_r"r#r����z"TestULP.test_nan.<locals>.<lambda>cr�r�r�r")r�r�r_r"r#r��r�c�t���d�Sr�r�r")r�r_�tinyr"r#r��r�cr�r�r�r")r�r_�zeror"r#r��r�cr�r�r�r")r�r_�nzeror"r#r��r�)r+r�r�r,rwr�r_r�r�r�r�r�r	r&)rr�r")r�rwr�r_r�r�r�r#r��s4
������zTestULP.test_nanN)r?r@rAr�r�r�r�r�r"r"r"r#r�wsr�c@ry)�TestStringEqualcCsntdd�tdd�t�t��
}tdd�Wd�n1swYt|j�}t|d�ttdd��dS)N�hellozhello
multilinezfoo
barz	hello
barz%Differences in strings:
- foo
+ hellocS�
tdd�S)NrOr��rr"r"r"r#r���
z-TestStringEqual.test_simple.<locals>.<lambda>)rr�rr&rrrr	)rrrur"r"r#r��s

�

�zTestStringEqual.test_simplecCstdd�ttdd��dS)Nza+*bcSr�)N�aaaza+br�r"r"r"r#r��r�z,TestStringEqual.test_regex.<locals>.<lambda>)rr	r&r<r"r"r#�
test_regex�s
�zTestStringEqual.test_regexN)r?r@rAr�r�r"r"r"r#r��sr�cCstz|j}Wntyi}Ynwt|�}d|vr3|d8}tjdd�dkr-|dur,|}n|dur3|}t||�dS)N�versionr(r))r1r)�__warningregistry__�AttributeErrorrkr\�version_infor)�mod�n_in_context�py34�py37�	mod_warns�	num_warnsr"r"r#�assert_warn_len_equal�s
�
�r�cCsDGdd�d�}|�}t|dd�Gdd�d�}|�}t|dd�dS)Nc@rG)�/test_warn_len_equal_call_scenarios.<locals>.modNrHr"r"r"r#r��rJr�r)r�r�c@r�)r�cSsddd�|_dS)Nr(r))�warning1�warning2)r�r<r"r"r#�__init__�s�z8test_warn_len_equal_call_scenarios.<locals>.mod.__init__N)r?r@rAr�r"r"r"r#r��r�r))r�)r��mod_instr"r"r#�"test_warn_len_equal_call_scenarios�s�
�r�cCs0tjt}z|j��W|StyY|Swr)r\r]r?r��clearr���my_modr"r"r#�_get_fresh_mods
��r�cCsHt�}tt|di�i�t|gd��t�d�t�d�Wd�n1s'wYt|ji�t��t�d�t�d�Wd�n1sJwYt|ddd�t|gd��t�d�t�d�Wd�n1sqwYt|ddd�t��t�d�t�d�Wd�n1s�wYt|d	ddd
�dS)Nr�)r]�ignore�Some warningr(r�r�zAnother warningr))r�r�)	r�r�getattrrrWrirXr�r�r�r"r"r#�test_clear_and_catch_warnings
s,
�
�
�
�r�cCs�t�}tt|di�i�dd�}t|d�t��}|�t�|jtj	j
d�t�d�|�Wd�n1s8wYtt
|j�d�t|jdjjdd�t|ddd�t�}|j|d�|�
t�d�Wd�n1sswYt|d�|j|d�|�
t�d�Wd�n1s�wYt|d�t��t�d	�t�d�Wd�n1s�wYt|ddd�dS)
Nr�cS�dd�}t�|ddg�dS)NcS�tjddd�|S)NzSome warning 2r)��
stacklevelrV��arrr"r"r#rX1�zFtest_suppress_warnings_module.<locals>.warn_other_module.<locals>.warnr�r+�apply_along_axis�rXr"r"r#�warn_other_module.�z8test_suppress_warnings_module.<locals>.warn_other_moduler��moduler�r(r�r�)r�rr�r�rrir_�filterr+�lib�
shape_baserWrXrk�logrgr�ri)r�rrlr"r"r#�test_suppress_warnings_module)s:
	

�	�
�

�r	cCs4t�}tt|di�i�t��}|�t�t�d�Wd�n1s$wYt|d�t�}|�t�|�
t�d�Wd�n1sHwYt|d�|j|d�|�
t�d�Wd�n1sjwYt|d�t��t�	d�t�d�Wd�n1s�wYt|ddd�dS)Nr�r�rrr�r(r�)
r�rr�rrr_rWrXr�ri)r�rlr"r"r#�test_suppress_warnings_typeWs.
�

�
�

�r
cCsvt�}|�t�|dd��}tjdd��}t�d�|t�|t�tt|�d�Wd�dS1s4wYdS)NcSst�d|�dS)Nr�rV)�categoryr"r"r#rXxsz7test_suppress_warnings_decorate_no_record.<locals>.warnT)ri�alwaysr()	rrr_rWrhri�RuntimeWarningrrk)rlrX�wr"r"r#�)test_suppress_warnings_decorate_no_recordts


"�rc	Cs�t�}|��}|�D|jdd�}|jdd�t�d�t�d�t�d�tt|j�d�tt|�d�tt|�d�t|djj	dd�Wd�n1sPwY|�D|jdd�}|jdd�t�d�t�d�t�d�tt|j�d�tt|�d�tt|�d�t|djj	dd�Wd�n1s�wYt��@}|��t�� }|jdd�t�d�t�d�tt|j�d�Wd�n1s�wYtt|j�d�Wd�dS1s�wYdS)NzSome other warning 2rfr��Some other warningr)r(r)
rrirrWrXrrkrrgr�)rl�log1�log2�sup2r"r"r#�test_suppress_warnings_record�sD


�



�


�"�rc	Cs2dd�}t��4}|��td��td�D]}t�d�qWd�n1s'wYtt|j�d�Wd�n1s>wYt��9}|��td��td�D]}t�d�t�d�qTWd�n1skwYtt|j�d�Wd�n1s�wYt��<}|��td��td�D]}t�d�t�d�|�q�Wd�n1s�wYtt|j�d�Wd�n1s�wYt��=}|��td��td�D]}t�d�t�d	�|�q�Wd�n1s�wYtt|j�d�Wd�dS1�swYdS)
NcSr�)NcSr�)Nr�r)r�rVr�r"r"r#rX�r�zJtest_suppress_warnings_forwarding.<locals>.warn_other_module.<locals>.warnrr�rr"r"r#r�rz<test_suppress_warnings_forwarding.<locals>.warn_other_modulerr)r��locationr�oncer)rri�rangerWrXrrkr)rrl�ir"r"r#�!test_suppress_warnings_forwarding�sT
���

���	


���



��$�rc	Cs�t��$}tj�|d�}t|d��Wd�n1swYWd�n1s*wYttj�|��d}zt��}t��1sEwYWntyVd}Ynwt|�ttj�|��dS)N�tmprFT)r�os�path�join�openr�isdir�
ValueError)�tdir�fpath�raisedr"r"r#�test_tempdir�s$�����r$c	Cs�t��}t|d��Wd�n1swYWd�n1s#wYttj�|��d}zt��}t��1s>wYWntyOd}Ynwt|�ttj�|��dS)NrFT)rrrrr�isfiler )r"r#r"r"r#�
test_temppath�s"�����r&c@seZdZejefZdS)�my_cacwN)r?r@rAr\r]�
class_modulesr"r"r"r#r'�sr'cCsPt�}t��t�d�t�d�Wd�n1swYt|ji�dS)Nr�r�)r�r'rWrirXrr�r�r"r"r#�%test_clear_and_catch_warnings_inherits
�r)zPython lacks refcountsc@s0eZdZdZdd�Zdd�Zejjdd��Z	dS)	�TestAssertNoGcCyclesz Test assert_no_gc_cycles cCs@dd�}t��|�Wd�n1swYt|�dS)NcSsg}|�g�|Sr��append)r!r"r"r#�no_cycle
s
z2TestAssertNoGcCycles.test_passes.<locals>.no_cycle)r)rr-r"r"r#�test_passess
�z TestAssertNoGcCycles.test_passesc	Cs�dd�}tt��t��|�Wd�n1swYWd�n1s)wYtt��
t|�Wd�dS1sBwYdS)NcSsg}|�|�|�|�|Srr+)r r"r"r#�
make_cycles

z5TestAssertNoGcCycles.test_asserts.<locals>.make_cycle)r	r&r)rr/r"r"r#�test_assertss
���

"�z!TestAssertNoGcCycles.test_assertscs�G�fdd�d��zCt����}ztt��tdd��Wd�n1s&wYWnty@|�dur>t�d��YnwWd�_dSWd�_dSd�_w)z�
        Test that in cases where the garbage cannot be collected, we raise an
        error, instead of hanging forever trying to clear it.
        cs(eZdZdZdZdd�Z�fdd�ZdS)z<TestAssertNoGcCycles.test_fails.<locals>.ReferenceCycleInDelz�
            An object that not only contains a reference cycle, but creates new
            cycles whenever it's garbage-collected and its __del__ runs
            TcSs
||_dSr)�cycler<r"r"r#r�3rEzETestAssertNoGcCycles.test_fails.<locals>.ReferenceCycleInDel.__init__csd|_�jr��dSdSr)r1r/r<��ReferenceCycleInDelr"r#�__del__6s
�zDTestAssertNoGcCycles.test_fails.<locals>.ReferenceCycleInDel.__del__N)r?r@rA�__doc__r/r�r4r"r2r"r#r3,s
r3cSrNrr"r"r"r"r#r�DrZz1TestAssertNoGcCycles.test_fails.<locals>.<lambda>Nz*GC does not call __del__ on cyclic objectsF)	�weakref�refr	rQrr&r��skipr/)rrr"r2r#�
test_fails%s$
��

���
	�zTestAssertNoGcCycles.test_failsN)
r?r@rAr5r.r0r�r��slowr9r"r"r"r#r*	sr*)NN)@rWr\rr�r�r6�numpyr+�
numpy.testingrrrrrrrr	r
rrr
rrrrrrrrrr�numpy.core.overridesrrrBr�r�r�rr&r0r�r8rFrTrlr~r�r�r�r�r�r�r	r
rrrr$r&r'r)r�r*r"r"r"r#�<module>sT`.-_b+m"3Kg8
".(/	

https://t.me/RX1948 - 2025