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

6��a��@sdZddlZddlZddlmZmZmZddlm	Z	ej
dej
dej
dej
dZd	diid
diddiddiddiddidd
idd
iiid�ZGdd�d�Z
Gdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd �d �ZGd!d"�d"�ZGd#d$�d$�Zd%d&�Zd'd(�Zej�d)gd*��d+d,��ZGd-d.�d.�Zej�d)e���d/d0��Zd1d2�Z ej�d)d3d4e!�dd5d6g�d7d8��Z"ej�d)e���d9d:��Z#ej�d)e���d;d<��Z$ej�d=e�ej�d)e���d>d?���Z%dS)@z(Tests for the array padding functions.

�N)�assert_array_equal�assert_allclose�assert_equal)�	_as_pairs�uint�int�float�complex�constant_values�
end_values�stat_length�reflect_type�even)�constant�edge�linear_ramp�maximum�mean�median�minimum�reflect�	symmetric�wrap�emptyc@�<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestAsPairscCsht�ddggd�}ddgdggfD]}t|d�}t||�qt�}tt|d�t�||ggd��dS)z Test casting for a single value.��
N��np�arrayrr�object��self�expected�x�result�obj�r(�?/usr/lib/python3/dist-packages/numpy/lib/tests/test_arraypad.py�test_single_value!s
�zTestAsPairs.test_single_valuecCs�t�ddggd�}ddgddggfD]}t|d�}t||�qt�}ttd|gd�t�d|ggd��ttdgdggd�t�ddgddgg��ttdg|ggd�t�ddg||gg��dS)z-Test proper casting for two different values.r�r�a�Nrr"r(r(r)�test_two_values.s"
���zTestAsPairs.test_two_valuescCs0d}ttdddd�|�ttdddd�|�dS)N)�NNr/r/rF��as_indexT)rr�r#r$r(r(r)�test_with_noneGs��zTestAsPairs.test_with_nonecCs$t�d��d�}tt|d�|�dS)z?Test if `x` already matching desired output are passed through.�)�r-r5N)r�arange�reshaperrr2r(r(r)�test_pass_throughRs
�zTestAsPairs.test_pass_throughc
Cs�ttddgddd�tjddggdtjd��ttddgddd�tjdd	ggdtjd��d
d
gd
ggd
d	gddgd
d	ggd	d
ggdd
ggdddggfD] }tjtdd��t|ddd�Wd�n1sjwYqOdS)z Test results if `as_index=True`.g������@gffffff
@rTr0r��dtypeg�(\��@r+�������r-�	���znegative values��matchN)rrrr �intp�pytest�raises�
ValueError)r#r%r(r(r)�
test_as_indexZs ��(����zTestAsPairs.test_as_indexcCs�tjtdd��tdgggd�Wd�n1swYtjtdd��tddgdd	ggd�Wd�n1s<wYtjtdd��tt�d
�d�Wd�dS1s\wYdS)z"Ensure faulty usage is discovered.zmore dimensions than allowedr@rrNzcould not be broadcastr=r-r+�r-r)rCrDrErr�ones)r#r(r(r)�test_exceptionsis��"�zTestAsPairs.test_exceptionsN)	�__name__�
__module__�__qualname__r*r.r3r8rFrIr(r(r(r)r s
rc@sZeZdZej�de���dd��Zej�dgd��dd��Z	ej�dgd��dd��Z
d	S)
�TestConditionalShortcuts�modecCs>t�d��ddd�}dd�|jD�}t|tj|||d��dS)N�xr+�r5cS�g|]}d�qS)�rrr(��.0�_r(r(r)�
<listcomp>w�zHTestConditionalShortcuts.test_zero_padding_shortcuts.<locals>.<listcomp>�rN�rr6r7�shaper�pad�r#rN�test�pad_amtr(r(r)�test_zero_padding_shortcutstsz4TestConditionalShortcuts.test_zero_padding_shortcuts)rrrrcCsLt�d��ddd�}dd�|jD�}ttj||dd�tj|||d	d
��dS)NrOr+rPr5cSrQ)�r=r=r(rSr(r(r)rV}rWzITestConditionalShortcuts.test_shallow_statistic_range.<locals>.<listcomp>rrXr=�rNrrYr\r(r(r)�test_shallow_statistic_rangezs
�z5TestConditionalShortcuts.test_shallow_statistic_rangecCsJt�d��dd�}dd�|jD�}ttj|||d�tj|||dd��dS)N�rPr5cSrQ))rrr(rSr(r(r)rV�rWzFTestConditionalShortcuts.test_clip_statistic_range.<locals>.<listcomp>rXrarYr\r(r(r)�test_clip_statistic_range�s
�z2TestConditionalShortcuts.test_clip_statistic_rangeN)rJrKrLrC�mark�parametrize�
_all_modes�keysr_rbrdr(r(r(r)rMss

rMc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zej�dgd��dd��Zej�dgd��ej�dgd ��d!d"���Zd#d$�Zej�d%�ej�d&�ej�dd'd(g�d)d*����Zej�dd+d,g�d-d.��Zd/S)0�
TestStatisticcCs>t�d��d�}tj|dddd�}t�gd��}t||�dS)N�d�f)���r)rG�r)���?rprprprprprprprprprprprprprprprprprprprprprprprp���?�@�@�@�@�@�@� @�"@�$@�&@�(@�*@�,@�.@�0@�1@�2@�3@�4@�5@�6@�7@�8@�9@�:@�;@�<@�=@�>@�?@�@@��@@�A@��A@�B@��B@�C@��C@�D@��D@�E@��E@�F@��F@�G@��G@�H@��H@�I@��I@�J@��J@�K@��K@�L@��L@�M@��M@�N@��N@�O@��O@�P@�@P@��P@��P@�Q@�@Q@��Q@��Q@�R@�@R@��R@��R@�S@�@S@��S@��S@�T@�@T@��T@��T@�U@�@U@��U@��U@�V@�@V@��V@��V@�W@�@W@��W@��W@�X@�@X@��X@��X@r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��rr6�astyper[r r�r#r,�br(r(r)�test_check_mean_stat_length�s�z)TestStatistic.test_check_mean_stat_lengthcC�4t�d�}t�|dd�}t�gd��}t||�dS)Nrjrlr)��cr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr=r-rr+rPr5��r>r�r4�
������rn����rm����rc�� �!�"�#�$�%�&�'�(�)�*�+�,�-�.�/�0�1�2�3�4�5�6�7�8�9�:�;�<�=�>�?�@�A�B�C�D�E�F�G�H�I�J�K�L�M�N�O�P�Q�R�S�T�U�V�W�X�Y�Z�[�\�]�^�_�`�a�br�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��rr6r[r rr�r(r(r)�test_check_maximum_1��
�z"TestStatistic.test_check_maximum_1cC�8t�d�d}t�|dd�}t�gd��}t||�dS)Nrjr=rlr)�rjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjr2r�r(r(r)�test_check_maximum_2���z"TestStatistic.test_check_maximum_2cC�<t�d�d}tj|dddd�}t�gd��}t||�dS)Nrjr=rlrrro)�rrrrrrrrrrrrrrrrrrrrrrrrrr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjr2r�r(r(r)�test_check_maximum_stat_length���z,TestStatistic.test_check_maximum_stat_lengthcCr�)Nrjrlr��rrrrrrrrrrrrrrrrrrrrrrrrrrr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rrrrrrrrrrrrrrrrrrrrr2r�r(r(r)�test_check_minimum_1�r4z"TestStatistic.test_check_minimum_1cCr5)Nrjr-rlr)�r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rj�er-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r2r�r(r(r)�test_check_minimum_2r7z"TestStatistic.test_check_minimum_2cCr8)Nrjr=rlrrro)�r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rjr*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r2r�r(r(r)�test_check_minimum_stat_lengthr:z,TestStatistic.test_check_minimum_stat_lengthcC�:t�d��d�}t�|dd�}t�gd��}t||�dS)Nrjrkrlr����H@rBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrqrrrsrtrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBr�r�r(r(r)�test_check_median2��zTestStatistic.test_check_mediancCs`t�gd�gd�gd�g�}t�|dd�}t�gd�gd�gd�gd	�gd�g�}t||�dS)
N�rr=r+�r+rPr>�r>r�r-r=r)r+r+rPr+r+�rrr=r+r�rPr+rPr>rP�r�r>r�r-r�)rr r[rr�r(r(r)�test_check_median_01Js��	z"TestStatistic.test_check_median_01cCsdt�gd�gd�gd�g�}t�|jdd�j}t�gd�gd�gd�gd	�gd�g�}t||�dS)
NrErFrGr=r)rPr+rPr+rPrHrIrJ)rr r[�Trr�r(r(r)�test_check_median_02Xs��	z"TestStatistic.test_check_median_02cCsNt�d��d�}d|d<d|d<tj|ddd	d
�}t�gd��}t||�dS)Nrjrkrsr=r�r0rlr�rrPro)�rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrqrsrsrtrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r(r(r)�test_check_median_stat_lengthfs�z+TestStatistic.test_check_median_stat_lengthcCs�gd�g}tj|dddd�}t�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�g
�}t||�dS)N�r+rPr5�rPr�rr-ro)r+r+r+r+r+r+rPr5r5r5r5r5r5r5r5�rr[r rr�r(r(r)�test_check_mean_shape_one�s&
��z'TestStatistic.test_check_mean_shape_onecCr@)NrjrkrlrrAr�r�r(r(r)�test_check_mean_2�rDzTestStatistic.test_check_mean_2rN)rrrrcCsFt�gd��tjgd�tjd�}t�|d|�}t|d|d�dS)z3 Test that appended and prepended values are equal )���r-rU)rg�-���q=rr9r`rrUN)rr �float64r[r)r#rNr,r(r(r)�test_same_prepend_append�s"
z&TestStatistic.test_same_prepend_appendr�r?)r?)rrU))rPr-)r?r))r<�r-cCsZt�d��d�}d}tjt|d��tj|d||d�Wd�dS1s&wYdS)Nrc�r5rP�#index can't contain negative valuesr@r-ro�rr6r7rCrDrEr[)r#rNr�arrrAr(r(r)�test_check_negative_stat_length�s
"�z-TestStatistic.test_check_negative_stat_lengthcCs�t�d�}t�|d�}tj|dddd�}t�gd�gd�gd�gd�gd	�gd
�gd�gd�gd�gd�gd�g�}t||�dS)
NrcrZ�rG�rr-r�rra)
r5r5r5rPr5r�r�r>r�r�)
r=r=r=rr=r-rr+rr)
r�r�r�rr�r4r�r�r�r�)
r�r�r�r�r�r�r�r�r�r�)
r�r�r�rnr�r�r�r�r�r�)
r�r�r�rmr�r�r�r�r�r��rr6r7r[r rr�r(r(r)�test_simple_stat_length�s$
��z%TestStatistic.test_simple_stat_lengthz)ignore:Mean of empty slice:RuntimeWarningzOignore:invalid value encountered in (true_divide|double_scalars):RuntimeWarningrrcCs>tjddgd|dd�}t�tjddtjtjg�}t||�dS)Nrrrs�r=r-rro)rr[r �nanr)r#rNr]r$r(r(r)�test_zero_stat_length_valid�sz)TestStatistic.test_zero_stat_length_validrrcCsd}tjt|d��tjddgd|dd�Wd�n1swYtjt|d��tjddgd|dd�Wd�n1sAwYtjt|d��tjddgd|dd�Wd�n1scwYtjt|d��tjddgd|dd�Wd�dS1s�wYdS)	Nz,stat_length of 0 yields no value for paddingr@rrrsrro)r=rr=)rCrDrErr[�r#rNrAr(r(r)�test_zero_stat_length_invalid�s���"�z+TestStatistic.test_zero_stat_length_invalidN)rJrKrLr�r3r6r9r<r>r?rCrKrMrOrSrTrCrerfrWr^rc�filterwarningsrfrhr(r(r(r)ri�s<
�
�ric@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestConstantcC�8t�d�}tj|dddd�}t�gd��}t||�dS)Nrjrlr)rrn�r
)�rrrrrrrrrrrrrrrrrrrrrrrrrrr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnr2r�r(r(r)�test_check_constant��
�z TestConstant.test_check_constantcCr�)Nrjrlrr;r2r�r(r(r)�test_check_constant_zerosr4z&TestConstant.test_check_constant_zeroscCslt�d��dd�}tj|dddd�}t�gd�gd	�gd
�gd�gd�gd
�gd�gd�g�}t||�dS)NrcrPr5rdr皙�����?�rNr
)	r=r=r=r=r=r=r=r=r=)	r=rr=r-rr+rPr=r=)	r=r5r�r�r>rr�r=r=)	r=r4r�r�r�r�r�r=r=)	r=r�r�rnr�r�r�r=r=)	r=r�rmr�r�r�r�r=r=�rr6r7r[r r�r#r]r]r$r(r(r)�test_check_constant_float$s 
���z&TestConstant.test_check_constant_floatcCsxt�d��dd�}|�tj�}tj|dddd�}t�gd�gd	�gd
�gd�gd�gd
�gd�gd�g�}t||�dS)NrcrPr5�rdrdrrprq)	rprprprprprprprprp)	rprqrrrsrtrurvrprp)	rprwrxryrzr{r|rprp)	rpr}r~rr�r�r�rprp)	rpr�r�r�r�r�r�rprp)	rpr�r�r�r�r�r�rprp�rr6r7r�rVr[r r)r#r]�	arr_floatr]r$r(r(r)�test_check_constant_float28s"
���z'TestConstant.test_check_constant_float2cCs<tjdtd�}tj|dddd�}t�gd��}t||�dS)Nrjr9rlr)皙������333333�rl)�ryryryryryryryryryryryryryryryryryryryryryryryryryrr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrz)rr6rr[r rr�r(r(r)�test_check_constant_float3Mr:z'TestConstant.test_check_constant_float3c
Csft�d��dd�}tj|dddd�}t�gd�gd	�gd
�gd�gd�gd
�gd�g�}t||�dS)NrcrPr5)�r=rYrrrq)
rrrrrrrrrr)
rrrr=r-rr+rPrr)
rrr5r�r�r>rr�rr)
rrr4r�r�r�r�r�rr)
rrr�r�rnr�r�r�rr)
rrr�rmr�r�r�r�rrrrrsr(r(r)�"test_check_constant_odd_pad_amountes
���z/TestConstant.test_check_constant_odd_pad_amountcCs\t�d��dd�}tjj|dddd�}t�gd�gd�gd	�gd
�gd
�g�}t||�dS)Nr+r-)rd)r=rr)rd�rr+rq)rr=r=r+r+r+)rrr=r+r+r+)rr-rr+r+r+)rr-r-r+r+r+)rr6r7�libr[r rrsr(r(r)�test_check_constant_pad_2dvs���z'TestConstant.test_check_constant_pad_2dcCs�d}tjd|tjd�}tj|dd|��d�}tjd|tjd�}t||�d}tjd|tjd�}tj|dd|��d�}tjd|tjd�}t||�dS)	Nl����rPr9r=rrqr�l����)r�full�uint64r[�minr�int64)r#�
uint64_maxr]r]r$�	int64_maxr(r(r)�test_check_large_integers�s
z&TestConstant.test_check_large_integerscCsrtjdtd�}t�}||d<t�}t�}tj|dd||fd�}tjdtd�}||d<||d<||d<t||�dS)Nr=r9rr)�	pad_widthrNr
rar-)rrr!r[r)r#r]�obj_a�obj_b�obj_cr$r(r(r)�test_check_object_array�s
�z$TestConstant.test_check_object_arraycC�0t�d�}tj|gd�dd�}|jdksJ�dS)N�rrr-��rrYr|rrX�rr+r+�r�zerosr[rZ�r#r]r&r(r(r)�test_pad_empty_dimension��
z%TestConstant.test_pad_empty_dimensionN)
rJrKrLrmrortrxr{r}r�r�r�r�r(r(r(r)rj�s

rjc@sReZdZdd�Zdd�Zejjefd�dd��Z	dd	�Z
ej�d
e�dd��Z
d
S)�TestLinearRampcCsDt�d��d�}tj|dddd�}t�gd��}t||ddd	�dS)
Nrjrkrlr)r+rP)r)�rug���Q�@gq=
ףp
@g)\��(@g�z�G�
@g������	@gR���Q@g
ףp=
@g�(\��@g{�G�z@g333333@g�Q���@g�p=
ף@g���Q��?g)\��(�?g�������?g
ףp=
�?g{�G�z�?g�Q����?g���Q��?g�������?g{�G�z�?g���Q��?g{�G�z�?g{�G�z�?rqrrrsrtrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�g33333�W@gffffffV@g�����9U@g�����T@g�R@g33333�Q@gfffff�P@g33333�N@g�����YL@r�gfffff�G@g�����LE@g33333�B@g������@@g�<@g������7@g�����3@g������,@gffffff#@rvg�h㈵��>)�rtol�atol)rr6r�r[r rr�r(r(r)�test_check_simple�s�z TestLinearRamp.test_check_simplecCstt�d��dd��tj�}tj|dddd�}t�gd�gd	�gd
�gd�gd�gd
�gd�gd�g�}t||�dS)Nrnr+rP)r-r-rrR�rNr)	rqrqrqrqrqrqrqrqrq)	rqrqrqrprrg�?rsrrrq)	rqrqrqrrrsrtrursrq)	rqg@rvrwrxryrzg@rq)	rqrvr{r|r}r~rrxrq)	rq�@r�r�r�r�r��#@rq)	rqg@r�ryg!@rzr�g@rqrvrsr(r(r)�
test_check_2d�s��	zTestLinearRamp.test_check_2d)�
exceptionscCs�ddlm}t�|dd�|dd�g�}tj|dddd�}t�|dd	�|d
d	�|dd	�|dd	�|d
d	�|dd	�|dd	�g�}t||�dS)Nr)�Fractionr=r-rUrGrr�r4rr5���r<r?)�	fractionsr�rr r[r)r#r�r]�actualr$r(r(r)�test_object_array�s�	z TestLinearRamp.test_object_arraycCsztjt�d��dd�ddd�}t|dd�dfd	�t|dd�d
fd	�t|ddd�fd	�t|d
dd�fd	�dS)z!Ensure that end values are exact.rr-rP)���{rrXNrrqrU)rr[rHr7r)r#r,r(r(r)�test_end_values�s
zTestLinearRamp.test_end_valuesr:cCs�tjdg|d�}tj|dddd�}tjgd�|d�}t||�tjdg|d�}tj|dddd�}tjgd�|d�}t||�dS)	a<
        Check correct behavior of unsigned dtypes if there is a negative
        difference between the edge to pad and `end_values`. Check both cases
        to be independent of implementation. Test behavior for all other dtypes
        in case dtype casting interferes with complex dtypes. See gh-14191.
        rr9rrr�)rr=r-rr-r=r)rr-r=rr=r-rN)rr r[r)r#r:r%r&r$r(r(r)�test_negative_difference�s
