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_arraysetops.cpython-310.pyc
o

6��a
o�@stdZddlZddlmZmZmZmZddlm	Z	m
Z
mZmZm
Z
mZmZmZddlZGdd�d�ZGdd�d�ZdS)	z-Test functions for 1D array set operations.

�N)�assert_array_equal�assert_equal�
assert_raises�assert_raises_regex)�ediff1d�intersect1d�setxor1d�union1d�	setdiff1d�unique�in1d�isinc
@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	�
dejgd�ej
d
�dejdfejgd�ej
d
�ejgd�ejd
�ddfejgd�ejd
�ejejdfg�dd��Zej	�
dejgd�ejd
�ddejgd�ejd
�fejgd�ejd
�ejdgejd
�dejgd�ejd
�fejgd�ejd
�ddejgd�ejd
�fejgd�ej
d
�ddejgd�ej
d
�fg�d d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z d8d9�Z!d:d;�Z"d<d=�Z#d>d?�Z$dS)@�
TestSetOpscCs�t�gd��}t�gd��}t�gd��}t||dd�}t||�t�gd��}t�gd��}t�gd��}t||�}t||�tgtgg��dS)N������r��rr)rrrT��
assume_unique)rrrrr)rrrrrrr)�np�arrayrr)�self�a�b�ec�c�ed�r!�B/usr/lib/python3/dist-packages/numpy/lib/tests/test_arraysetops.py�test_intersect1ds


zTestSetOps.test_intersect1dcCsLGdd�d�}|�}t||�}t||�tgd�gd��}t|gd��dS)Nc@seZdZdd�ZdS)z4TestSetOps.test_intersect1d_array_like.<locals>.TestcSs
t�d�S)Nr)r�arange�rr!r!r"�	__array__%s
z>TestSetOps.test_intersect1d_array_like.<locals>.Test.__array__N)�__name__�
__module__�__qualname__r&r!r!r!r"�Test$sr*�rrr)rr)rr*r�resr!r!r"�test_intersect1d_array_like"s

z&TestSetOps.test_intersect1d_array_likecCs�t�gd��}t�gd��}t||ddd�\}}}t�gd��}t||�t|||�t|||�t�gd��}t�gd��}t||dd�\}}}t�gd��}t||�t|||�t|||�t�gd	�gd
�g�}t�gd�gd�g�}t||ddd�\}}}t�||j�}t�||j�}	t�gd
��}
t|
||�t|
||	�t�gd�gd�g�}t�gd�gd�g�}t||dd�\}}}t�||j�}t�||j�}	t�gd��}
t|
||�t|
||	�dS)N�rrrr)rrr�T)r�return_indices)rrr)rrrrrrr)r�rrrrrr)r0)rrrr/)rr1r�)rrrr/)�
�r1�	)rr/rr1)rrrr/r/)rrr1rr)rrrr)r3r4r1r)rrr1)rrrr�
unravel_index�shape)rrrr�i1�i2�ee�ef�ui1�ui2�ear!r!r"�test_intersect1d_indices.s<

z#TestSetOps.test_intersect1d_indicescCs�t�gd��}t�gd��}t�gd��}t||�}t||�t�gd��}t�gd��}t�gd��}t||�}t||�t�gd��}t�gd��}t�gd��}t||�}t||�tgtgg��dS)	Nrr)rrrr+)r/rr)rrrrrr/)rr1rr)r/rrr1)rrrr�rrrrrr!r!r"�
test_setxor1dUs 





