
    G/Ph                        d Z ddlZddlZddlmZmZmZ ddlm	Z	 ej
        j        d         ej
        j        d         z   ej
        j        d         z   ej
        j        d         z   Zd	dii d
diddiddiddiddiddiddii i dZ G d d          Z G d d          Z G d d          Z G d d          Z G d d          Z G d d          Z G d d          Z G d d          Z G d d           Z G d! d"          Z G d# d$          Zd% Zd& Zej                            d'g d(          d)             Z G d* d+          Zej                            d'e                                          d,             Z d- Z!ej                            d'd.d/ e"            dd0d1g          d2             Z#ej                            d'e                                          d3             Z$ej                            d'e                                          d4             Z%ej                            d5e          ej                            d'e                                          d6                         Z&dS )7z(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                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestAsPairsc                    t          j        ddggdz            }ddgdggfD ]"}t          |d          }t          ||           #t	                      }t          t          |d          t          j        ||ggdz                       dS )z Test casting for a single value.   
   Nnparrayr   r   objectselfexpectedxresultobjs        ]/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numpy/lib/tests/test_arraypad.pytest_single_valuezTestAsPairs.test_single_value!   s    8aVHrM**aSA3% 	+ 	+Aq"%%F****hhc2HsCj\B&''	
 	
 	
 	
 	
    c                    t          j        ddggdz            }ddgddggfD ]"}t          |d          }t          ||           #t	                      }t          t          d|gd          t          j        d|ggdz                       t          t          dgdggd          t          j        ddgddgg                     t          t          dg|ggd          t          j        ddg||gg                     dS )z-Test proper casting for two different values.r      r   a   Nr    r$   s        r*   test_two_valueszTestAsPairs.test_two_values.   s1    8aVHrM**a&Aq6(# 	+ 	+Aq"%%F****hhsCj"%%HsCj\B&''	
 	
 	
 	sQCj!$$Hq!fq!f%&&	
 	
 	

 	usena((HsCj3*-..	
 	
 	
 	
 	
r,   c                     d}t          t          d dd          |           t          t          d dd          |           d S )N)NNr3   r3   r   Fas_indexT)r   r   r%   r&   s     r*   test_with_nonezTestAsPairs.test_with_noneG   sa    =dA...	
 	
 	
 	dA---	
 	
 	
 	
 	
r,   c                     t          j        d                              d          }t          t	          |d          |           dS )z?Test if `x` already matching desired output are passed through.   )   r0   r:   N)r!   arangereshaper   r   r6   s     r*   test_pass_throughzTestAsPairs.test_pass_throughR   sI    9R==((00h""	
 	
 	
 	
 	
r,   c           
         t          t          ddgdd          t          j        ddggdz  t          j                             t          t          ddgdd          t          j        dd	ggdz  t          j                             d
d
gd
ggd
d	gddgd
d	ggd	d
ggddggdz  ddggz   fD ]G}t          j        t          d          5  t          |dd           ddd           n# 1 swxY w Y   HdS )z Test results if `as_index=True`.g@gffffff
@r   Tr4   r   dtypeg(\@r.      r0   	   znegative valuesmatchN)r   r   r!   r"   intppytestraises
ValueError)r%   r'   s     r*   test_as_indexzTestAsPairs.test_as_indexZ   so   sCj"t444Hq!fX]"'222	
 	
 	
 	sDk2555Hq!fX]"'222	
 	
 	
 rdbTFRGaWAwi1b'q6(Q,1b'*, 	0 	0Az1BCCC 0 0!R$////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	0 	0s   C,,C0	3C0	c                    t          j        t          d          5  t          dgggd           ddd           n# 1 swxY w Y   t          j        t          d          5  t          ddgdd	ggd           ddd           n# 1 swxY w Y   t          j        t          d          5  t          t	          j        d
          d           ddd           dS # 1 swxY w Y   dS )z"Ensure faulty usage is discovered.zmore dimensions than allowedrF   r   r   Nzcould not be broadcastrC   r0   r.   r0   r   )rI   rJ   rK   r   r!   ones)r%   s    r*   test_exceptionszTestAsPairs.test_exceptionsi   s   ]:-KLLL 	# 	#ugr"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#]:-EFFF 	+ 	+1v1v&***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+]:-EFFF 	* 	*bgfooq)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s3   <A A "BB	B	+#CC"CN)	__name__
__module____qualname__r+   r1   r7   r=   rL   rP    r,   r*   r   r       sn        
 
 

 
 
2	
 	
 	

 
 
0 0 0* * * * *r,   r   c                      e Zd Zej                            de                                          d             Zej                            dg d          d             Z	ej                            dg d          d             Z
dS )TestConditionalShortcutsmodec                     t          j        d                              ddd          }d |j        D             }t	          |t          j        |||                     d S )Nx   r.      r:   c                     g | ]}d S )r   r   rT   .0_s     r*   
<listcomp>zHTestConditionalShortcuts.test_zero_padding_shortcuts.<locals>.<listcomp>w       ...a6...r,   rW   r!   r;   r<   shaper   padr%   rW   testpad_amts       r*   test_zero_padding_shortcutsz4TestConditionalShortcuts.test_zero_padding_shortcutst   s]    y~~%%aA....4:...4gD!A!A!ABBBBBr,   )r   r   r   r   c           	          t          j        d                              ddd          }d |j        D             }t	          t          j        ||d          t          j        |||d	                     d S )
NrY   r.   rZ   r:   c                     g | ]}d S )rC   rC   rT   r]   s     r*   r`   zITestConditionalShortcuts.test_shallow_statistic_range.<locals>.<listcomp>}   ra   r,   r   rb   rC   rW   r   rc   rf   s       r*   test_shallow_statistic_rangez5TestConditionalShortcuts.test_shallow_statistic_rangez   s    y~~%%aA....4:...26$f===6$dJJJ	L 	L 	L 	L 	Lr,   c           	          t          j        d                              dd          }d |j        D             }t	          t          j        |||          t          j        |||d                     d S )N   rZ   r:   c                     g | ]}d S ))r   r   rT   r]   s     r*   r`   zFTestConditionalShortcuts.test_clip_statistic_range.<locals>.<listcomp>   ra   r,   rb   rm   rc   rf   s       r*   test_clip_statistic_rangez2TestConditionalShortcuts.test_clip_statistic_range   s~    y}}$$Q**..4:...26$d;;;6$dKKK	M 	M 	M 	M 	Mr,   N)rQ   rR   rS   rI   markparametrize
_all_modeskeysri   rn   rr   rT   r,   r*   rV   rV   s   s        [VZ__%6%677C C 87C
 [V%N%N%NOOL L POL [V%N%N%NOOM M POM M Mr,   rV   c                   X   e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zej                            dg d          d             Zej                            dg d          ej                            dg d          d                         Zd Zej                            d          ej                            d          ej                            dddg          d                                     Zej                            dddg          d             ZdS )TestStatisticc                     t          j        d                              d          }t          j        |ddd          }t          j        g d          }t          ||           d S )Nd   f)      r   )rN   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                 ?       @      @      @      @      @      @       @      "@      $@      &@      (@      *@      ,@      .@      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   r!   r;   astypere   r"   r   r%   r/   bs      r*   test_check_mean_stat_lengthz)TestStatistic.test_check_mean_stat_length   sm    IcNN!!#&&F1lF
