HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/numpy/lib/tests/__pycache__/test_index_tricks.cpython-310.pyc
o

6��aJ�@s�ddlZddlZddlmZmZmZmZmZm	Z	m
Z
mZddlm
Z
mZmZmZmZmZmZmZmZmZmZGdd�d�ZGdd�d�ZGdd	�d	�ZGd
d�d�ZGdd
�d
�ZGdd�d�Zdd�ZGdd�d�Zdd�Z Gdd�d�Z!dd�Z"dS)�N)�assert_�assert_equal�assert_array_equal�assert_almost_equal�assert_array_almost_equal�
assert_raises�assert_raises_regex�assert_warns)�mgrid�ogrid�ndenumerate�
fill_diagonal�diag_indices�diag_indices_from�	index_exp�ndindex�r_�s_�ix_c@sfeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
j�dgd��dd��Z
dd�ZdS)�TestRavelUnravelIndexcCs�tt�dd�d�ttjddd�d�tt��tjddd�Wd�n1s)wYtt��tjddd�Wd�n1sDwYtt��tjddd	�Wd�n1s_wYtt��tjddd
�Wd�n1szwYtt�dd�d�tt�dd�d�tt�dd�d�tttjdd�tttjd
d�tttjdd�tttjdd�tttjdd�tttjdd�tttjdd�tttjdd�tt�dd�gd��tt�gd�d�d�t�gd�gd�g�}tt�|d�gd��ttj|ddd�gd��ttj|ddd �gd!��ttj|d"d#d �gd$��tt�d%d&�d'�tt�t�gd��d�gd�gd�g�ttjt�gd��ddd�gd�gd�g�tt�d'd&�gd%��dS)(N�)rr��r)�indices�shape)r�hape)r�)��^)�ims)�dims)r�B���g�?�)���r)rr)rr$)rr)皙�����?g�.)r#��)rrr#)r'r(r()r#�r)�r()��)�%�F��order)�r,�
)r#r(�clip��mode)r+���r#r#)r3�wrap)�r2r2)r'rr#r)r(r*��	iU)r�np�
unravel_indexr�	TypeError�ravel_multi_index�
ValueError�array)�self�arr�rE�C/usr/lib/python3/dist-packages/numpy/lib/tests/test_index_tricks.py�
test_basicsj��
�
�
�
�������z TestRavelUnravelIndex.test_basiccCsd}d}tt|tjgd�tt|tjdd�tt|tjt�g�d�tt�tjgtd�d�gggg�tt|tjggfd�tt|tjgdgfd�tt|tjt�g�t�g�fd�tt�tjgtd�tjgtd�fd�g�tt�tjgggtd�d�g�dS)	Nz9indices must be integral: the provided empty sequence waszonly int indices permitted)�
r'r)rE��dtype�rHr'�abc)r)r')rr?r=r>rBr�intr@)rC�msg1�msg2rErErF�test_empty_indicesGs:����
�����z(TestRavelUnravelIndex.test_empty_indicescCs�tjtjkr(ddgddgddgddgdd	gddgd
dgf}tt�|d�dd
g�tttjdd�d
gd
gf}t�tj�j	d}tt�||df�d
g�tttj||ddf�ttj||dfdd�d
g�tttj||ddfdd�dS)Nr�r'r)�ur7riK	ir)r,r*�x�$i�
r;r(l�z�l
nm)l��lr.r/)
r=�intp�int64rr@rrAr>�iinfo�max)rCrD�	dummy_arr�half_maxrErErF�test_big_indices[s.�
����
�z&TestRavelUnravelIndex.test_big_indicescCsptjtjtjtjtjtjfD]�}tjgd�gd�g|d�}d}d|d|d}tt�	||�|�t|t�
||��|dd|d}ttj	||d	d
�|�t|tj
||d	d
��tjgd�gd�gd�g|d�}d}d
d|d|d|d}tt�	||�|�t|t�
||��|dd|dd|d}ttj	||d	d
�|�t|tj
||d	d
��qdS)N)rrrrr'r#)rr(rr'rrrI)r)r;r;rrr)r.r/)rr'rrr<r))r)r;rHrHr)r=�int16�uint16�int32�uint32rV�uint64rBrr@r>)rCrJ�coordsr�uncoordsrErErF�test_dtypesss:����  ��z!TestRavelUnravelIndex.test_dtypescCsdttjgd�ddd�t�gd�d��ttjgd�ddd�t�gd�d��tttjgd�d�dS)N)r)rr"r)r#r'r*r:r9r4)rrr(r)r9�raiser3rd)rrrr)rr=r@rrA�rCrErErF�test_clipmodes�s����z$TestRavelUnravelIndex.test_clipmodescCs0t�gd�d�\}}t|jj�t|jj�dS)N�rrr')r#r))r=r>r�flags�	writeable)rC�x�yrErErF�test_writeability�sz'TestRavelUnravelIndex.test_writeabilitycCsBt�dd�}t|d�ttdtjdgd�ttdtjdgd�dS)NrrEz0d arrayz
out of boundsr)r=r>rrrA�rCrjrErErF�test_0d�s
�zTestRavelUnravelIndex.test_0dr5)r3r9rdcCsttjtjdtjd�d|d�}|jdksJ�tt��tjtjdtjd�d|d�Wd�dS1s3wYdS)N)r'rrI�rrrr4�r)r'r)r=r@�zerosrUrrrA)rCr5�resrErErF�test_empty_array_ravel�s�
�"�z,TestRavelUnravelIndex.test_empty_array_ravelcCszt�tjdtjd�d�}t|�dksJ�tdd�|D��sJ�tt��t�dgd�Wd�dS1s6wYdS)NrrIror'css�|]}|jdkVqdS)rpN)r)�.0�arErErF�	<genexpr>�s�zATestRavelUnravelIndex.test_empty_array_unravel.<locals>.<genexpr>r)r=r>rqrU�len�allrrA)rCrrrErErF�test_empty_array_unravel�s
"�z.TestRavelUnravelIndex.test_empty_array_unravelN)�__name__�
__module__�__qualname__rGrPr[rcrfrlrn�pytest�mark�parametrizersryrErErErFrs7	
	rc@sVeZdZdd�Zdd�Zdd�Zdd�Zej�	d	d
dg�dd
��Z
dd�Zdd�ZdS)�TestGridcCs�tddd�}tddd�}t|jdk�t|jdk�t|ddk�t|dd�t|ddk�t|d|ddd�t|d|dd	d�t|d|dd
d�dS)Nr"r�$@r%)rH)�r�ggfffff�?g�q�q�?)r
rrr)rCru�brErErFrG�szTestGrid.test_basiccCs8tjdddd�\}}t|d�t|tddd�d�dS)NrrHT)�retstepg9/����?yI@r2)r=�linspacerrr
)rCrk�strErErF�test_linspace_equivalence�s
z"TestGrid.test_linspace_equivalencecCsVtddd�ddd�f}tddd�ddd�f}t|jdk�t|jd	k�t|d
d
dd�ft�dd��t|ddd�d
fdt�dd��t|d
ddd�ft�dd�d
�t|ddd�dfdt�dd�d
�t|d
ddd�f|d
d
dd�fdt�dd�d
�t|ddd�df|ddd�d
fdt�dd�d
�dS)Nr"rr����rr%g�������?)rrHrH)rr�r�rrH�dr�r�)r
rrrr=�onesr)rC�cr�rErErF�test_nd�s$&$($�$�zTestGrid.test_ndcCs\tddd�ddd�f}tddd�ddd�f}tj|�}t||�D]	\}}t||�q"dS)Nr"rr�r�r)r
rr=�broadcast_arrays�zipr)rC�	grid_full�grid_sparse�grid_broadcast�fr�rErErF�test_sparse�s
�zTestGrid.test_sparsezstart, stop, step, expected)NrHr�)��rH)i����r�N)i�cCsJt|||�|||�f}t|||�}t|j|d�t|j|d�dS)Nrr)r
r�size)rC�start�stop�step�expected�grid�
grid_smallrErErF�test_mgrid_size_none_handling�s	z&TestGrid.test_mgrid_size_none_handlingcCs�tddd�f}tt�d�t�d�t�d��f}t|jtjk�t||�tddd�}tt�d�t�d�t�d��}t|jtjk�t||�dS)Nr%g��Q��?)r
r=�float32rrJ�float64r)rC�grid64�grid32rErErF�test_accepts_npfloating�s"
 z TestGrid.test_accepts_npfloatingcCsPttddd�ftddt�d��f�ttddd�tddt�d���dS)Nr%g333333�?y@)rr