zTestSetOps.test_setxor1dcCs,t�g�}t�dg�}t�ddg�}tgt|��tdgt|dd��tdgt|dd��tddgt|ddd��tgt|��tdgt|��tgd�t|d	d
d��tgd�t|dd
gd	dgd��tdd
gt|d
d��tgd�t|d	dgd��td	dgt|d	d��tgd�t|dd
gd��dS)Nrrr)�to_begin)�to_end���)rBrC)rrr5rr5)rr/rrr1rr/r1)rrr1)rr/r)rrrr)r�	zero_elem�one_elem�two_elemr!r!r"�test_ediff1dms"
�zTestSetOps.test_ediff1dzary, prepend, append, expectedr+��dtypeNrC)rrrrB)��?g@g"@cCsHd�|�}tt|��t|||d�Wd�dS1swYdS)Nz dtype of `{}` must be compatible��aryrCrB)�formatr�	TypeErrorr)rrM�prepend�append�expected�msgr!r!r"�!test_ediff1d_forbidden_type_casts�s
�"�z,TestSetOps.test_ediff1d_forbidden_type_castszary,prepend,append,expectedii)rrrrr)rrrr)rrrrr���)rrrrUcCs.tj|||d�}t||�|j|jksJ�dS)NrL)rrrrJ)rrMrPrQrR�actualr!r!r"�test_ediff1d_scalar_handling�s�
z'TestSetOps.test_ediff1d_scalar_handlingc	s�dd�}tj|tgdhd���fdd�}t�d��gd��}t�gd	�gd
�gd�g�}|||�dd
g}d}|||�t�d�}|||�|||�|||�|d|�||d�|dd�g}|||�|||�|||�dS)NcSst�|�����}||vS�N)r�asarray�flatten�tolist)rrr!r!r"�
_isin_slow�sz(TestSetOps.test_isin.<locals>._isin_slowr)�otypes�excludedcs"t||�}�||�}t||�dSrX)r
r)rr�x�y��	isin_slowr!r"�assert_isin_equal�s

z/TestSetOps.test_isin.<locals>.assert_isin_equal��rrr)r3��)rrr)���!)r5r1)rr/)r5rrrr/)r�	vectorize�boolr$�reshaper)	rr\rcrrr�d�fr_r!rar"�	test_isin�s(










zTestSetOps.test_isincCsdD]�}gd�}gd�|}t�gd��}t||dd�}t||�d|d<t�gd	��}t||dd�}t||�d
\|d<|d<t�gd��}t||dd�}t||�t�gd
��}gd�|}gd�}t||�}t||�|gd�|}gd�}t||�}t||�t�gd��}t�gd�|�}t�gd��}t||�}t||�t�gd��}t�gd�|�}t�gd��}t||�}t||�t�ddg�}t�ddg|�}t�ddg�}t||�}t||�qt�dg�}t�dg�}t�dg�}t||�}t||�ttgg�g�dS)N�rr3rr)TFTTTrr1r)FFTT)rr1r)TFTF�rrrrrrrrrrrrrrre)FTFTTTTTTFTFFF)rrr)TTTTTTTTTTTFTT)rrrrr)rrrrrr)TFTTTrrF�rrrr)r�multrrrrr!r!r"�	test_in1d�sX













zTestSetOps.test_in1dcCsBt�gd��}t�ddg�}t�gd��}t||�}t||�dS)N)rrrrn�errvrrr)TFTFFTFFrsr@r!r!r"�test_in1d_char_array+s