z'TestLinearRamp.test_negative_differenceN)rJrKrLr�r�rCre�xfail�AssertionErrorr�r�rf�_numeric_dtypesr�r(r(r(r)r��s
r�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestReflectcCr�)Nrjrlr)�rmr�r�r�r�rnr�r�r�r�r�r�r�r4r�rr>r�r�r5rPr+rr-r=rr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�r1r0r/r.r-r,r+r*r)r(r'r&r%r$r#r"r!r rrr2r�r(r(r)r��r4zTestReflect.test_check_simplecCrk)Nrjrlr�odd�r
)�i���������������������������������������������������r����r<r;r?rUrr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rjr=�f�g�h�i�j�k�l�m�n�o�p�q�r�s�t�u�v�wr2r�r(r(r)�test_check_odd_methodrnz!TestReflect.test_check_odd_methodcCs�gd�gd�g}t�|dd�}t�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�g�}t||�dS)NrP�r5r�r�rQr)r�r5r�r�r�r5r�r�r�r5r�r�r�r5r��rPr+rPr5rPr+rPr5rPr+rPr5rPr+rPrRr�r(r(r)�test_check_large_pad,s(��z TestReflect.test_check_large_padcC�~gd�g}t�|dd�}t�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�g
�}t||�dS)NrPrQrr�rRr�r(r(r)�test_check_shapeCs&
��zTestReflect.test_check_shapecC�.t�gd�dd�}t�gd��}t||�dS)N�r=r-rr-r)rr-r=r-rr-r=rRr�r(r(r)�
test_check_01Y�zTestReflect.test_check_01cCr�)Nr�rr)	r-rr-r=r-rr-r=r-rRr�r(r(r)�
test_check_02^r�zTestReflect.test_check_02cCr�)Nr�r+r)r=r-rr-r=r-rr-r=r-rrRr�r(r(r)�
test_check_03cr�zTestReflect.test_check_03N)
rJrKrLr�r�r�r�r�r�r�r(r(r(r)r��sr�c@sPeZdZdZej�dee�	�ddh��dd��Z
ej�de�	��dd��Zd	S)
�TestEmptyArrayz<Check how padding behaves on arrays with an empty dimension.rNrrcCs�d}tjt|d��tjgd|d�Wd�n1swYtjt|d��tjt�d�d|d�Wd�n1s>wYtjt|d��tjt�d�d|d�Wd�dS1sawYdS)NzFcan't extend empty axis 0 using modes other than 'constant' or 'empty'r@r+rXr)rr)r|r�)rCrDrErr[�ndarrayr�rgr(r(r)r�ls��"�z'TestEmptyArray.test_pad_empty_dimensioncCs(tjt�d�d|d�}|jdksJ�dS)N)r-rr-)rar�r|rX)r�rr+)rr[rHrZ)r#rNr&r(r(r)�test_pad_non_empty_dimension{sz+TestEmptyArray.test_pad_non_empty_dimensionN)rJrKrL�__doc__rCrerf�sortedrgrhr�r�r(r(r(r)r�is�

r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�
TestSymmetriccCr�)Nrjrlr)�r�r�r�r�rnr�r�r�r�r�r�r�r4r�rr>r�r�r5rPr+rr-r=rrr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�r�r1r0r/r.r-r,r+r*r)r(r'r&r%r$r#r"r!r rr2r�r(r(r)r��r4zTestSymmetric.test_check_simplecCrk)Nrjrlrr�r�)�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r<r;r?rUrrr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�r�rjr=r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r2r�r(r(r)r��rnz#TestSymmetric.test_check_odd_methodcCs�gd�gd�g}t�|dd�}t�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�g�}t||�dS)NrPr�rQr�rPr5r5rPr+r+rPr5r5rPr+r+rPr5r5)r�r�r�r�r5r5r�r�r�r�r5r5r�r�r�rRr�r(r(r)r��s(��z"TestSymmetric.test_check_large_padcCs�gd�gd�g}tj|dddd�}t�gd�gd�gd�gd�gd	�gd	�gd
�gd
�gd�gd�gd�gd�gd
�gd
�g�}t||�dS)NrPr�rQrr�r�)r;r?r?rUrrr=r-r-rr+r+rPr5r5)rUrrr=r-r-rr+r+rPr5r5r�r�r�)r=r-r-rr+r+rPr5r5r�r�r�r>rr)rr+r+rPr5r5r�r�r�r>rrr�r4r4)rPr5r5r�r�r�r>rrr�r4r4r�r�r�)r�r�r�r>rrr�r4r4r�r�r�r�r�r�)r>rrr�r4r4r�r�r�r�r�r�r�r�r�rRr�r(r(r)�test_check_large_pad_odd�s(��z&TestSymmetric.test_check_large_pad_oddcCr�)NrPrQrr�rRr�r(r(r)r��s&
��zTestSymmetric.test_check_shapecCr�)Nr�r-r)r-r=r=r-rrr-rRr�r(r(r)r��r�zTestSymmetric.test_check_01cCr�)Nr�rr)	rr-r=r=r-rrr-r=rRr�r(r(r)r��r�zTestSymmetric.test_check_02cCr�)Nr�r5r)r=r-rrr-r=r=r-rrr-r=r=r-rrRr�r(r(r)r�r�zTestSymmetric.test_check_03N)rJrKrLr�r�r�r�r�r�r�r�r(r(r(r)r��sr�c@r)�TestWrapcCr�)Nrjrlr)�rrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�rnr�r�r�r�rmr�r�r�r�rcr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrr	r
rrr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r�rr=r-rr+rPr5r�r�r>rr�r4r�r�r�r�r�r�r�r2r�r(r(r)r�r4zTestWrap.test_check_simplecCs�t�d�}t�|d�}t�|dd�}t�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�gd�g�}t||�dS)Nr4r~)rr4r)rr�r�r>rr�r�r>rr�r�r>rr�r�r>rr�r�r>rr�r�r>rr�)r-rrr=r-rrr=r-rrr=r-rrr=r-rrr=r-rrr=r-r)r5r�r+rPr5r�r+rPr5r�r+rPr5r�r+rPr5r�r+rPr5r�r+rPr5r�rbr�r(r(r)r� s@
��6zTestWrap.test_check_large_padcCr�)Nr�rr)	r=r-rr=r-rr=r-rrRr�r(r(r)r�\r�zTestWrap.test_check_01cCr�)Nr�r+r)rr=r-rr=r-rr=r-rr=rRr�r(r(r)r�ar�zTestWrap.test_check_02cCs8t�d�}tj|ddd�}t||dd�dd�f�dS)NrN)rrPrrXr�)rrHr[rr�r(r(r)�test_pad_with_zerofs
zTestWrap.test_pad_with_zerocCsxt�d�}tj|ddd�}ttj||||fdd�|�t�d�}tj|ddd�}ttj||||fdd�|�dS)	zy
        Check wrapping on each side individually if the wrapped area is longer
        than the original array.
        rP)r4rrrXrN)rr4r;)rr6r[r�r_r�r(r(r)�test_repeated_wrappingks
 
$zTestWrap.test_repeated_wrappingN)	rJrKrLr�r�r�r�r�r�r(r(r(r)r�s<r�c@�eZdZdd�Zdd�ZdS)�TestEdgecCsrt�d�}t�|d�}t�|dd�}t�gd�gd�gd�gd�gd�gd�gd�gd�gd�g	�}t||�dS�	Nr4�r+rr_r)rrrrr=r-r-r-)rrrrr+rPrPrP)r5r5r5r5r�r�r�r�)r>r>r>r>rr�r�r�rbr�r(r(r)r�zs 
��
zTestEdge.test_check_simplecCs�t�gd��}t�|dd�}t�gd��}t||�t�gd�gd�g�}t�|dd�}t�|dd�}t||�t�d��dd	d
�}t�|dd�}t�|dd�}t||�dS)Nr�)rdr)r=r=r-rrrrPrur�r-rr+)rdrdrd)rr r[rr6r7)r#r,�paddedr$r(r(r)�test_check_width_shape_1_2�s