CCCH   & 	1a     r,   c                     t          j        d          }t          j        |dd          }t          j        g d          }t	          ||           d S )Nrz   r|   r   )c   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   rC   r0   r   r.   rZ   r:         rD   r      r9                        r~               r}               rp          !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   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   b   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r!   r;   re   r"   r   r   s      r*   test_check_maximum_1z"TestStatistic.test_check_maximum_1   Z    IcNNF1h	**H5 5 5 & 	1a     r,   c                     t          j        d          dz   }t          j        |dd          }t          j        g d          }t	          ||           d S )Nrz   rC   r|   r   )rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rB  r   s      r*   test_check_maximum_2z"TestStatistic.test_check_maximum_2   s_    IcNNQF1h	**H? ? ? & 	1a     r,   c                     t          j        d          dz   }t          j        |ddd          }t          j        g d          }t	          ||           d S )Nrz   rC   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   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rz   rB  r   s      r*   test_check_maximum_stat_lengthz,TestStatistic.test_check_maximum_stat_length   sd    IcNNQF1h	r:::H? ? ? & 	1a     r,   c                     t          j        d          }t          j        |dd          }t          j        g d          }t	          ||           d S )Nrz   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   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rB  r   s      r*   test_check_minimum_1z"TestStatistic.test_check_minimum_1   sZ    IcNNF1h	**H+ + + & 	1a     r,   c                     t          j        d          dz   }t          j        |dd          }t          j        g d          }t	          ||           d S )Nrz   r0   r|   r   )r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   rz   e   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   r0   rB  r   s      r*   test_check_minimum_2z"TestStatistic.test_check_minimum_2  s_    IcNNQF1h	**H+ + + & 	1a     r,   c                     t          j        d          dz   }t          j        |ddd          }t          j        g d          }t	          ||           d S )Nrz   rC   r|   r   r   r   )rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   rz   r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  r:  rB  r   s      r*   test_check_minimum_stat_lengthz,TestStatistic.test_check_minimum_stat_length  sd    IcNNQF1h	r:::H5 5 5 & 	1a     r,   c                     t          j        d                              d          }t          j        |dd          }t          j        g d          }t          ||           d S )Nrz   r{   r|   r        H@rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  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   rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  rS  r   r   s      r*   test_check_medianzTestStatistic.test_check_median2  sk    IcNN!!#&&F1h))HI I I & 	1a     r,   c                     t          j        g dg dg dg          }t          j        |dd          }t          j        g dg dg dg d	g dg          }t          ||           d S )
Nr   rC   r.   r.   rZ   rD   rD   r   r0   rC   r   )r.   r.   rZ   r.   r.   r   r   rC   r.   r   rZ   r.   rZ   rD   rZ   r   rD   r   r0   r   )r!   r"   re   r   r   s      r*   test_check_median_01z"TestStatistic.test_check_median_01J  s    HiiiIII677F1a""H__________  	1a     r,   c                     t          j        g dg dg dg          }t          j        |j        dd          j        }t          j        g dg dg dg d	g dg          }t	          ||           d S )
NrV  rW  rX  rC   r   )rZ   r.   rZ   r.   rZ   rY  rZ  r[  )r!   r"   re   Tr   r   s      r*   test_check_median_02z"TestStatistic.test_check_median_02X  s    HiiiIII677F138$$&H__________  	1a     r,   c                     t          j        d                              d          }d|d<   d|d<   t          j        |ddd	
          }t          j        g d          }t          ||           d S )Nrz   r{   r   rC   r   r@  r|   r   r   rZ   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   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   s      r*   test_check_median_stat_lengthz+TestStatistic.test_check_median_stat_lengthf  s    IcNN!!#&&!"F1hf===H? ? ? & 	1a     r,   c                     g dg}t          j        |ddd          }t          j        g dg dg dg dg dg dg dg dg dg dg dg dg dg          }t          ||           d S )Nr.   rZ   r:   rZ   r   r   r0   r   )r.   r.   r.   r.   r.   r.   rZ   r:   r:   r:   r:   r:   r:   r:   r:   r!   re   r"   r   r   s      r*   test_check_mean_shape_onez'TestStatistic.test_check_mean_shape_one  s    YYKF1ff!444H:::::::::::::::::::::::::::::::::::::::< " 	1a     r,   c                     t          j        d                              d          }t          j        |dd          }t          j        g d          }t          ||           d S )Nrz   r{   r|   r   rR  r   r   s      r*   test_check_mean_2zTestStatistic.test_check_mean_2  sk    IcNN!!#&&F1h''HI I I & 	1a     r,   rW   )r   r   r   r   c                     t          j        g d          t          j        g dt           j                  z   }t          j        |d|          }t	          |d         |d                    dS )z3 Test that appended and prepended values are equal )r0   rk  )r   g-q=r   r?   rl   r   rk  N)r!   r"   float64re   r   )r%   rW   r/   s      r*   test_same_prepend_appendz&TestStatistic.test_same_prepend_append  sb     H[[[!!BH]]]"*$M$M$MMF1fd##QqT1R5!!!!!r,   r   rE   )rE   )r   rk  ))rZ   r0   )rE   r   ))rB   r0   c                     t          j        d                              d          }d}t          j        t
          |          5  t          j        |d||           d d d            d S # 1 swxY w Y   d S )Nrp   r:   rZ   #index can't contain negative valuesrF   r0   r   r!   r;   r<   rI   rJ   rK   re   )r%   rW   r   arrrG   s        r*   test_check_negative_stat_lengthz-TestStatistic.test_check_negative_stat_length  s    
 imm##F++5]:U333 	: 	:F34[9999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s   A++A/2A/c                    t          j        d          }t          j        |d          }t          j        |ddd          }t          j        g dg dg dg dg d	g d
g dg dg dg dg dg          }t          ||           d S )Nrp   rq  rN   r   r0   r   r   rm   )
r:   r:   r:   rZ   r:   r   r   rD   r   r   )
rC   rC   rC   r   rC   r0   r   r.   r   r   )
r   r   r   r   r   r9   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<   re   r"   r   r   s      r*   test_simple_stat_lengthz%TestStatistic.test_simple_stat_length  s    IbMMJq&!!F1&VFFFH++++++++++++5555555555555555555557  	1a     r,   z)ignore:Mean of empty slice:RuntimeWarningzCignore:invalid value encountered in( scalar)? divide:RuntimeWarningr   r   c                     t          j        ddgd|d          }t          j        t           j        ddt           j        t           j        g          }t	          ||           d S )Nr   r   rC   r0   r   r   )r!   re   r"   nanr   )r%   rW   rt  r&   s       r*   test_zero_stat_length_validz)TestStatistic.test_zero_stat_length_valid  sV     fb"Xvt;;;8RVRRVRV<==S(#####r,   r   r   c                 t   d}t          j        t          |          5  t          j        ddgd|d           d d d            n# 1 swxY w Y   t          j        t          |          5  t          j        ddgd|d           d d d            n# 1 swxY w Y   t          j        t          |          5  t          j        ddgd|d           d d d            n# 1 swxY w Y   t          j        t          |          5  t          j        ddgd|d           d d d            d S # 1 swxY w Y   d S )	Nz,stat_length of 0 yields no value for paddingrF   r   r   r   r   )rC   r   rC   )rI   rJ   rK   r!   re   r%   rW   rG   s      r*   test_zero_stat_length_invalidz+TestStatistic.test_zero_stat_length_invalid  s2   >]:U333 	5 	5FB8Q!4444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5]:U333 	: 	:FB8Q&9999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:]:U333 	5 	5FB8Q!4444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5]:U333 	: 	:FB8Q&9999	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:sG   AA	A	+BBB8CC#&C#D--D14D1N)rQ   rR   rS   r   rC  rF  rH  rK  rN  rP  rT  r\  r_  rb  rg  ri  rI   rs   rt   rm  ru  r{  filterwarningsr  r  rT   r,   r*   rx   rx      s/       ! ! !0! ! !0! ! !0! ! !0! ! !0! ! !0! ! !0! ! !0! ! !! ! !! ! !4! ! !,! ! !0 [V & & &  " " " [V%M%M%MNN[MMM : :  ON:! ! !* [ KLL[M  [Vfh%788$ $ 98  ML
$
 [Vi%;<<	: 	: =<	: 	: 	:r,   rx   c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )TestConstantc                     t          j        d          }t          j        |ddd          }t          j        g d          }t	          ||           d S )Nrz   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   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   r~   rB  r   s      r*   test_check_constantz TestConstant.test_check_constant  s_    IcNNF1h
HEEEH5 5 5 & 	1a     r,   c                     t          j        d          }t          j        |dd          }t          j        g d          }t	          ||           d S )Nrz   r|   r   rJ  rB  r   s      r*   test_check_constant_zerosz&TestConstant.test_check_constant_zeros  sZ    IcNNF1h
++H5 5 5 & 	1a     r,   c                     t          j        d                              dd          }t          j        |ddd          }t          j        g dg d	g d
g dg dg dg dg dg          }t          ||           d S )Nrp   rZ   r:   r}  r   皙?rW   r   )	rC   rC   rC   rC   rC   rC   rC   rC   rC   )	rC   r   rC   r0   r   r.   rZ   rC   rC   )	rC   r:   r   r   rD   r   r   rC   rC   )	rC   r9   r   r   r   r   r   rC   rC   )	rC   r   r   r~   r   r   r   rC   rC   )	rC   r   r}   r   r   r   r   rC   rC   r!   r;   r<   re   r"   r   r%   rt  rg   r&   s       r*   test_check_constant_floatz&TestConstant.test_check_constant_float#  s     imm##Aq))vc6
#&( ( (8111111111111111111111111	3  	h'''''r,   c                 <   t          j        d                              dd          }|                    t           j                  }t          j        |ddd          }t          j        g dg d	g d
g dg dg dg dg dg          }t          ||           d S )Nrp   rZ   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   rl  re   r"   r   )r%   rt  	arr_floatrg   r&   s        r*   test_check_constant_float2z'TestConstant.test_check_constant_float27  s     imm##Aq))JJrz**	vi!1
#&( ( (8LLLLLLLLLLLLLLLLLLLLLLLL	N  	h'''''r,   c                     t          j        dt                    }t          j        |ddd          }t          j        g d          }t          ||           d S )Nrz   r?   r|   r   )皙333333r  )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   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  )r!   r;   r	   re   r"   r   r   s      r*   test_check_constant_float3z'TestConstant.test_check_constant_float3L  si    Ic'''F1h
LIIIHI I I & 	1r,   c           
          t          j        d                              dd          }t          j        |ddd          }t          j        g dg d	g d