zTestSetOps.test_in1d_char_arraycCsHdD]}t�gd��}gd�|}tt�t||��t||dd��qdS)zTest in1d's invert parameterrqrrreT��invertN)rrrryr)rrtrrr!r!r"�test_in1d_invert4s
"�zTestSetOps.test_in1d_invertcCs�t�d��dd�}t�dd��dd�}t�dd��dd�}t�gd��}tt||dd	�|�tt||d
d	�|�tt||dd	�|�tt||d
d	�|�dS)Nr/rrr5�?rg)FFFTTTTrF)rr$rmrrr)rrr�long_brr!r!r"�test_in1d_ravel=szTestSetOps.test_in1d_ravelcCs<dg}t�dgd�}t�dg�}t�||�}t||�dS�Nrr3Frs�r�ar1�ar2rR�resultr!r!r"�test_in1d_first_array_is_objectJ�
z*TestSetOps.test_in1d_first_array_is_objectcCs:d}t�dgd�}t�dg�}t�||�}t||�dSr~rsrr!r!r"� test_in1d_second_array_is_objectQs
z+TestSetOps.test_in1d_second_array_is_objectcCs<dg}t�dgd�}t�dg�}t�||�}t||�dS)Nr3Trsrr!r!r"� test_in1d_both_arrays_are_objectXr�z+TestSetOps.test_in1d_both_arrays_are_objectcCs`t�dtfdtfg�}tjdg|d�}tjdgd|d�}t�dg�}t�||�}t||�dS)N�field1�field2)rNrIr3T)rrJ�int�objectrrr)r�dtr�r�rRr�r!r!r"�+test_in1d_both_arrays_have_structured_dtype_sz6TestSetOps.test_in1d_both_arrays_have_structured_dtypecCs`tjddgtd�}tjddgtd�}t�ddg�}t�||�}t||�tj||dd�}t|t�|��tjgd�td�}|dd�}tjgd�td�}|dd�}t�ddg�}t�||�}t||�tj||dd�}t|t�|��tjgd�td�}|dd�}tjddgtd�}t�dd	g�}t�||�}t||�tj||dd�}t|t�|��dS)
N�rrrITrx)r�)rrrrD)r��rrrF)rrr�rrryrr!r!r"�'test_in1d_with_arrays_containing_tuplesis0


z2TestSetOps.test_in1d_with_arrays_containing_tuplesc	Cs�t�gd��}t�gd��}t�gd��}t||�}t||�t�gd�gd�g�}t�gd��}t�gd��}t||�}t||�tgtgg��dS)N)rrrrr�rrrrrrr)rrrrrr)rrr)rrr)rrrrr)rrrrrr)rrr	r)	rrrrrr_r`�ez�zr!r!r"�test_union1d�s



zTestSetOps.test_union1dcCs�t�gd��}t�gd��}t�ddg�}t||�}t||�t�d�}t�d�}t�ddg�}t||�}t||�tgtgg��t�dtj�}tt|g�jtj�dS)	N)r/rrrrrrrr�r/r��rfr!)rrr
rr$�uint32rrJr@r!r!r"�test_setdiff1d�s





zTestSetOps.test_setdiff1dcCsFt�gd��}t�gd��}t�ddg�}t||dd�}t||�dS)N)rrr)rrrrrTr)rrr
r)rrrrRrVr!r!r"�test_setdiff1d_unique�s
z TestSetOps.test_setdiff1d_uniquecCs8t�gd��}t�gd��}tt||�t�dg��dS)N)rrr)rr�sr)rrrr
)rrrr!r!r"�test_setdiff1d_char_array�sz$TestSetOps.test_setdiff1d_char_arraycCsRt�gd��}t�gd��}t||�}t||�}t||�}t||�}t||�dS)N)rrrrr1)r5r1rrrrr)rrrrr	r
r)rrr�c1�aux1�aux2�c2r!r!r"�
test_manyways�s



zTestSetOps.test_manyways)%r'r(r)r#r-r?rArH�pytest�mark�parametrizerr�int64�nan�float32�int8rT�int16�float64�int32rWrprurwrzr}r�r�r�r�r�r�r�r�r�r�r!r!r!r"rs�'����
������
)<		

