o 6a @sdZddlZddlZddlmZmZmZddlm Z ej dej dej dej dZ d diid did did did did did d id d iiid Z GdddZ GdddZGdddZGdddZGdddZGdddZGdddZGdddZGdd d ZGd!d"d"ZGd#d$d$Zd%d&Zd'd(Zejd)gd*d+d,ZGd-d.d.Zejd)e d/d0Zd1d2Z ejd)d3d4e!dd5d6gd7d8Z"ejd)e d9d:Z#ejd)e d;d<Z$ejd=e ejd)e d>d?Z%dS)@z(Tests for the array padding functions. N)assert_array_equalassert_allclose assert_equal) _as_pairsuintintfloatcomplexconstant_values end_values stat_length reflect_typeeven) constantedge linear_rampmaximummeanmedianminimumreflect symmetricwrapemptyc@<eZdZddZddZddZddZd d Zd d Zd S) TestAsPairscCshtddggd}ddgdggfD] }t|d}t||qt}tt|dt||ggddS)z Test casting for a single value. Nnparrayrrobjectselfexpectedxresultobjr(?/usr/lib/python3/dist-packages/numpy/lib/tests/test_arraypad.pytest_single_value!s  zTestAsPairs.test_single_valuecCstddggd}ddgddggfD] }t|d}t||qt}ttd|gdtd|ggdttdgdggdtddgddggttdg|ggdtddg||ggdS)z-Test proper casting for two different values.rraNrr"r(r(r)test_two_values.s"   zTestAsPairs.test_two_valuescCs0d}ttdddd|ttdddd|dS)N)NNr/r/rFas_indexT)rrr#r$r(r(r)test_with_noneGs  zTestAsPairs.test_with_nonecCs$tdd}tt|d|dS)z?Test if `x` already matching desired output are passed through. )r-r5N)rarangereshaperrr2r(r(r)test_pass_throughRs zTestAsPairs.test_pass_throughc Csttddgdddtjddggdtjdttddgdddtjdd ggdtjdd d gd ggd d gdd gd d ggd d ggd d ggdd dggfD] }tjtddt|dddWdn1sjwYqOdS)z Test results if `as_index=True`.g@gffffff @rTr0rdtypeg(\@r+r- znegative valuesmatchN)rrrr intppytestraises ValueError)r#r%r(r(r) test_as_indexZs (zTestAsPairs.test_as_indexcCstjtddtdgggdWdn1swYtjtddtddgdd ggdWdn1stdddd}dd|jD}t|tj|||ddS)Nxr+r5cSg|]}dqS)rrr(.0_r(r(r) wzHTestConditionalShortcuts.test_zero_padding_shortcuts..rNrr6r7shaperpadr#rNtestpad_amtr(r(r)test_zero_padding_shortcutstsz4TestConditionalShortcuts.test_zero_padding_shortcuts)rrrrcCsLtdddd}dd|jD}ttj||ddtj|||d d dS) NrOr+rPr5cSrQ)r=r=r(rSr(r(r)rV}rWzITestConditionalShortcuts.test_shallow_statistic_range..rrXr=rNr rYr\r(r(r)test_shallow_statistic_rangezs z5TestConditionalShortcuts.test_shallow_statistic_rangecCsJtddd}dd|jD}ttj|||dtj|||dddS)NrPr5cSrQ))rrr(rSr(r(r)rVrWzFTestConditionalShortcuts.test_clip_statistic_range..rXrarYr\r(r(r)test_clip_statistic_ranges z2TestConditionalShortcuts.test_clip_statistic_rangeN) rJrKrLrCmark parametrize _all_modeskeysr_rbrdr(r(r(r)rMss  rMc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZejdgdddZejdgdejdgd d!d"Zd#d$Zejd%ejd&ejdd'd(gd)d*Zejdd+d,gd-d.Zd/S)0 TestStatisticcCs>tdd}tj|dddd}tgd}t||dS)Ndf)r)rGr )?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@rrrrrrrrrrrrrrrrrrrrrr6astyper[r rr#r,br(r(r)test_check_mean_stat_lengths z)TestStatistic.test_check_mean_stat_lengthcC4td}t|dd}tgd}t||dS)Nrjrlr)crrrrrrrrrrrrrrrrrrrrrrrrrr=r-rr+rPr5r>r r4 rnrmrc !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abrrrrrrrrrrrrrrrrrrrrrrr6r[r rrr(r(r)test_check_maximum_1 z"TestStatistic.test_check_maximum_1cC8tdd}t|dd}tgd}t||dS)Nrjr=rlr)rjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjr2rr(r(r)test_check_maximum_2 z"TestStatistic.test_check_maximum_2cC<tdd}tj|dddd}tgd}t||dS)Nrjr=rlrrro)rrrrrrrrrrrrrrrrrrrrrrrrrr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjrjr2rr(r(r)test_check_maximum_stat_length z,TestStatistic.test_check_maximum_stat_lengthcCr)Nrjrlrrrrrrrrrrrrrrrrrrrrrrrrrrrr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrrrrrrrrrrrrrrrrrrrrr2rr(r(r)test_check_minimum_1r4z"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+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrjer-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r-r2rr(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+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrjr*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r*r2rr(r(r)test_check_minimum_stat_lengthr:z,TestStatistic.test_check_minimum_stat_lengthcC:tdd}t|dd}tgd}t||dS)NrjrkrlrH@rBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrqrrrsrtrurvrwrxryrzr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrBrrr(r(r)test_check_median2 zTestStatistic.test_check_mediancCs`tgdgdgdg}t|dd}tgdgdgdgd gdg}t||dS) Nrr=r+r+rPr>r>rr-r=r)r+r+rPr+r+rrr=r+rrPr+rPr>rPrr>rr-r)rr r[rrr(r(r)test_check_median_01Js z"TestStatistic.test_check_median_01cCsdtgdgdgdg}t|jddj}tgdgdgdgd gdg}t||dS) NrErFrGr=r)rPr+rPr+rPrHrIrJ)rr r[Trrr(r(r)test_check_median_02Xs z"TestStatistic.test_check_median_02cCsNtdd}d|d<d|d<tj|ddd d }tgd }t||dS) Nrjrkrsr=rr0rlrrrPro)rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrqrsrsrtrurvrwrxryrzr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr(r(r)test_check_median_stat_lengthfsz+TestStatistic.test_check_median_stat_lengthcCsgdg}tj|dddd}tgdgdgdgdgdgdgdgdgdgdgdgdgdg }t||dS)Nr+rPr5rPrrr-ro)r+r+r+r+r+r+rPr5r5r5r5r5r5r5r5rr[r rrr(r(r)test_check_mean_shape_ones& z'TestStatistic.test_check_mean_shape_onecCr@)NrjrkrlrrArrr(r(r)test_check_mean_2rDzTestStatistic.test_check_mean_2rN)rrrrcCsFtgdtjgdtjd}t|d|}t|d|ddS)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_appends" z&TestStatistic.test_same_prepend_appendr r?)r?)rrU))rPr-)r?r))r<r-cCsZtdd}d}tjt|dtj|d||dWddS1s&wYdS)Nrcr5rP#index can't contain negative valuesr@r-rorr6r7rCrDrEr[)r#rNr arrrAr(r(r)test_check_negative_stat_lengths "z-TestStatistic.test_check_negative_stat_lengthcCstd}t|d}tj|dddd}tgdgdgdgdgd gd gd gd gd gd gd g }t||dS) NrcrZrGrr-rrra) r5r5r5rPr5rrr>rr) r=r=r=rr=r-rr+rr) rrrrrr4rrrr) rrrrrrrrrr) rrrrnrrrrrr) rrrrmrrrrrrrr6r7r[r rrr(r(r)test_simple_stat_lengths$  z%TestStatistic.test_simple_stat_lengthz)ignore:Mean of empty slice:RuntimeWarningzOignore:invalid value encountered in (true_divide|double_scalars):RuntimeWarningrrcCs>tjddgd|dd}ttjddtjtjg}t||dS)Nrrrsr=r-rro)rr[r nanr)r#rNr]r$r(r(r)test_zero_stat_length_validsz)TestStatistic.test_zero_stat_length_validrrcCsd}tjt|dtjddgd|ddWdn1swYtjt|dtjddgd|ddWdn1sAwYtjt|dtjddgd|ddWdn1scwYtjt|dtjddgd|ddWddS1swYdS) Nz,stat_length of 0 yields no value for paddingr@rrrsrro)r=rr=)rCrDrErr[r#rNrAr(r(r)test_zero_stat_length_invalids"z+TestStatistic.test_zero_stat_length_invalidN)rJrKrLrr3r6r9r<r>r?rCrKrMrOrSrTrCrerfrWr^rcfilterwarningsrfrhr(r(r(r)ris<   ric@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS) TestConstantcC8td}tj|dddd}tgd}t||dS)Nrjrlr)rrnr )rrrrrrrrrrrrrrrrrrrrrrrrrrr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnrnr2rr(r(r)test_check_constant z TestConstant.test_check_constantcCr)Nrjrlrr;r2rr(r(r)test_check_constant_zeros r4z&TestConstant.test_check_constant_zerosc Csltddd}tj|dddd}tgdgd gd gd gd gd gdgdg}t||dS)NrcrPr5rdr皙?rNr ) r=r=r=r=r=r=r=r=r=) r=rr=r-rr+rPr=r=) r=r5rrr>rrr=r=) r=r4rrrrrr=r=) r=rrrnrrrr=r=) r=rrmrrrrr=r=rr6r7r[r rr#r]r]r$r(r(r)test_check_constant_float$s   z&TestConstant.test_check_constant_floatc Csxtddd}|tj}tj|dddd}tgdgd gd gd gd gd gdgdg}t||dS)NrcrPr5rdrdrrprq) rprprprprprprprprp) rprqrrrsrtrurvrprp) rprwrxryrzr{r|rprp) rpr}r~rrrrrprp) rprrrrrrrprp) rprrrrrrrprprr6r7rrVr[r r)r#r] arr_floatr]r$r(r(r)test_check_constant_float28s"   z'TestConstant.test_check_constant_float2cCs<tjdtd}tj|dddd}tgd}t||dS)Nrjr9rlr)皙333333rl)ryryryryryryryryryryryryryryryryryryryryryryryryryrr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrzrz)rr6rr[r rrr(r(r)test_check_constant_float3Mr:z'TestConstant.test_check_constant_float3c Csftddd}tj|dddd}tgdgd gd gd gd gd gdg}t||dS)NrcrPr5)r=rYrrrq) rrrrrrrrrr) rrrr=r-rr+rPrr) rrr5rrr>rrrr) rrr4rrrrrrr) rrrrrnrrrrr) rrrrmrrrrrrrrrsr(r(r)"test_check_constant_odd_pad_amountes  z/TestConstant.test_check_constant_odd_pad_amountcCs\tddd}tjj|dddd}tgdgdgd gd gd g}t||dS) Nr+r-)rd)r=rr)rdrr+rq)rr=r=r+r+r+)rrr=r+r+r+)rr-rr+r+r+)rr-r-r+r+r+)rr6r7libr[r rrsr(r(r)test_check_constant_pad_2dvs z'TestConstant.test_check_constant_pad_2dcCsd}tjd|tjd}tj|dd|d}tjd|tjd}t||d}tjd|tjd}tj|dd|d}tjd|tjd}t||dS) NlrPr9r=rrqrl)rfulluint64r[minrint64)r# uint64_maxr]r]r$ int64_maxr(r(r)test_check_large_integerss 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_aobj_bobj_cr$r(r(r)test_check_object_arrays z$TestConstant.test_check_object_arraycC0td}tj|gddd}|jdksJdS)Nrrr-rrYr|rrXrr+r+rzerosr[rZr#r]r&r(r(r)test_pad_empty_dimension z%TestConstant.test_pad_empty_dimensionN) rJrKrLrmrortrxr{r}rrrrr(r(r(r)rjs  rjc@sReZdZddZddZejjefdddZ dd Z ej d e d d Z d S)TestLinearRampcCsDtdd}tj|dddd}tgd}t||ddd dS) Nrjrkrlr)r+rP)r )rugQ@gq= ףp @g)\( @gzG @g @gRQ@g ףp= @g(\@g{Gz@g333333@gQ@gp= ף@gQ?g)\(?g?g ףp= ?g{Gz?gQ?gQ?g?g{Gz?gQ?g{Gz?g{Gz?rqrrrsrtrurvrwrxryrzr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrg33333W@gffffffV@g9U@g T@gR@g33333Q@gfffffP@g33333N@gYL@rgfffffG@gLE@g33333B@g@@g<@g7@g3@g,@gffffff#@rvgh㈵>)rtolatol)rr6rr[r rrr(r(r)test_check_simples z TestLinearRamp.test_check_simplec Csttdddtj}tj|dddd}tgdgd gd gd gd gd gdgdg}t||dS)Nrnr+rP)r-r-rrRrNr ) rqrqrqrqrqrqrqrqrq) rqrqrqrprrg?rsrrrq) rqrqrqrrrsrtrursrq) rqg@rvrwrxryrzg@rq) rqrvr{r|r}r~rrxrq) rq@rrrrr#@rq) rqg@rryg!@rzrg@rqrvrsr(r(r) test_check_2ds zTestLinearRamp.test_check_2d) exceptionsc Csddlm}t|dd|ddg}tj|dddd}t|dd |d d |d d |d d |d d |dd |dd g}t||dS)Nr)Fractionr=r-rUrGrrr4rr5r<r?) fractionsrrr r[r)r#rr]actualr$r(r(r)test_object_arrays  z TestLinearRamp.test_object_arraycCsztjtdddddd}t|dddfd t|ddd fd t|dddfd t|d ddfd dS) z!Ensure that end values are exact.rr-rP){rrXNrrqrU)rr[rHr7r)r#r,r(r(r)test_end_valuess zTestLinearRamp.test_end_valuesr:cCstjdg|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_differences z'TestLinearRamp.test_negative_differenceN)rJrKrLrrrCrexfailAssertionErrorrrrf_numeric_dtypesrr(r(r(r)rs  rc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS) TestReflectcCr)Nrjrlr)rmrrrrrnrrrrrrrr4rrr>rrr5rPr+rr-r=rr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rr1r0r/r.r-r,r+r*r)r(r'r&r%r$r#r"r!r rrr2rr(r(r)rr4zTestReflect.test_check_simplecCrk)Nrjrlroddr )irr<r;r?rUrr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrjr=fghijklmnopqrstuvwr2rr(r(r)test_check_odd_methodrnz!TestReflect.test_check_odd_methodcCsgdgdg}t|dd}tgdgdgdgdgdgdgdgdgdgdgdgdgdgdg}t||dS)NrPr5rrrQr)rr5rrrr5rrrr5rrrr5rrPr+rPr5rPr+rPr5rPr+rPr5rPr+rPrRrr(r(r)test_check_large_pad,s(z TestReflect.test_check_large_padcC~gdg}t|dd}tgdgdgdgdgdgdgdgdgdgdgdgdgdg }t||dS)NrPrQrrrRrr(r(r)test_check_shapeCs& zTestReflect.test_check_shapecC.tgddd}tgd}t||dS)Nr=r-rr-r)rr-r=r-rr-r=rRrr(r(r) test_check_01YzTestReflect.test_check_01cCr)Nrrr) r-rr-r=r-rr-r=r-rRrr(r(r) test_check_02^rzTestReflect.test_check_02cCr)Nrr+r) r=r-rr-r=r-rr-r=r-rrRrr(r(r) test_check_03crzTestReflect.test_check_03N) rJrKrLrrrrrrrr(r(r(r)rs rc@sPeZdZdZejdee ddhddZ ejde ddZ d S) TestEmptyArrayzwYtjt|dtjtdd|dWddS1sawYdS)NzFcan't extend empty axis 0 using modes other than 'constant' or 'empty'r@r+rXr)rr)r|r)rCrDrErr[ndarrayrrgr(r(r)rls"z'TestEmptyArray.test_pad_empty_dimensioncCs(tjtdd|d}|jdksJdS)N)r-rr-)rarr|rX)rrr+)rr[rHrZ)r#rNr&r(r(r)test_pad_non_empty_dimension{sz+TestEmptyArray.test_pad_non_empty_dimensionN) rJrKrL__doc__rCrerfsortedrgrhrrr(r(r(r)ris  rc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS) TestSymmetriccCr)Nrjrlr)rrrrrnrrrrrrrr4rrr>rrr5rPr+rr-r=rrr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrr1r0r/r.r-r,r+r*r)r(r'r&r%r$r#r"r!r rr2rr(r(r)rr4zTestSymmetric.test_check_simplecCrk)Nrjrlrrr)rrrrrrrrrrrrrrrrrrrrr<r;r?rUrrr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrrjr=rrrrrrrrrrrrrrrrrr2rr(r(r)rrnz#TestSymmetric.test_check_odd_methodcCsgdgdg}t|dd}tgdgdgdgdgdgdgdgdgdgdgdgdgdgdg}t||dS)NrPrrQrrPr5r5rPr+r+rPr5r5rPr+r+rPr5r5)rrrrr5r5rrrrr5r5rrrrRrr(r(r)rs(z"TestSymmetric.test_check_large_padcCsgdgdg}tj|dddd}tgdgdgdgdgd gd gd gd gd gd gd gd gd gd g}t||dS)NrPrrQrrr)r;r?r?rUrrr=r-r-rr+r+rPr5r5)rUrrr=r-r-rr+r+rPr5r5rrr)r=r-r-rr+r+rPr5r5rrrr>rr)rr+r+rPr5r5rrrr>rrrr4r4)rPr5r5rrrr>rrrr4r4rrr)rrrr>rrrr4r4rrrrrr)r>rrrr4r4rrrrrrrrrrRrr(r(r)test_check_large_pad_odds(z&TestSymmetric.test_check_large_pad_oddcCr)NrPrQrrrRrr(r(r)rs& zTestSymmetric.test_check_shapecCr)Nrr-r)r-r=r=r-rrr-rRrr(r(r)rrzTestSymmetric.test_check_01cCr)Nrrr) rr-r=r=r-rrr-r=rRrr(r(r)rrzTestSymmetric.test_check_02cCr)Nrr5r)r=r-rrr-r=r=r-rrr-r=r=r-rrRrr(r(r)rrzTestSymmetric.test_check_03N) rJrKrLrrrrrrrrr(r(r(r)rs rc@r)TestWrapcCr)Nrjrlr)rrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrr=r-rr+rPr5rrr>rrr4rrrrrrrrnrrrrrmrrrrrcrrrrrrrrrrrrrrrrrrrrrrrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1rrr=r-rr+rPr5rrr>rrr4rrrrrrrr2rr(r(r)rr4zTestWrap.test_check_simplecCstd}t|d}t|dd}tgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdgdg}t||dS)Nr4r~)rr4r)rrrr>rrrr>rrrr>rrrr>rrrr>rrrr>rr)r-rrr=r-rrr=r-rrr=r-rrr=r-rrr=r-rrr=r-r)r5rr+rPr5rr+rPr5rr+rPr5rr+rPr5rr+rPr5rr+rPr5rrbrr(r(r)r s@  6zTestWrap.test_check_large_padcCr)Nrrr) r=r-rr=r-rr=r-rrRrr(r(r)r\rzTestWrap.test_check_01cCr)Nrr+r) rr=r-rr=r-rr=r-rr=rRrr(r(r)rarzTestWrap.test_check_02cCs8td}tj|ddd}t||ddddfdS)NrN)rrPrrXr)rrHr[rrr(r(r)test_pad_with_zerofs zTestWrap.test_pad_with_zerocCsxtd}tj|ddd}ttj||||fdd|td}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[rr_rr(r(r)test_repeated_wrappingks   $zTestWrap.test_repeated_wrappingN) rJrKrLrrrrrrr(r(r(r)rs< rc@eZdZddZddZdS)TestEdgec Csrtd}t|d}t|dd}tgdgdgdgdgdgdgdgdgdg }t||dS Nr4r+rr_r)rrrrr=r-r-r-)rrrrr+rPrPrP)r5r5r5r5rrrr)r>r>r>r>rrrrrbrr(r(r)rzs   zTestEdge.test_check_simplecCstgd}t|dd}tgd}t||tgdgdg}t|dd}t|dd}t||tddd d }t|dd}t|d d}t||dS) Nr)rdr)r=r=r-rrrrPrurr-rr+)rdrdrd)rr r[rr6r7)r#r,paddedr$r(r(r)test_check_width_shape_1_2s  z#TestEdge.test_check_width_shape_1_2N)rJrKrLrrr(r(r(r)rys rc@r) TestEmptycCsRtddd}tj|ddgdd}|jdksJt||d d d d fdS) Nrr+r5rG)rr=rrX)r>rr-r;rrUrr6r7r[rZrrr(r(r) test_simpleszTestEmpty.test_simplecCr)NrrrrXrrrr(r(r)rrz"TestEmpty.test_pad_empty_dimensionN)rJrKrLrrr(r(r(r)rs rc Csddd}tddd}t|d|}tgdgdgdgdgdgdg}t||dS) NcSs&d|d|d<d||d d<dS)Nrrr=r()vectorriaxiskwargsr(r(r) _padwithtenssz6test_legacy_vector_functionality.._padwithtensr5r-r)rrrrrrr)rrrr=r-rr)rrrr+rPrrrb)rr,rr(r(r) test_legacy_vector_functionalitys rcCs.tjdgddd}tgd}t||dS)Nr=r-rrX)rrr=rrrR)r,rr(r(r)test_unicode_moderrrN)rrrrcCs:tjddd}d}tjddd}ttj|||d|dS)Nr) fill_valuer_)r>rrX)rrrr[)rNr,r^rr(r(r)test_object_inputsrc @seZdZejdgdejdeddZejdeddZ ejdgdejded d Z ejd d d de dfdde fe dddfdgejdeddZ ddZejdgdejdeddZdS) TestPadWidthr))r+rPr5r)r|rYra)rdr~)rPr5))rr+rP)rr=r-rNcCVtdd}d}tjt|dt|||WddS1s$wYdS)NrcrZz(operands could not be broadcast togetherr@r\r#rrNr]rAr(r(r)test_misshaped_pad_widths "z%TestPadWidth.test_misshaped_pad_widthcCsVtdd}d}tjt|dt|d|WddS1s$wYdS)NrcrZzDinput operand has more dimensions than allowed by the axis remappingr@))ra)r+)rP)rr|rYr\)r#rNr]rAr(r(r)test_misshaped_pad_width_2s "z'TestPadWidth.test_misshaped_pad_width_2rXcCr)NrcrZr[r@r\rr(r(r)test_negative_pad_widths "z$TestPadWidth.test_negative_pad_widthzpad_width, dtype)3N)wordNr/N)g333333 @N))r-rr+r`r=rU)))grr`NcCstdd}d}|dur4tjt|dt|tj||d|WddS1s-wYdStjt|dt|||Wdn1sMwYtjt|dt|t||WddS1sowYdS)NrcrZz%`pad_width` must be of integral type.r@r9)rr6r7rCrD TypeErrorr[r )r#rr:rNr]rAr(r(r) test_bad_types ""zTestPadWidth.test_bad_typec Csxtd}t|d}t|tdd}tgdgdgdgdgdgdgdgdgdg }t||dSrrbrr(r(r)test_pad_width_as_ndarrays   z&TestPadWidth.test_pad_width_as_ndarray)rrR)rRrRcCs,tddd}t|tj|||ddS)Nrcr5rPrX)rr6r7rr[)r#rrNr]r(r(r)test_zero_pad_widthsz TestPadWidth.test_zero_pad_width)rJrKrLrCrerfrgrhrrrr!r rrrr(r(r(r)rs6      rc Cst|}i}tD] }||kr||q tjgdd|fi||D]/\}}d|}tjt |dtjgdd|fi||iWdn1sQwYq'dS)z1Test behavior of pad's kwargs for the given mode.rr=z+unsupported keyword arguments for mode '{}'r@N) rgvaluesupdaterr[itemsformatrCrDrE)rNallowed not_allowedrkeyvaluerAr(r(r) test_kwargs!s    rcCs(tddg}tt|dgddS)Nr=r-)rrr=r=rr)rr rr[)r]r(r(r)test_constant_zero_default2srr=constTFcCsRd|}tjt|dtjgdd|dWddS1s"wYdS)Nzmode '{}' is not supportedr@rr+rX)r rCrDrErr[)rNrAr(r(r)test_unsupported_mode7s "rcCs`tdddddddddf}t|d|}|jdks!Jt|ddddf|dS)Nrr+r5r-rG)rrr;r)rNr]r&r(r(r)test_non_contiguous_array>s&rcCsPtjddd}t|d|jdsJtjddd}t|d|jds&JdS) z5Test if C and F order is preserved for all pad modes.)rPrC)orderrP C_CONTIGUOUSF F_CONTIGUOUSN)rrHr[flags)rNr%r(r(r)test_memory_layout_persistenceFsrr:cCs0tjd|d}tj|d|d}|j|ksJdS)N)rr-r=r9r=rX)rrr[r:)r:rNr]r&r(r(r)test_dtype_persistenceOsr)&rrCnumpyr numpy.testingrrrnumpy.lib.arraypadrsctypesrrgrrMrirjrrrrrrrrrrerfrrrhrrr!rrrrr(r(r(r)sr Sl4Unr'  Q