z#TestEdge.test_check_width_shape_1_2N)rJrKrLr�r�r(r(r(r)r�ysr�c@r�)�	TestEmptycCsRt�d��dd�}tj|ddgdd�}|jdksJ�t||d	d
�dd�f�dS)
Nr�r+r5rG)rr=rrX)r>rr-r;rrU�rr6r7r[rZrr�r(r(r)�test_simple�szTestEmpty.test_simplecCr�)Nr�r�rrXr�r�r�r(r(r)r��r�z"TestEmpty.test_pad_empty_dimensionN)rJrKrLr�r�r(r(r(r)r��sr�c	Csddd�}t�d��dd�}t�|d|�}t�gd�gd�gd�gd�gd�gd�g�}t||�dS)	NcSs&d|d|d�<d||dd�<dS)Nrrr=r()�vectorr��iaxis�kwargsr(r(r)�_padwithtens�sz6test_legacy_vector_functionality.<locals>._padwithtensr5r-r)rrrrrrr)rrrr=r-rr)rrrr+rPrrrb)r�r,r�r(r(r)� test_legacy_vector_functionality�s��
r�cCs.tjdgddd�}t�gd��}t||�dS)Nr=r-rrX)rrr=rrrR)r,r�r(r(r)�test_unicode_mode�r�r�rN)rrrrcCs:tjddd�}d}tjddd�}ttj|||d�|�dS)Nr�)�
fill_valuer_)r>r�rX)rr�rr[)rNr,r^r�r(r(r)�test_object_input�sr�c@s�eZdZej�dgd��ej�de���dd���Zej�de���dd��Z	ej�dgd��ej�de���d	d
���Z
ej�ddd
de�dfddefedd�dfdg�ej�de���dd���Z
dd�Zej�dgd��ej�de���dd���ZdS)�TestPadWidthr�))r+rPr5r�)r|rYra)rdr~)rPr5))rr+rP)rr=r-rNcC�Vt�d��d�}d}tjt|d��t�|||�Wd�dS1s$wYdS)NrcrZz(operands could not be broadcast togetherr@r\�r#r�rNr]rAr(r(r)�test_misshaped_pad_width�s
"�z%TestPadWidth.test_misshaped_pad_widthcCsVt�d��d�}d}tjt|d��t�|d|�Wd�dS1s$wYdS)NrcrZzDinput operand has more dimensions than allowed by the axis remappingr@))ra)r+)rP)r�r|rYr\)r#rNr]rAr(r(r)�test_misshaped_pad_width_2�s
"�z'TestPadWidth.test_misshaped_pad_width_2rXcCr�)NrcrZr[r@r\r�r(r(r)�test_negative_pad_width�s
"�z$TestPadWidth.test_negative_pad_widthzpad_width, dtype)�3N)�wordNr/N)g333333@N))r-rr+r`r=rU)))g�������rr`NcCs�t�d��d�}d}|dur4tjt|d��t�|tj||d�|�Wd�dS1s-wYdStjt|d��t�|||�Wd�n1sMwYtjt|d��t�|t�|�|�Wd�dS1sowYdS)NrcrZz%`pad_width` must be of integral type.r@r9)rr6r7rCrD�	TypeErrorr[r )r#r�r:rNr]rAr(r(r)�
test_bad_type�s"��"�zTestPadWidth.test_bad_typecCsxt�d�}t�|d�}t�|t�d�d�}t�gd�gd�gd�gd�gd�gd�gd�gd�gd�g	�}t||�dSr�rbr�r(r(r)�test_pad_width_as_ndarrays 
��
z&TestPadWidth.test_pad_width_as_ndarray)rrR)rRrRcCs,t�d��dd�}t|tj|||d��dS)Nrcr5rPrX)rr6r7rr[)r#r�rNr]r(r(r)�test_zero_pad_widthsz TestPadWidth.test_zero_pad_width)rJrKrLrCrerfrgrhrrrr!r	rrrr(r(r(r)r��s6
��

r�c	Cs�t|}i}t��D]}||kr|�|�q
tjgd�d|fi|��|��D]/\}}d�|�}tjt	|d��tjgd�d|fi||i��Wd�n1sQwYq'dS)z1Test behavior of pad's kwargs for the given mode.r�r=z+unsupported keyword arguments for mode '{}'r@N)
rg�values�updaterr[�items�formatrCrDrE)rN�allowed�not_allowedr��key�valuerAr(r(r)�test_kwargs!s
�
 ���rcCs(t�ddg�}tt�|d�gd��dS)Nr=r-)rrr=r=rr)rr rr[)r]r(r(r)�test_constant_zero_default2srr=�constTFcCsRd�|�}tjt|d��tjgd�d|d�Wd�dS1s"wYdS)Nzmode '{}' is not supportedr@r�r+rX)rrCrDrErr[)rNrAr(r(r)�test_unsupported_mode7s
"�rcCs`t�d��dd�ddd�ddd�f}t�|d|�}|jdks!J�t|dd�dd�f|�dS)Nr�r+r5r-rG)r�r�r;r�)rNr]r&r(r(r)�test_non_contiguous_array>s&rcCsPtjddd�}t�|d|�jdsJ�tjddd�}t�|d|�jds&J�dS)	z5Test if C and F order is preserved for all pad modes.)rPr�C)�orderrP�C_CONTIGUOUS�F�F_CONTIGUOUSN)rrHr[�flags)rNr%r(r(r)�test_memory_layout_persistenceFsrr:cCs0tjd|d�}tj|d|d�}|j|ksJ�dS)N)rr-r=r9r=rX)rr�r[r:)r:rNr]r&r(r(r)�test_dtype_persistenceOsr)&r�rC�numpyr�
numpy.testingrrr�numpy.lib.arraypadr�sctypesr�rgrrMrirjr�r�r�r�r�r�r�r�r�rerfr�r�rhrrr!rrrrr(r(r(r)�<module>sr�����Sl4Unr'

Q





https://t.me/RX1948 - 2025