g dg dg dg dg          }t          ||           d S )Nrp   rZ   r:   )rC   ro  r   r   r  )
r   r   r   r   r   r   r   r   r   r   )
r   r   r   rC   r0   r   r.   rZ   r   r   )
r   r   r:   r   r   rD   r   r   r   r   )
r   r   r9   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  s       r*   "test_check_constant_odd_pad_amountz/TestConstant.test_check_constant_odd_pad_amountd  s    imm##Aq))vc<j#$& & &85555555555555555555557
 
 	h'''''r,   c                     t          j        d                              dd          }t          j        |ddd          }t          j        g dg dg d	g d
g d
g          }t          ||           d S )Nr.   r0   )r}  rC   r   r   )r}  r   r.   r  )r   rC   rC   r.   r.   r.   )r   r   rC   r.   r.   r.   )r   r0   r   r.   r.   r.   )r   r0   r0   r.   r.   r.   r  r  s       r*   test_check_constant_pad_2dz'TestConstant.test_check_constant_pad_2du  s    ill""1a((vc+**:< < <8	!
 
 	h'''''r,   c                    d}t          j        d|t           j                  }t          j        |dd|                                          }t          j        d|t           j                  }t          ||           d}t          j        d|t           j                  }t          j        |dd|                                          }t          j        d|t           j                  }t          ||           d S )	Nl    rZ   r?   rC   r   r  r   l    )r!   fulluint64re   minr   int64)r%   