!rc@sfeZdZdd�Zdd�Zdd�Zdd�Zej�	d	d
dg�dd
��Z
dd�Zdd�Zdd�Z
dd�ZdS)�
TestUniquecCsddd�}gd�d}gd�}gd�}gd�d}t�gd�d�}g}|�tjd	�|�tjd
�|�d�|�d�|D]}t�||�}	t�||�}
||	|
||||�q>d
}t�t|�|�}	||	dd�<t�t|�|�}
||
dd�<||	|
||||�ddg}t�tt	||��|�}	t�tt	||��|�}
||	|
||||�gd�}	t
t�|	�ddg�gd�}gd�}gd�}t|�}
t
|
|�t|dd�\}}t
||�t
||�t�d�}d|d<tj|dd�\}}t
|t�
d��g}tj|dd�d}tj|dd�d}tj|ddd�dd�\}}t|jtj�t|jtj�t|jtj�t|jtj�dtjdtjg}ddtjg}gd�}gd �}gd!�}tt�|�|�ttj|dd�||f�ttj|dd�||f�ttj|dd"�||f�d#tjd$td%tj�tdtj�g}d$d#td%tj�g}gd&�}gd'�}gd(�}tt�|�|�ttj|dd�||f�ttj|dd�||f�ttj|dd"�||f�t�d)�}t�d*�|t�d+�|g}t�d+�t�d*�|g}gd�}gd �}gd!�}tt�|�|�ttj|dd�||f�ttj|dd�||f�ttj|dd"�||f�t�d)�}t�dd,�|t�dd-�|g}t�dd-�t�dd,�|g}gd�}gd �}gd!�}tt�|�|�ttj|dd�||f�ttj|dd�||f�ttj|dd"�||f�tjgd.}tjg}d/g}gd0�}d.g}tt�|�|�ttj|dd�||f�ttj|dd�||f�ttj|dd"�||f�dS)1Nc
Ss�d}|�d|�}t|�}t|||�|�d|�}t|ddd�\}}	t|||�t|	||�|�d|�}t|ddd�\}}	t|||�t|	||�|�d|�}t|ddd�\}}	t|||�t|	||�|�d|�}t|ddd�\}}
}t|||�t|
||�t|||�|�d	|�}t|ddd�\}}
}t|||�t|
||�t|||�|�d
|�}t|ddd�\}}
}t|||�t|
||�t|||�|�d|�}t|ddd�\}}
}}t|||�t|
||�t|||�t|||�dS)Nzcheck {0} failed for type {1}�values�return_indexTF�return_inverse�
return_countszreturn_index and return_inversezreturn_index and return_countsz return_inverse and return_countsz.return_index, return_inverse and return_counts)rNrr)
rrr8r9rr��base_msgrS�v�j�j1�j2�j3r!r!r"�	check_all�sN�z,TestUnique.test_unique_1d.<locals>.check_all)rrrrrrrr3)rrrr)rrrr)rrrrrrr)rrrr�
AllInteger�AllFloat�
datetime64[D]�timedelta64[D]�O)��i)��?��?�rr�r�)�rrr�r�r+)rrrrrrT)r�rr�.)r�r)r�r�g@rK)rrr)rrrr)rrr)r�y@�y�?�?�)rrr)rrrrr)rrr�natz
2020-12-26z
2020-12-24�D�hrr)rrrr)r�multiply�extend�	typecodesrQr�empty�len�list�ziprr�	chararray�zerosrrJ�intpr��complex�
datetime64�timedelta64)rr�rrr8r9r�typesr��aa�bb�unq�inv�a1�a2�a2_inv�a1_idx�a3_idx�a3_inv�ua�ua_idx�ua_inv�ua_cntr��all_nansr!r!r"�test_unique_1d�s�0





�� 

zTestUnique.test_unique_1dcCs\tt|jt�tt|jdtfdtfg�ttjtt�d�dd�ttjtt�d�dd�dS)Nrrr3r��axis���)	rrO�_run_axis_testsr�r�r�	AxisErrorrr$r%r!r!r"�test_unique_axis_errorsps�z"TestUnique.test_unique_axis_errorscCsZd}gd�gd�g}t�|�}tt|dd�t|dd�|�tt|dd�t|dd�|�dS)NzUnique failed on list of lists�rrrrr�r)rrYrr)rrS�inp�inp_arrr!r!r"�test_unique_axis_listxs

 z TestUnique.test_unique_axis_listcCsg}|�tjd�|�tjd�|�d�|�d�|�dtfdtfg�|�dtfdtfg�|D]}|�|�q4d}tjdtjd	��	d