r=�	complex64rerErErF�test_accepts_npcomplexfloatings"��z'TestGrid.test_accepts_npcomplexfloatingN)
rzr{r|rGr�r�r�r}r~rr�r�r�rErErErFr��s	�

r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestConcatenatorcCsDttdt�gd���t�d�}t|dd|f}t|gd��dS)N)rrr'r#r)r(r)r)rrrrrrrrrrrr)rrr=rBr�)rCr�r�rErErF�test_1ds
zTestConcatenator.test_1dcCs"tddd�f}t|jdk�dS)Ng333333$@rrH�f8)rrrJ�rC�grErErF�test_mixed_type�z TestConcatenator.test_mixed_typecCs4tdt�dg�t�gd��df}t|jdk�dS)Ng333333$�r)rr'r#g$@r�)rr=rBrrJr�rErErF�test_more_mixed_types"z%TestConcatenator.test_more_mixed_typecCsBtddd�}t|jdk�tddt�d��}t|jdk�dS)NrrTyY@)�d)rrrr=r�r�rErErF�test_complex_stepsz"TestConcatenator.test_complex_stepcCs�tj�dd�}tj�dd�}td||f}t|jdk�t|dd�dd�f|�t|dd�dd�f|�t||f}t|jdk�t|dd�dd�f|�t|dd�dd�f|�dS)Nr)�1)r)rH)rHr))r=�random�randrrrr)rCr�r�r�rErErF�test_2d%szTestConcatenator.test_2dcCsbttdt�d�dfgd��ttgd�t�d�fgd��ttt�d�gd�fgd��dS)Nrrr�rrrr')rrrr'rg)rrr=rBrerErErFrn1s $zTestConcatenator.test_0dN)	rzr{r|r�r�r�r�r�rnrErErErFr�
s	r�c@seZdZdd�ZdS)�TestNdenumeratecCs0t�ddgddgg�}ttt|��gd��dS)Nrrr'r#)))rrr))rrr)rr'))rrr#)r=rBr�listr�rCrurErErFrG8s�zTestNdenumerate.test_basicN)rzr{r|rGrErErErFr�7sr�c@seZdZdd�Zdd�ZdS)�TestIndexExpressioncCsJt�d�}t|dd�|tdd��t|dd�|tdd��dS)Nrr")r=�arangerrrr�rErErF�test_regression_1?s
"z%TestIndexExpression.test_regression_1cCs�tj�ddd�}t|dd�dd�ddgf|tdd�dd�ddgf�t|dd�dd�ddgf|tdd�dd�ddgf�dS)Nr#r)r(r'rr)r=r�r�rrrr�rErErF�
test_simple_1Es:>z!TestIndexExpression.test_simple_1N)rzr{r|r�r�rErErErFr�>sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestIx_cCsbt�td��\}t|jtj�t�g�\}t|jtj�t�tjgtjd��\}t|jtj�dS)NrrI)r=r�rangerrJrUrBr�r�rErErFr�MszTestIx_.test_regression_1cs�d}ttjfD]>�tj�fdd�|D��}tt||��D](\�\}}t|j�|�tt	�fdd�t|j�D���tt�
|jtj��qqdS)N)r#r)r'rcsg|]}�|��qSrErE)rt�sz)�funcrErF�
<listcomp>]�z0TestIx_.test_shape_and_dtype.<locals>.<listcomp>c3s$�|]
\}}|�kr|dkVqdS)rNrE)rt�j�sh)�krErFrv`s�"z/TestIx_.test_shape_and_dtype.<locals>.<genexpr>)
r�r=r�r�	enumerater�rrrrx�
issubdtyperJ�integer)rC�sizes�arraysrur�rE)r�r�rF�test_shape_and_dtypeYs ��zTestIx_.test_shape_and_dtypecCs,gd�}t�|�\}tt�|�d|�dS)N)TFTTr)r=�nonzerorr)rC�bool_a�int_arErErF�	test_boolcszTestIx_.test_boolcCs"gd�gd�g}tttj|�dS)Nrg�r#r)r()rrAr=r)rC�idx2drErErF�test_1d_onlyhr�zTestIx_.test_1d_onlycCsRd}t�|�}t||�}t|dj|df�t|djd|f�t|j|f�dS)Nr)rr)r=r�rrr)rC�length_of_vectorrj�outrErErF�test_repeated_inputls

zTestIx_.test_repeated_inputN)rzr{r|r�r�r�r�r�rErErErFr�Ls
r�cCs>tjt�gd�g�ddt�gd�g�f}t|gd�g�dS)Nrgrr�)rrr'rrr#r)r()r=�c_rBr)rurErErF�test_c_vs*r�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestFillDiagonalcC�<t�dt�}t|d�t|t�gd�gd�gd�g��dS)N)r'r'r)�r)rr�rr)r�rrr)�r=rqrMr
rrBr�rErErFrG|�
��zTestFillDiagonal.test_basiccCsft�dt�}t|d�t|t�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�g
��dS)NrKr)r�r�r��rrrr�r�rErErF�test_tall_matrix�s
��z!TestFillDiagonal.test_tall_matrixcCsht�dt�}t|dd�t|t�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�g
��dS)NrKr)Tr�r�r�r�r�r�rErErF�test_tall_matrix_wrap�s��z&TestFillDiagonal.test_tall_matrix_wrapcCr�)N)r'rHr))
r)rrrrrrrrr)
rr)rrrrrrrr)
rrr)rrrrrrrr�r�rErErF�test_wide_matrix�r�z!TestFillDiagonal.test_wide_matrixcCsDt�dt�}t|d�t�gd��}tt�|dk�||||f�dS)N)r'r'r'r'r#r�r)r=rqrMr
rBr�where)rCru�irErErF�test_operate_4d_array�s
 z&TestFillDiagonal.test_operate_4d_arraycC�Ft�dt�}ttd��t|d�Wd�dS1swYdS)Nr'�at least 2-dr)�r=rqrMrrAr
r�rErErF�test_low_dim_handling�s"�z&TestFillDiagonal.test_low_dim_handlingcCr�)N)r'r'r*r'�equal lengthrr�r�rErErF�test_hetero_shape_handling�s"�z+TestFillDiagonal.test_hetero_shape_handlingN)
rzr{r|rGr�r�r�r�r�r�rErErErFr�{s		r�c	Cs�td�}t�gd�gd�gd�gd�g�}d||<t|t�gd�gd�gd	�gd
�g��tdd�}t�d
t�}d||<t|t�ddgddggddgddggg��dS)Nr#)rrr'r#)r)r(r*r;)r<rHr�r:)r2���r�)r�rr'r#)r)r�r*r;)r<rHr�r:)r2r�r�r�rr')rrrrr)rr=rBrrqrM)�diru�d3rErErF�test_diag_indices�s4
���
����r�c@s$eZdZdd�Zdd�Zdd�ZdS)�TestDiagIndicesFromcCs<tj�d�}t|�\}}t|t�d��t|t�d��dS)Nr8r#)r=r�rrr�)rCrj�rr�rErErF�test_diag_indices_from�sz*TestDiagIndicesFrom.test_diag_indices_fromcCsBt�d�}ttd��
t|�Wd�dS1swYdS)Nr*r�)r=r�rrArrmrErErF�test_error_small_input�s

"�z*TestDiagIndicesFrom.test_error_small_inputcCsDt�dt�}ttd��
t|�Wd�dS1swYdS)N)r'r'rr'r�)r=rqrMrrArrmrErErF�test_error_shape_mismatch�s
"�z-TestDiagIndicesFrom.test_error_shape_mismatchN)rzr{r|r�r�r�rErErErFr��sr�cCs�ttddd��}dd�tt�d��D�}t||�ttd��}t||�ttd��}t|ttd���tt��}t|dg�ttd��}t|dg�ttd	g��}t|g�dS)
Nrrr'cSsg|]\}}|�qSrErE)rt�ix�erErErFr��r�z test_ndindex.<locals>.<listcomp>rg)r'rEr)r�rrr=rqrr)rjr�rErErF�test_ndindex�s


r�)#r}�numpyr=�
numpy.testingrrrrrrrr	�numpy.lib.index_tricksr
rrr
rrrrrrrrr�r�r�r�r�r�r�r�r�r�rErErErF�<module>s (4.Q**G