uint64_maxrt  rg   r&   	int64_maxs         r*   test_check_large_integersz&TestConstant.test_check_large_integers  s     
ga29555vc1:swwyyIII71j	:::4***	ga"(333vc1:swwyyIII71irx8884*****r,   c                 B   t          j        dt                    }t                      }||d<   t                      }t                      }t          j        |dd||f          }t          j        dt                    }||d<   ||d<   ||d<   t	          ||           d S )NrC   r?   r   r   )	pad_widthrW   r   ry  r0   )r!   r   r#   re   r   )r%   rt  obj_aobj_bobj_cr&   s         r*   test_check_object_arrayz$TestConstant.test_check_object_array  s    hq'''AfSAJ&+U^5 5 5 8D///3)))))r,   c                 z    t          j        d          }t          j        |g dd          }|j        dk    sJ d S )Nr   r   r0   r   ro  r  r   rb   r   r.   r.   r!   zerosre   rd   r%   rt  r(   s      r*   test_pad_empty_dimensionz%TestConstant.test_pad_empty_dimension  sG    hy!!///jAAA|y((((((r,   N)rQ   rR   rS   r  r  r  r  r  r  r  r  r  r  rT   r,   r*   r  r    s        ! ! !0! ! !0( ( ((( ( (*  0( ( ("( ( (+ + +* * * ) ) ) ) )r,   r  c                       e Zd Zd Zd Zej                            ef          d             Z	d Z
ej                            de          d             ZdS )	TestLinearRampc                     t          j        d                              d          }t          j        |ddd          }t          j        g d          }t          ||dd	           d S )
Nrz   r{   r|   r   )r.   rZ   )r   )r   gQ@gq=
ףp@g)\(@gzG
@g	@gRQ@g
ףp=
@g(\@g{Gz@g333333@gQ@gp=
ף @gQ?g)\(?g?g
ףp=
?g{Gz?gQ?gQ?g?g{Gz?gQ?g{Gz?g{Gz?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   g33333W@gffffffV@g9U@gT@g     R@g33333Q@gfffffP@g33333N@gYL@r   gfffffG@gLE@g33333B@g@@g     <@g7@g3@g,@gffffff#@r   gh㈵>)rtolatol)r!   r;   r   re   r"   r   r   s      r*   test_check_simplez TestLinearRamp.test_check_simple  sw    IcNN!!#&&F1h&AAAHF F F & 	14d333333r,   c                 8   t          j        d                              dd                              t           j                  }t          j        |ddd          }t          j        g dg d	g d
g dg dg dg dg dg          }t          ||           d S )Nr~   r.   rZ   )r0   r0   r   r\   rW   r   )	r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   g      ?r   r   r   )	r   r   r   r   r   r   r   r   r   )	r   g      @r   r   r   r   r   g      @r   )	r   r   r   r   r   r   r   r   r   )	r         @r   r   r   r   r         #@r   )	r   g      @r  r   g      !@r   r  g      @r   r  r  s       r*   test_check_2dzTestLinearRamp.test_check_2d  s    imm##Aq))00<<vc6&III8BBBBBBBBBBBBBBBBBBBBBBBBDE E 	h'''''r,   )
exceptionsc                 x   ddl m} t          j         |dd           |dd          g          }t          j        |ddd          }t          j         |dd	           |d
d	           |dd	           |dd	           |dd	           |dd	           |dd	          g          }t          ||           d S )Nr   )FractionrC   r0   rk  rN   r   r  r9   r   r:   rB   rE   )	fractionsr  r!   r"   re   r   )r%   r  rt  actualr&   s        r*   test_object_arrayz TestLinearRamp.test_object_array  s    &&&&&&hAQ899V-AFFF 8HaHaHaHRHRHRHR
   	VX&&&&&r,   c                 P   t          j        t          j        d                              dd          dd          }t	          |dddf         d	           t	          |ddd