d��
t�}tjdd
gd
d
ggtd	�}t
t|dd�||�d}t�ddgddgddgddgg�}t�ddgg�}t
t|dd�||�dS)Nr�r�r�r�rrz&Non-bitwise-equal booleans test failedr3rIrDrFTrr�z"Negative zero equality test failedg�r�)r�rr�rQr��floatr�r$�uint8rm�viewrlrrr)rr�rJrS�datar�r!r!r"�test_unique_axiss"

"zTestUnique.test_unique_axisr�rrDcCs,t�gd��}t||d�}t|gd��dS)N)rrrrrrrrr�r.�rrrr)rr�r_�uniqr!r!r"�test_unique_1d_with_axis�sz#TestUnique.test_unique_1d_with_axisc
CsRtjdtjd�}t|ddddd�\}}}}t|j|j�t|tjdd��t|t�dg��t|t�ddg��t|t�dg��t|d	dddd�\}}}}t|j|j�t|tjdd��t|t�g��t|t�g��t|t�g��d
}tj|d�}tt	|��D]"}t
|�}	||dkr�d|	|<nd	|	|<tt||d�tj|	d��q�dS)N)rr)r7rJrT�r�r�r�r�)rr)r7rr)rrrrrrrr�)rr�r�rrrJrr�ranger�r�)
r�single_zeror��idxr��cntr7�multiple_zerosr��expected_shaper!r!r"�test_unique_axis_zeros�s8��

��z!TestUnique.test_unique_axis_zeroscCshtjgd�dd�}tj�|d�}t�|�}tj|ddd�\}}}d}t|j|j|�t|j|j|�dS)N)�@rrrrr{r{rrrrrrr{rr�rIrT)r�r�z6Unique returned different results when asked for index)rr�ma�masked_equalrrr��mask)rr_r`r��v2r�rrSr!r!r"�test_unique_masked�s
�
zTestUnique.test_unique_maskedcCsDd}dD]}t�dgdgg|�}tj|dd�}t||||�qdS)Nz*sort order incorrect for integer type '%s'�bhilqrDrr�r�)r�fmtr�rrr!r!r"� test_unique_sort_order_with_axis�s�z+TestUnique.test_unique_sort_order_with_axisc
Cs�t�gd�gd�gd�gd�g��|�}d}t�ddg�}tt|�|�|�|�d}t�gd�gd�g�}tt|dd�|�|�|�d}t�gd	�gd
�gd	�gd
�g�}tt|dd�|�|�|�d}t�ddgddggddgddggg��|�}tj|ddgdd�}tt|dd�||�t|dd
d
d
d�\}}}}	d}t||||�d}t|||�d}t|	t�ddg�|�t|dd
d
d
d�\}}}}	d}t|dd�|f|�d}t|dd�|f|�d}t|	t�gd��|�dS)N)rrrr)rrrrz&Unique with 1d array and axis=0 failedrrz&Unique with 2d array and axis=0 failedr�z&Unique with 2d array and axis=1 failed)rrrr�z&Unique with 3d array and axis=2 failedrTr�z-Unique's return_index=True failed with axis=0z/Unique's return_inverse=True failed with axis=0z.Unique's return_counts=True failed with axis=0z-Unique's return_index=True failed with axis=1z/Unique's return_inverse=True failed with axis=1z.Unique's return_counts=True failed with axis=1)rrr)rr�astyperr�take)
rrJr�rSr��data3dr�r�r�r�r!r!r"r��s\
��"
������zTestUnique._run_axis_testsN)r'r(r)r�r�r�r�r�r�r�r�r�rrr�r!r!r!r"r��s*
$
	r�)�__doc__�numpyr�
numpy.testingrrrr�numpy.lib.arraysetopsrrrr	r
rrr
r�rr�r!r!r!r"�<module>s(:

https://t.me/RX1948 - 2025