f         d	           t	          |dddf         d	           t	          |d
ddf         d	           dS )z!Ensure that end values are exact.r   r0   rZ   )   {   r   rb   Nr   r   rk  )r!   re   rO   r<   r   )r%   r/   s     r*   test_end_valueszTestLinearRamp.test_end_values  s    F272;;&&q!,,j}MMMQqqq!tWb!!!Qqqq"uXr"""Qq!!!tWb!!!Qr111uXr"""""r,   r@   c                 b   t          j        dg|          }t          j        |ddd          }t          j        g d|          }t          ||           t          j        dg|          }t          j        |ddd          }t          j        g d|          }t          ||           dS )	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.
        r   r?   r   r   r  )r   rC   r0   r   r0   rC   r   )r   r0   rC   r   rC   r0   r   N)r!   r"   re   r   )r%   r@   r'   r(   r&   s        r*   test_negative_differencez'TestLinearRamp.test_negative_difference  s     HaS&&&1=Q???8111???VX&&&HaS&&&1=Q???8111???VX&&&&&r,   N)rQ   rR   rS   r  r  rI   rs   xfailAssertionErrorr  r  rt   _numeric_dtypesr  rT   r,   r*   r  r    s        4 4 40( ( ( [>"344' ' 54'$# # # [Wo66' ' 76' ' 'r,   r  c                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )TestReflectc                     t          j        d          }t          j        |dd          }t          j        g d          }t	          ||           d S )Nrz   r|   r   )r}   r   r   r   r   r~   r   r   r   r   r   r   r   r9   r   r   rD   r   r   r:   rZ   r.   r   r0   rC   r   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   rA  r@  r?  r>  r=  r<  r;  r:  r9  r8  r7  r6  r5  r4  r3  r2  r1  r0  r/  r.  rB  r   s      r*   r  zTestReflect.test_check_simple  rD  r,   c                     t          j        d          }t          j        |ddd          }t          j        g d          }t	          ||           d S )Nrz   r|   r   oddr   )ir  rB   rA   rE   rk  r   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   rz   rM  f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   rB  r   s      r*   test_check_odd_methodz!TestReflect.test_check_odd_method  s_    IcNNF1h	>>>H? ? ? & 	1a     r,   c                     g dg dg}t          j        |dd          }t          j        g dg dg dg dg dg dg dg dg dg dg dg dg dg dg          }t          ||           d S )Nrd  r:   r   r   re  r   )r   r:   r   r   r   r:   r   r   r   r:   r   r   r   r:   r   rZ   r.   rZ   r:   rZ   r.   rZ   r:   rZ   r.   rZ   r:   rZ   r.   rZ   rf  r   s      r*   test_check_large_padz TestReflect.test_check_large_pad+  s    YY			"F1fi((H::::::::::::::::::::::::::::::::::::::::::< $ 	1a     r,   c                     g dg}t          j        |dd          }t          j        g dg dg dg dg dg dg dg dg dg dg dg dg dg          }t          ||           d S )Nrd  re  r   r  rf  r   s      r*   test_check_shapezTestReflect.test_check_shapeB  s    YYKF1fi((H:::::::::::::::::::::::::::::::::::::::< " 	1a     r,   c                     t          j        g ddd          }t          j        g d          }t          ||           d S )NrC   r0   r   r0   r   )r   r0   rC   r0   r   r0   rC   rf  r   s      r*   test_check_01zTestReflect.test_check_01X  sE    F999a++H***++1a     r,   c                     t          j        g ddd          }t          j        g d          }t          ||           d S )Nr  r   r   )	r0   r   r0   rC   r0   r   r0   rC   r0   rf  r   s      r*   test_check_02zTestReflect.test_check_02]  sE    F999a++H000111a     r,   c                     t          j        g ddd          }t          j        g d          }t          ||           d S )Nr  r.   r   )rC   r0   r   r0   rC   r0   r   r0   rC   r0   r   rf  r   s      r*   test_check_03zTestReflect.test_check_03b  sE    F999a++H666771a     r,   c                     t          j        g dddgd          }t          j        g d          }t          ||           d S )Nr  rC   r   r   )r0   rC   r0   r   r0   rC   r0   r   r0   rC   r0   r   r0   rC   rf  r   s      r*   test_check_04zTestReflect.test_check_04g  sI    F999q"gy11H???@@1a     r,   c                     t          j        g dddgd          }t          j        g d          }t          ||           d S )NrC   r0   r   r.   r  r   r   );r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   r   r.   r   r0   rC   r0   rf  r   s      r*   test_check_05zTestReflect.test_check_05l  sU    F<<<"b955H( ( () ) 	1a     r,   c                     t          j        g dddgd          }t          j        g d          }t          ||           d S )Nr  r   r0   r   )r0   r   r.   r.   r   r0   rC   rC   r0   r   r.   r.   r   r0   rC   rC   r0   r   r.   r.   r   rf  r   s      r*   test_check_06zTestReflect.test_check_06w  sU    F<<<"a+66H  
 

 	1a     r,   c                     t          j        g dddgd          }t          j        g d          }t          ||           d S )N)rC   r0   r   r.   rZ   r:   r  r   r   )6r.   rZ   r:   r:   rZ   r.   r   r0   rC   rC   r0   r   r.   rZ   r:   r:   rZ   r.   r   r0   rC   rC   r0   r   r.   rZ   r:   r:   rZ   r.   r   r0   rC   rC   r0   r   r.   rZ   r:   r:   rZ   r.   r   r0   rC   rC   r0   r   r.   rZ   r:   r:   rZ   r.   rf  r   s      r*   test_check_07zTestReflect.test_check_07  sX    F%%%Aw<<H    	1a     r,   N)rQ   rR   rS   r  r  r  r  r  r	  r  r  r  r  r  rT   r,   r*   r  r    s        ! ! !0! ! !0! ! !.! ! !,! ! !
! ! !
! ! !
! ! !
	! 	! 	!! ! !	! 	! 	! 	! 	!r,   r  c                      e Zd ZdZej                            d ee	                                ddhz
                      d             Z
ej                            de	                                          d             ZdS )TestEmptyArrayz<Check how padding behaves on arrays with an empty dimension.rW   r   r   c                    d}t          j        t          |          5  t          j        g d|           d d d            n# 1 swxY w Y   t          j        t          |          5  t          j        t          j        d          d|           d d d            n# 1 swxY w Y   t          j        t          |          5  t          j        t          j        d          d|           d d d            d S # 1 swxY w Y   d S )NzFcan't extend empty axis 0 using modes other than 'constant' or 'empty'rF   r.   rb   r   )r   r   )r  r  )rI   rJ   rK   r!   re   ndarrayr  r  s      r*   r  z'TestEmptyArray.test_pad_empty_dimension  s   ]:U333 	% 	%F2qt$$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%]:U333 	0 	0F2:a==!$////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0]:U333 	> 	>F28F##\====	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s5   AA	A(*BB"%B"*C;;C?C?c                 r    t          j        t          j        d          d|          }|j        dk    sJ d S )N)r0   r   r0   )ry  r  r  rb   )r   r   r.   )r!   re   rO   rd   )r%   rW   r(   s      r*   test_pad_non_empty_dimensionz+TestEmptyArray.test_pad_non_empty_dimension  s<    	**,>TJJJ|y((((((r,   N)rQ   rR   rS   __doc__rI   rs   rt   sortedru   rv   r  r  rT   r,   r*   r  r    s        FF[ 	z((J+@@AA 
> > 
> [VZ__%6%677) ) 87) ) )r,   r  c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
TestSymmetricc                     t          j        d          }t          j        |dd          }t          j        g d          }t	          ||           d S )Nrz   r|   r   )r   r   r   r   r~   r   r   r   r   r   r   r   r9   r   r   rD   r   r   r:   rZ   r.   r   r0   rC   r   r   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   r   rA  r@  r?  r>  r=  r<  r;  r:  r9  r8  r7  r6  r5  r4  r3  r2  r1  r0  r/  rB  r   s      r*   r  zTestSymmetric.test_check_simple  sZ    IcNNF1h,,H5 5 5 & 	1a     r,   c                     t          j        d          }t          j        |ddd          }t          j        g d          }t	          ||           d S )Nrz   r|   r   r  r  )r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rB   rA   rE   rk  r   r   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   r   rz   rM  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rB  r   s      r*   r  z#TestSymmetric.test_check_odd_method  s_    IcNNF1h%@@@H? ? ? & 	1a     r,   c                     g dg dg}t          j        |dd          }t          j        g dg dg dg dg dg dg dg dg dg dg dg dg dg dg          }t          ||           d S )Nrd  r   re  r   rZ   r:   r:   rZ   r.   r.   rZ   r:   r:   rZ   r.   r.   rZ   r:   r:   )r   r   r   r   r:   r:   r   r   r   r   r:   r:   r   r   r   rf  r   s      r*   r  z"TestSymmetric.test_check_large_pad  s    YY			"F1fk**H::::::::::::::::::::::::::::::::::::::::::< & 	1a     r,   c                     g dg dg}t          j        |ddd          }t          j        g dg dg dg dg d	g d	g d
g d
g dg dg dg dg dg dg          }t          ||           d S )Nrd  r   re  r   r  r  )rA   rE   rE   rk  r   r   rC   r0   r0   r   r.   r.   rZ   r:   r:   )rk  r   r   rC   r0   r0   r   r.   r.   rZ   r:   r:   r   r   r   )rC   r0   r0   r   r.   r.   rZ   r:   r:   r   r   r   rD   r   r   )r   r.   r.   rZ   r:   r:   r   r   r   rD   r   r   r   r9   r9   )rZ   r:   r:   r   r   r   rD   r   r   r   r9   r9   r   r   r   )r   r   r   rD   r   r   r   r9   r9   r   r   r   r   r   r   )rD   r   r   r   r9   r9   r   r   r   r   r   r   r   r   r   rf  r   s      r*   test_check_large_pad_oddz&TestSymmetric.test_check_large_pad_odd  s    YY			"F1fk>>>HIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIK $ 	1a     r,   c                     g dg}t          j        |dd          }t          j        g dg dg dg dg dg dg dg dg dg dg dg dg dg          }t          ||           d S )Nrd  re  r   r"  rf  r   s      r*   r  zTestSymmetric.test_check_shape  s    YYKF1fk**H:::::::::::::::::::::::::::::::::::::::< " 	1a     r,   c                     t          j        g ddd          }t          j        g d          }t          ||           d S )Nr  r0   r   )r0   rC   rC   r0   r   r   r0   rf  r   s      r*   r  zTestSymmetric.test_check_01  sE    F999a--H***++1a     r,   c                     t          j        g ddd          }t          j        g d          }t          ||           d S )Nr  r   r   )	r   r0   rC   rC   r0   r   r   r0   rC   rf  r   s      r*   r	  zTestSymmetric.test_check_02  sE    F999a--H000111a     r,   c                     t          j        g ddd          }t          j        g d          }t          ||           d S )Nr  r:   r   )rC   r0   r   r   r0   rC   rC   r0   r   r   r0   rC   rC   r0   r   rf  r   s      r*   r  zTestSymmetric.test_check_03$  sE    F999a--HBBBCC1a     r,   N)rQ   rR   rS   r  r  r  r$  r  r  r	  r  rT   r,   r*   r  r    s        ! ! !0! ! !0! ! !0! ! !.! ! !,! ! !
! ! !
! ! ! ! !r,   r  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	TestWrapc                     t          j        d          }t          j        |dd          }t          j        g d          }t	          ||           d S )Nrz   r|   r   )r*  r+  r,  r-  r.  r/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   r   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   r~   r   r   r   r   r}   r   r   r   r   rp   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/  r0  r1  r2  r3  r4  r5  r6  r7  r8  r9  r:  r;  r<  r=  r>  r?  r@  rA  r   r   rC   r0   r   r.   rZ   r:   r   r   rD   r   r   r9   r   r   r   r   r   r   r   rB  r   s      r*   r  zTestWrap.test_check_simple+  sZ    IcNNF1h''H5 5 5 & 	1a     r,   c                 b   t          j        d          }t          j        |d          }t          j        |dd          }t          j        g dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg dg          }t          ||           d S )Nr9   r  )r   r9   r   )r   r   r   rD   r   r   r   rD   r   r   r   rD   r   r   r   rD   r   r   r   rD   r   r   r   rD   r   r   )r0   r   r   rC   r0   r   r   rC   r0   r   r   rC   r0   r   r   rC   r0   r   r   rC   r0   r   r   rC   r0   r   )r:   r   r.   rZ   r:   r   r.   rZ   r:   r   r.   rZ   r:   r   r.   rZ   r:   r   r.   rZ   r:   r   r.   rZ   r:   r   rz  r   s      r*   r  zTestWrap.test_check_large_padC  s   IbMMJq&!!F1h''H. . .) ) )) ) ). . .) ) )) ) ). . .) ) )) ) ). . .) ) )) ) ). . .) ) )) ) ). . .) ) )) ) ). . .) ) )) ) ). . .) ) )) ) ). . .e3/5 5l 	1a     r,   c                     t          j        g ddd          }t          j        g d          }t          ||           d S )Nr  r   r   )	rC   r0   r   rC   r0   r   rC   r0   r   rf  r   s      r*   r  zTestWrap.test_check_01  sE    F999a((H000111a     r,   c                     t          j        g ddd          }t          j        g d          }t          ||           d S )Nr  r.   r   )r   rC   r0   r   rC   r0   r   rC   r0   r   rC   rf  r   s      r*   r	  zTestWrap.test_check_02  sE    F999a((H666771a     r,   c                     t          j        d          }t          j        |dd          }t          ||d dd df                    d S )Nra  )r   rZ   r   rb   r  )r!   rO   re   r   r   s      r*   test_pad_with_zerozTestWrap.test_pad_with_zero  sK    GFOOF1f6***1aSbSk*****r,   c                 b   t          j        d          }t          j        |dd          }t          t           j        ||||f         dd         |           t          j        d          }t          j        |dd          }t          t           j        ||||f         dd         |           dS )	zy
        Check wrapping on each side individually if the wrapped area is longer
        than the original array.
        rZ   )r9   r   r   rb   r   N)r   r9   rA   )r!   r;   re   r   r_r   s      r*   test_repeated_wrappingzTestWrap.test_repeated_wrapping  s    
 IaLLF1gF+++25Aq!,QRR0!444IaLLF1gF+++25Aq!,SbS1155555r,   c           	          t          j        d                              dd          }t          j        |ddgd          }t          j        g dg dg dg dg dg dg          }t          ||           d	S )
z
        Assert that 'wrap' pads only with multiples of the original area if
        the pad width is larger than the original array.
        r.   r0   r  r   rC   r   rb   )r   r0   r   r0   r   r0   )rC   r   rC   r   rC   r   Nrz  r   s      r*   &test_repeated_wrapping_multiple_originz/TestWrap.test_repeated_wrapping_multiple_origin  s    
 IaLL  A&&F1vv&V444H!
 
 	1a     r,   N)
rQ   rR   rS   r  r  r  r	  r0  r3  r6  rT   r,   r*   r*  r*  *  s~        ! ! !0:! :! :!x! ! !
! ! !
+ + +
6 6 6! ! ! ! !r,   r*  c                       e Zd Zd Zd ZdS )TestEdgec                    t          j        d          }t          j        |d          }t          j        |dd          }t          j        g dg dg dg dg dg dg dg dg dg	          }t          ||           d S 	Nr9   r.   r   rw  r   )r   r   r   r   rC   r0   r0   r0   )r   r   r   r   r.   rZ   rZ   rZ   )r:   r:   r:   r:   r   r   r   r   )rD   rD   rD   rD   r   r   r   r   rz  r   s      r*   r  zTestEdge.test_check_simple  s    IbMMJq&!!F1&//H%%%%%%%%%%%%%%%))))))))))))
+  	1a     r,   c                     t          j        g d          }t          j        |dd          }t          j        g d          }t          ||           t          j        g dg dg          }t          j        |dd          }t          j        |dd          }t          ||           t          j        d                              dd	d
          }t          j        |dd          }t          j        |dd          }t          ||           d S )Nr  )r}  r   )rC   rC   r0   r   r   r   rd  r  r   r0   r   r.   )r}  r}  r}  )r!   r"   re   r   r;   r<   )r%   r/   paddedr&   s       r*   test_check_width_shape_1_2z#TestEdge.test_check_width_shape_1_2  s     HYYY9f--8...//68,,,Hiii+,,9f--6!-v6668,,,IbMM!!!Q**9f--6!5v>>68,,,,,r,   N)rQ   rR   rS   r  r>  rT   r,   r*   r8  r8    s2        ! ! !&- - - - -r,   r8  c                       e Zd Zd Zd ZdS )	TestEmptyc                     t          j        d                              dd          }t          j        |ddgd          }|j        dk    sJ t          ||d	d
ddf                    d S )Nr   r.   r:   rN   r5  r   rb   )rD   r   r0   rA   r   rk  r!   r;   r<   re   rd   r   r  s      r*   test_simplezTestEmpty.test_simple  st    imm##Aq))ff-G<<<|w&&&&S&2qt,-----r,   c                 z    t          j        d          }t          j        |g dd          }|j        dk    sJ d S )Nr  r  r   rb   r  r  r  s      r*   r  z"TestEmpty.test_pad_empty_dimension  sG    hy!!///g>>>|y((((((r,   N)rQ   rR   rS   rC  r  rT   r,   r*   r@  r@    s2        . . .) ) ) ) )r,   r@  c            	          d } t          j        d                              dd          }t          j        |d|           }t          j        g dg dg dg dg dg dg          }t          ||           d S )Nc                 <    d| d |d         <   d| |d          d <   d S )Nr   r   rC   rT   )vectorr  iaxiskwargss       r*   _padwithtensz6test_legacy_vector_functionality.<locals>._padwithtens  s.     "}	!}!#	!}~~r,   r:   r0   r   )r   r   r   r   r   r   r   )r   r   r   rC   r0   r   r   )r   r   r   r.   rZ   r   r   rz  )rJ  r/   r   s      r*    test_legacy_vector_functionalityrK    s    $ $ $ 		!Q""A
q!\""A
	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%	%	'		
 		
A q!r,   c                      t          j        dgdd          } t          j        g d          }t          | |           d S )NrC   r0   r   rb   )r   r   rC   r   r   rf  )r/   r   s     r*   test_unicode_moderM    sC    
sAJ'''A
!!Aq!r,   rW   )r   r   r   r   c                     t          j        dd           }d}t          j        dd           }t          t          j        |||           |           d S )Nr;  )
fill_valuerw  )rD   r   rb   )r!   r  r   re   )rW   r/   rh   r   s       r*   test_object_inputrP    sX     	4(((AG
4(((Arvat444a88888r,   c                      e Zd Zej                            dg d          ej                            de                                          d                         Zej                            de                                          d             Z	ej                            dg d          ej                            de                                          d                         Z
ej                            dd	d
d e            dfddef edd          dfdg          ej                            de                                          d                         Zd Zej                            dg d          ej                            de                                          d                         ZdS )TestPadWidthr  ))r.   rZ   r:   r   )r  ro  ry  )r}  r  )rZ   r:   ))r   r.   rZ   )r   rC   r0   rW   c                     t          j        d                              d          }d}t          j        t
          |          5  t          j        |||           d d d            d S # 1 swxY w Y   d S )Nrp   rq  z(operands could not be broadcast togetherrF   rs  r%   r  rW   rt  rG   s        r*   test_misshaped_pad_widthz%TestPadWidth.test_misshaped_pad_width  s     imm##F++:]:U333 	) 	)F3	4(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)   A))A-0A-c                     t          j        d                              d          }d}t          j        t
          |          5  t          j        |d|           d d d            d S # 1 swxY w Y   d S )Nrp   rq  zDinput operand has more dimensions than allowed by the axis remappingrF   ))ry  )r.   )rZ   )r  r  ro  rs  )r%   rW   rt  rG   s       r*   test_misshaped_pad_width_2z'TestPadWidth.test_misshaped_pad_width_2  s    imm##F++]:U333 	H 	HF3@$GGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	HrV  rn  c                     t          j        d                              d          }d}t          j        t
          |          5  t          j        |||           d d d            d S # 1 swxY w Y   d S )Nrp   rq  rr  rF   rs  rT  s        r*   test_negative_pad_widthz$TestPadWidth.test_negative_pad_width  s     imm##F++5]:U333 	) 	)F3	4(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)rV  zpad_width, dtype)3N)wordNr3   N)g333333@N))r0   r   r.   rx  rC   rk  )))g r   rx  Nc                 f   t          j        d                              d          }d}|`t          j        t
          |          5  t          j        |t          j        ||          |           d d d            d S # 1 swxY w Y   d S t          j        t
          |          5  t          j        |||           d d d            n# 1 swxY w Y   t          j        t
          |          5  t          j        |t          j        |          |           d d d            d S # 1 swxY w Y   d S )Nrp   rq  z%`pad_width` must be of integral type.rF   r?   )r!   r;   r<   rI   rJ   	TypeErrorre   r"   )r%   r  r@   rW   rt  rG   s         r*   test_bad_typezTestPadWidth.test_bad_type#  s    imm##F++7y666 D DsBHYe<<<dCCCD D D D D D D D D D D D D D D D D D y666 - -sIt,,,- - - - - - - - - - - - - - -y666 7 7sBHY//6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7s6   +A??BB'C

CC0)D&&D*-D*c                 &   t          j        d          }t          j        |d          }t          j        |t          j        d          d          }t          j        g dg dg dg dg dg dg dg dg dg	          }t          ||           d S r:  rz  r   s      r*   test_pad_width_as_ndarrayz&TestPadWidth.test_pad_width_as_ndarray;  s    IbMMJq&!!F1bh/00&99H000000000000000000000000000
2  	1a     r,   )r   r\   )r\   r\   c                     t          j        d                              dd          }t          |t          j        |||                     d S )Nrp   r:   rZ   rb   )r!   r;   r<   r   re   )r%   r  rW   rt  s       r*   test_zero_pad_widthz TestPadWidth.test_zero_pad_widthN  sH     imm##Aq))3sID A A ABBBBBr,   )rQ   rR   rS   rI   rs   rt   ru   rv   rU  rX  rZ  r#   r
   r_  ra  rc  rT   r,   r*   rR  rR    s'       [[ + + +   [VZ__%6%677) ) 87 ) [VZ__%6%677H H 87H [KKKM M[VZ__%6%677) ) 87M M) [/	4	f%	B#	2 	 	 [VZ__%6%6777 7 87	 	7! ! !& [[*G*G*GHH[VZ__%6%677C C 87 IHC C Cr,   rR  c                    t           |          }i }t                                           D ]}||k    r|                    |           t          j        g dd| fi | |                                D ]e\  }}d                    |           }t          j        t          |          5  t          j        g dd| fi ||i ddd           n# 1 swxY w Y   fdS )z1Test behavior of pad's kwargs for the given mode.r  rC   z+unsupported keyword arguments for mode '{}'rF   N)
ru   valuesupdater!   re   itemsformatrI   rJ   rK   )rW   allowednot_allowedrI  keyvaluerG   s          r*   test_kwargsrm  U  s9    GK##%% ' 'Wv&&&F999a)))))!'')) 7 7
U=DDTJJ]:U333 	7 	7F999a66#u666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	77 7s   &CC	C	c                  |    t          j        ddg          } t          t          j        | d          g d           d S )NrC   r0   )r   r   rC   rC   r   r   )r!   r"   r   re   )rt  s    r*   test_constant_zero_defaultro  f  s<    
(Aq6

Crvc1~~'9'9'9:::::r,   rC   constTFc                     d                     |           }t          j        t          |          5  t	          j        g dd|            d d d            d S # 1 swxY w Y   d S )Nzmode '{}' is not supportedrF   r  r.   rb   )rh  rI   rJ   rK   r!   re   )rW   rG   s     r*   test_unsupported_moderr  k  s    '..t44E	z	/	/	/ ( (
yyy!$''''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (s   AAAc                     t          j        d                              dd          d d dd d df         }t          j        |d|           }|j        dk    sJ t          |ddddf         |           d S )Nr   r.   r:   r0   rN   )r   r   rA   rB  )rW   rt  r(   s      r*   test_non_contiguous_arrayrt  r  s    
)B--

1
%
%ccc33Q3h
/CVC&&F<6!!!!"ad
#S)))))r,   c                     t          j        dd          }t          j        |d|           j        d         sJ t          j        dd          }t          j        |d|           j        d         sJ dS )	z5Test if C and F order is preserved for all pad modes.)rZ   r   C)orderrZ   C_CONTIGUOUSFF_CONTIGUOUSN)r!   rO   re   flags)rW   r'   s     r*   test_memory_layout_persistencer|  z  sv     	s###A6!Q#N3333
s###A6!Q#N333333r,   r@   c                 z    t          j        d|           }t          j        |d|          }|j        | k    sJ d S )N)r   r0   rC   r?   rC   rb   )r!   r  re   r@   )r@   rW   rt  r(   s       r*   test_dtype_persistencer~    sG     (9E
*
*
*CVC&&&F<5      r,   )'r  rI   numpyr!   numpy.testingr   r   r   numpy.lib._arraypad_implr   _coresctypesr  ru   r   rV   rx   r  r  r  r  r  r*  r8  r@  rK  rM  rs   rt   rP  rR  rv   rm  ro  r#   rr  rt  r|  r~  rT   r,   r*   <module>r     s         K K K K K K K K K K . . . . . . HVhuhw  	hy!"  #A& !$t$D!d#t$' &) 
P* P* P* P* P* P* P* P*fM M M M M M M M,f: f: f: f: f: f: f: f:Rp) p) p) p) p) p) p) p)fR' R' R' R' R' R' R' R'jO! O! O! O! O! O! O! O!d) ) ) ) ) ) ) )0C! C! C! C! C! C! C! C!L@! @! @! @! @! @! @! @!F$- $- $- $- $- $- $- $-N
) 
) 
) 
) 
) 
) 
) 
)  (   !I!I!IJJ9 9 KJ9NC NC NC NC NC NC NC NCb !2!2337 7 437 ; ; ;
 !WffhhdE!JKK( ( LK( !2!233* * 43* !2!2334 4 434 /22!2!233! ! 43 32! ! !r,   