B ٬?g:M gS㥛?gz):?g h"?g?gc@steZdZejejgZejejgZ ddZ ddZ ddZ ddZ d d Zd d Zd dZddZddZddZdS)TestNanFunctions_MinMaxcCs.t}x |jD]}||t|tqWdS)N)_ndatcopynanfuncsr)selfndatfrT/opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/tests/test_nanfunctions.py test_mutation+s z%TestNanFunctions_MinMax.test_mutationcCsdtd}xTt|j|jD]B\}}x8dD]0}|||dd}|||dd}t|j|jkq(WqWdS)N)NrT)axiskeepdims)npeyeziprstdfuncsrndim)rmatnfrfrtgtresrrr test_keepdims2s   z%TestNanFunctions_MinMax.test_keepdimscCsbtd}xRt|j|jD]@\}}td}||dd}||d|d}t||t||qWdS)Nrr)r)rout)rrrrrzerosr )rr!r"r#resoutr$r%rrrtest_out:s    z TestNanFunctions_MinMax.test_outcCsd}xt|j|jD]|\}}xr|D]j}tjd|d}||ddjj}||ddjj}t||k||ddjj}||ddjj}t||kq"WqWdS)NefdgFDGr)dtyper)r)rrrrrr,typer)rcodesr"r#cr!r$r%rrrtest_dtype_from_inputCs  z-TestNanFunctions_MinMax.test_dtype_from_inputcsHxBt|j|jD]0\}fddtD}|tdd}t||qWdS)Ncsg|] }|qSrr).0d)r#rr Rsz>TestNanFunctions_MinMax.test_result_values..r)r)rrr_rdatrr )rr"r$r%r)r#rtest_result_valuesPs z*TestNanFunctions_MinMax.test_result_valuesc Csttjgddd}x|jD]}xndD]f}tjddP}tdtt |||d tt |dkd tt |d j tWdQRXq,WtjddJ}tdtt |tjtt |dkd tt |d j tWdQRXq"WdS) N r)NrrT)recordalways)rrzno warning raisedr)rarraynanreshaperwarningscatch_warnings simplefilterrisnanalllen issubclasscategoryRuntimeWarning)rr!rrwrrr test_allnansVs   " z$TestNanFunctions_MinMax.test_allnanscCsntjt}|j}xRtjgD]F}||dd}|tdd}t||t|j|tt | q WdS)Nr)r) rZmaZ fix_invalidrZ_maskrnanminrrZisinfany)rr!Zmskrr%r$rrr test_maskedfs      z#TestNanFunctions_MinMax.test_maskedcCs$x|jD]}t|ddkqWdS)Ng)rr)rrrrr test_scalarps z#TestNanFunctions_MinMax.test_scalarc Csttd}xx|jD]n}||dd}tt|tjt|jdk||dd}tt|tjt|jdk||}tt|qWtj|d<xd|jD]X}t j ddR}t d ||dd}tt|tjtt t | tt|dkWdQRXt j dd}t d ||dd}tt|tjtt |d ont |d  ont |d  tt|dkd tt|djtWdQRXt j ddD}t d ||}tt|t|tjktt|dkWdQRXqWdS)Nrr)r)rrr)rrT)r7r8)rr)rr)rzno warning raised)rmatrixrrr isinstanceshapeisscalarr:r<r=r>rHr?rArBrCrD)rr!rr%rErrr test_matricests@        $ z%TestNanFunctions_MinMax.test_matricesc Cstjddgtjdgtjtjggtd}tt|dttj|ddddgtjddV}td tt tj|d dddtjgt t |d kd t t |dj tWdQRXdS) Ng?g@g@)r,r)rT)r7r8rzno warning raised)rr9r:objectrrGr<r=r>listrrArBrCrD)rZarrrErrrtest_object_arrays&  z)TestNanFunctions_MinMax.test_object_arrayN)__name__ __module__ __qualname__rrGnanmaxrminmaxrrr&r*r0r5rFrIrJrPrSrrrrr&s     'rc@sHeZdZejejgZddZddZddZ ddZ d d Z d d Z d S)TestNanFunctions_ArgminArgmaxcCs.t}x |jD]}||t|tqWdS)N)rrrr)rrrrrrrs z+TestNanFunctions_ArgminArgmax.test_mutationc Csxt|jtjtjgD]\}}x|tD]t}td}|td||}||}t t | t ||| t t ||d| WdQRXq$WqWdS)Nzinvalid value encountered in) rrrZgreaterZlessrr filterrDrr?rHZequal)rrZfcmprowsupZindvalrrrr5s  z0TestNanFunctions_ArgminArgmax.test_result_valuescCsZttjgddd}x:|jD]0}xdD]}tt|||dq,Wtt|tjq"WdS)Nr6r)Nrr)r)rr9r:r;rr ValueError)rr!rrrrrrFs   z*TestNanFunctions_ArgminArgmax.test_allnanscCsftd}xV|jD]L}xdD]}tt|||dqWx(dD] }|||d}t|tdq:WqWdS)N)rr)rN)r)rr)rr(rr r_r)rr!rrr%rrr test_emptys     z(TestNanFunctions_ArgminArgmax.test_emptycCs$x|jD]}t|ddkqWdS)Ng)rr)rrrrrrJs z)TestNanFunctions_ArgminArgmax.test_scalarcCsttd}xx|jD]n}||dd}tt|tjt|jdk||dd}tt|tjt|jdk||}tt|qWdS)Nrr)r)rrr)rr)rrLrrrrMrNrO)rr!rr%rrrrPs   z+TestNanFunctions_ArgminArgmax.test_matricesN) rTrUrVr nanargmin nanargmaxrrr5rFr`rJrPrrrrrZs   rZc@seZdZejejejejejej ej ej fZ e dddddgZddZdd Zd d Zd d ZddZddZddZddZddZddZddZddZdS)TestNanFunctions_IntTypes']W.ccs"x|jD]}|j|VqWdS)N) int_typesr!astype)rr,rrrinteger_arrayss z(TestNanFunctions_IntTypes.integer_arrayscCs2t|j}x |D]}tt||qWdS)N)rrXr!rkrrG)rr$r!rrr test_nanmins z%TestNanFunctions_IntTypes.test_nanmincCs2t|j}x |D]}tt||qWdS)N)rrYr!rkrrW)rr$r!rrr test_nanmaxs z%TestNanFunctions_IntTypes.test_nanmaxcCs2t|j}x |D]}tt||qWdS)N)rZargminr!rkrra)rr$r!rrrtest_nanargmins z(TestNanFunctions_IntTypes.test_nanargmincCs2t|j}x |D]}tt||qWdS)N)rZargmaxr!rkrrb)rr$r!rrrtest_nanargmaxs z(TestNanFunctions_IntTypes.test_nanargmaxcCs2t|j}x |D]}tt||qWdS)N)rsumr!rkrnansum)rr$r!rrr test_nansums z%TestNanFunctions_IntTypes.test_nansumcCs2t|j}x |D]}tt||qWdS)N)rprodr!rkrnanprod)rr$r!rrr test_nanprods z&TestNanFunctions_IntTypes.test_nanprodcCs2t|j}x |D]}tt||qWdS)N)rcumsumr!rkr nancumsum)rr$r!rrrtest_nancumsum s z(TestNanFunctions_IntTypes.test_nancumsumcCs2t|j}x |D]}tt||qWdS)N)rcumprodr!rkr nancumprod)rr$r!rrrtest_nancumprods z)TestNanFunctions_IntTypes.test_nancumprodcCs2t|j}x |D]}tt||qWdS)N)rmeanr!rkrnanmean)rr$r!rrr test_nanmeans z&TestNanFunctions_IntTypes.test_nanmeancCsft|j}x |D]}tt||qWtj|dd}x$|D]}ttj|dd|qFWdS)Nr)ddof)rvarr!rkrnanvar)rr$r!rrr test_nanvars  z%TestNanFunctions_IntTypes.test_nanvarcCsht|j}x |D]}tt||qWtj|jdd}x$|D]}ttj|dd|qHWdS)Nr)r)rstdr!rkrnanstd)rr$r!rrr test_nanstd$s  z%TestNanFunctions_IntTypes.test_nanstdN)rTrUrVrZint8Zint16Zint32Zint64Zuint8Zuint16Zuint32Zuint64rir9r!rkrlrmrnrorrrurxr{r~rrrrrrrcs rcc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)SharedNanFunctionsTestsMixincCs.t}x |jD]}||t|tqWdS)N)rrrr)rrrrrrr/s z*SharedNanFunctionsTestsMixin.test_mutationcCsdtd}xTt|j|jD]B\}}x8dD]0}|||dd}|||dd}t|j|jkq(WqWdS)Nr)NrrT)rr)rrrrrrr )rr!r"r#rr$r%rrrr&6s   z*SharedNanFunctionsTestsMixin.test_keepdimscCsbtd}xRt|j|jD]@\}}td}||dd}||d|d}t||t||qWdS)Nrr)r)rr')rrrrrr(r )rr!r"r#r)r$r%rrrr*>s    z%SharedNanFunctionsTestsMixin.test_outc Cstd}d}xt|j|jD]\}}x|D]}t}|tjtjhkr\|dkr\|tj ||t |ddj j }||t |ddj j }t ||k||t |ddj j }||t |ddj j }t ||kWdQRXq,WqWdS)Nrr+FDGr)r,r) rrrrrr rrr[ComplexWarningr,r-r) rr!r.r"r#r/r]r$r%rrrtest_dtype_from_dtypeGs    z2SharedNanFunctionsTestsMixin.test_dtype_from_dtypec Cstd}d}xt|j|jD]\}}x|D]}t}|tjtjhkr\|dkr\|tj |||ddj j }|||ddj j }t ||k|||ddj j }|||ddj j }t ||kWdQRXq,WqWdS)Nrr+rr)r,r) rrrrrr rrr[rr,r-r) rr!r.r"r#r/r]r$r%rrrtest_dtype_from_charXs    z1SharedNanFunctionsTestsMixin.test_dtype_from_charcCsd}xt|j|jD]\}}x||D]t}tjd|d}||ddjj}||ddjj}t||kd||f||ddjj}||ddjj}t||kq"WqWdS)Nr+r)r,r)rzres %s, tgt %s)rrrrrr,r-r)rr.r"r#r/r!r$r%rrrr0is z2SharedNanFunctionsTestsMixin.test_dtype_from_inputcsHxBt|j|jD]0\}fddtD}|tdd}t||qWdS)Ncsg|] }|qSrr)r1r2)r#rrr3xszCSharedNanFunctionsTestsMixin.test_result_values..r)r)rrrr4rr )rr"r$r%r)r#rr5vs z/SharedNanFunctionsTestsMixin.test_result_valuescCs$x|jD]}t|ddkqWdS)Ng)rr)rrrrrrJ|s z(SharedNanFunctionsTestsMixin.test_scalarcCsttd}xx|jD]n}||dd}tt|tjt|jdk||dd}tt|tjt|jdk||}tt|qWdS)Nrr)r)rrr)rr)rrLrrrrMrNrO)rr!rr%rrrrPs   z*SharedNanFunctionsTestsMixin.test_matricesN) rTrUrVrr&r*rrr0r5rJrPrrrrr.s  rc@s4eZdZejejgZejejgZ ddZ ddZ dS)TestNanFunctions_SumProdc Cstjdd}tdtjtjgddd}t|dkdtt|dkdttj}t|dkdtt|dkdtjdgdddtt|dkd WdQRXdS) NT)r7r8r)rrzresult is not 0zwarning raisedzunwanted warning raised)r<r=r>rrqr:rrA)rrEr%rrrrFs  z%TestNanFunctions_SumProd.test_allnanscCsxttjtjgddgD]f\}}td}|gd}||dd}t||g}||dd}t|||}||dd}t||qWdS)Nrr)rrr)r)rrrqrtr(r)rr tgt_valuer!r$r%rrrr`s        z#TestNanFunctions_SumProd.test_emptyN) rTrUrVrrqrtrrprsrrFr`rrrrrs  rc@sTeZdZejejgZejejgZ ddZ ddZ ddZ ddZ d d Zd d Zd S)TestNanFunctions_CumSumProdc Csxt|jddgD]\}}t~|tjgddd}|td}tt||d||tj}|td}tt||d||dgdddWdQRXqWdS)Nrrr)rzresult is not %s * np.ones((3))zresult is not %s * np.ones((1)))rrr rr:onesrZ array_equal)rrrr%r$rrrrFs z(TestNanFunctions_CumSumProd.test_allnanscCsxt|jddgD]p\}}td}|td}||dd}t|||}||dd}t||td}||dd}t||qWdS)Nrr)rr)r)rrrr(rr)rrrr!r$r%rrrr`s       z&TestNanFunctions_CumSumProd.test_emptyc Csx^t|j|jD]L\}}td}x8dD]0}|||dd}|||dd}t|j|jkq(WqWx~|jD]t}td}tj d}tj ||j |j dk<||dd}t |j dx*td D]}|||d}t |j dqWqhWdS) Nr)Nrr)rr')r rg?)r)i)rrrrrrr rrandomZ RandomStater:randrNrarange) rrgr!rr$r%r2Zrsrrrr&s        z)TestNanFunctions_CumSumProd.test_keepdimscCsxttd}xb|jD]X}xtjtjtjgD]*}tjtjd|d}tt |td|dqWqWdS)Nr)r,r)rr') rrrrremptyrrNr r)rrr,r'rrrtest_out_dtype_errors z0TestNanFunctions_MeanVarStd.test_out_dtype_errorcsntjtjg}tjtjg}xPt||D]B\}x8dD]0fddtD}|tdd}t||q2Wq$WdS)N)rrcsg|]}|dqS))rr)r1r2)rr#rrr3sz9TestNanFunctions_MeanVarStd.test_ddof..r)rr) rrrrrrr4rr )rrrr"r$r%r)rr#r test_ddofs   z%TestNanFunctions_MeanVarStd.test_ddofc stjtjg}tjtjg}ddtD}xt||D]\}}xtdD]tz}| t | tj fdd|D}|t dd}tt||t|rtt|jdkntt|jdkWdQRXqDWq2WdS)NcSsg|] }t|qSr)rA)r1r2rrrr3 szATestNanFunctions_MeanVarStd.test_ddof_too_big..rcsg|] }|kqSrr)r1r2)rrrr3&sr)rrr)rrrrrr4rranger r7rDr[rrrr?rHrrAlog) rrrZdsizer"r#r]r$r%r)rrtest_ddof_too_bigs    z-TestNanFunctions_MeanVarStd.test_ddof_too_bigc Csttjgddd}x|jD]}xdD]}tjdd}tdtt |||d tt |dktt |d j ttt |tjtt |d ktt |d j tWdQRXq,Wq"WdS) Nr6r)NrrT)r7r8)rrrrK)rr9r:r;rr<r=r>rr?r@rArBrCrD)rr!rrrErrrrF.s   z(TestNanFunctions_MeanVarStd.test_allnansc Cstd}x|jD]}xldD]d}tjddN}tdtt|||dtt |dktt |dj t WdQRXqWxVd D]N}tjdd8}tdt |||dtgtt |dkWdQRXqWqWdS) N)rr)rNT)r7r8)rrr)r)rr(rr<r=r>rr?r@rArBrCrDr)rr!rrrErrrr`<s    "  z&TestNanFunctions_MeanVarStd.test_emptyN)rTrUrVrr}rrrr|rrrrrrrrFr`rrrrrs rc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)TestNanFunctions_MediancCs t}t|t|tdS)N)rrr nanmedianr)rrrrrrNs z%TestNanFunctions_Median.test_mutationc Cs\td}x@dD]8}tj||ddd}tj||ddd}t|j|jkqWtd}tjdt|j dddf}| tj }tj |t |<t}|ttj|ddd}t|j d tj|d dd}t|j d tj|d dd}t|j d tj|ddd}t|j dtj|ddd}t|j d tj|ddd}t|j dWdQRXdS)Nr)NrrF)rr'overwrite_input)rrrr)rT)rr)rrrr)rr)rrrr)rr)rrrr)r)rrrr)rrrKr)rrr)rrrr)rrmedianrrr rrr9rNrjintpr:tupler r[rDr)rr!rr$r%r2rEr]rrrr&Ts.   $       z%TestNanFunctions_Median.test_keepdimscCstjdd}tj|ddgtjdd}td}tj|dd}tj|d|d}t||t||td}tj|dd}tj|d|d}t||t||tj|d|d}t||t||dS) NrrrKr)r)rr'r)rr) rrrinsertr:r(rrr )rr!nan_matr)r$r%rrrr*os       z TestNanFunctions_Median.test_outcCsxdD]}tjd|}tjjd|j|jdd}tj||<d|dddf<g}x4|D],}tt||}| tj |ddqZWt tj |d d |qWdS) N)r3rirrr)sizeg?T)rr)r) rrZrandnZrandintrr:Zravelcompressr?appendrr r)rsr2rEr$xZnonanrrrtest_small_larges  z(TestNanFunctions_Median.test_small_largecCs*ddtD}tjtdd}t||dS)NcSsg|]}t|qSr)rr)r1r2rrrr3sz>TestNanFunctions_Median.test_result_values..r)r)r4rrrr )rr$r%rrrr5sz*TestNanFunctions_Median.test_result_valuesc Csttjgddd}xdD]}t}|ttttj ||d |dkrntt |j dkntt |j dkttt tj|dkrtt |j dkntt |j dkWdQRXq WdS)Nr6r)Nrr)rrrKr) rr9r:r;r r7rDrr?rr@rAr)rr!rr]rrrrFs  z$TestNanFunctions_Median.test_allnansc Cstd}xndD]f}tjddP}tdtttj||dtt |dktt |dj t WdQRXqWxXd D]P}tjdd:}tdt tj||dtgtt |dkWdQRXqWdS) N)rr)rNT)r7r8)rrr)r)rr(r<r=r>rr?rr@rArBrCrDr)rr!rrErrrr`s   "  z"TestNanFunctions_Median.test_emptycCsttddkdS)Ng)rrr)rrrrrJsz#TestNanFunctions_Median.test_scalarcCsptd}ttjtj|ddttjtj|ddttjtj|ddttjtj|ddtttj|dddS)N)rrrr)r)rrr)rr)rr)rrr AxisErrorrr_)rr2rrrtest_extended_axis_invalids  z2TestNanFunctions_Median.test_extended_axis_invalidc Cst}|txtjtj gD]}t|tjgtjtjgg}ttj|dd|tjgttj|dd|tjgtt||ttjtj|gtjtj|gg}tt||ttj|ddtjtj|gttj|dd|t||g||gg}ttj|dd|tj|d| dgdtjtjdgdtjtj|ggtj d }|dkrttj|ddd d | d gtt|d n.ttj|dddd | dgtt|dttj|dddd|gx t ddD]}xt ddD]}ttjg||g|gd}tt||ttj|dd|ttj|ddtjg||g|ttjg|| g|gd}tt|| ttj|dd| ttj|ddtjg|| g|qWqWq&WWdQRXdS)Nr)rrriirr)r,g@g@g@g@g$g"grg rK) r r[rDrinfr9r:rrZfloat32r)rr]raijrrrtest_float_specialsH    "$z*TestNanFunctions_Median.test_float_specialN) rTrUrVrr&r*rr5rFr`rJrrrrrrrLsrc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)TestNanFunctions_PercentilecCs"t}t|dt|tdS)N)rrr nanpercentiler)rrrrrrs z)TestNanFunctions_Percentile.test_mutationc Csltd}xDdD]<}tj|d|ddd}tj|d|ddd}t|j|jkqWtd}tjdt|j dddf}| tj }tj |t |<t}|ttj|ddd d }t|j d tj|dd d d }t|j d tj|ddd d }t|j dtj|ddd d }t|j dtj|ddd d }t|j d tj|ddd d }t|j dWdQRXdS)Nr)NrrFF)rr'r)rrrr)rrZT)rr)rrrr)rr)rrrr)rr)rrrr)r)rrrr)rrrKr)rrr)rrrr)rr percentilerrr rrr9rNrjrr:rr r[rDr)rr!rr$r%r2rEr]rrrr&s2     $       z)TestNanFunctions_Percentile.test_keepdimscCstjdd}tj|ddgtjdd}td}tj|ddd}tj|dd|d}t||t||td}tj|ddd}tj|dd|d}t||t||tj|dd |d}t||t||dS) NrrrKr)r*)rr'r)rr) rrrrr:r(rrr )rr!rr)r$r%rrrr*s       z$TestNanFunctions_Percentile.test_outcCsZddtD}tjtddd}t||tddtD}tjtddd}t||dS)NcSsg|]}t|dqS))rr)r1r2rrrr3(szBTestNanFunctions_Percentile.test_result_values..rr)rcSsg|]}t|dqS))rb)rr)r1r2rrrr3,s)rr)r4rrrr Z transpose)rr$r%rrrr5's  z.TestNanFunctions_Percentile.test_result_valuesc Csttjgddd}xdD]}tjdd}tdtttj |d|d |dkrttt |d kntt |dktt |d j tttt tjd|dkrtt |d kntt |d ktt |d j tWdQRXq WdS) Nr6r)NrrT)r7r8<)rrrrKr)rr9r:r;r<r=r>rr?rr@rArBrCrD)rr!rrErrrrF0s  z(TestNanFunctions_Percentile.test_allnansc Cstd}xpdD]h}tjddR}tdtttj|d|dtt |dktt |d j t WdQRXqWxZd D]R}tjdd<}tdt tj|d|dtgtt |d kWdQRXqWdS) N)rr)rNT)r7r8()rrr)r)rr(r<r=r>rr?rr@rArBrCrDr)rr!rrErrrr`Cs   "  z&TestNanFunctions_Percentile.test_emptycCsHttdddtd}tj|ddd}t|dtt|dS)Ngd2r)rg@)rrrrrrO)rrrrrrrJQs   z'TestNanFunctions_Percentile.test_scalarcCsztd}ttjtj|dddttjtj|dddttjtj|dddttjtj|dddtttj|ddddS) N)rrrrrr)qr)rrr)rr)rr)rrr rrr_)rr2rrrrXs  z6TestNanFunctions_Percentile.test_extended_axis_invalidc Cs$ddg}td}tj|}td}d|dddddddf<|ddddddfd9<xd D]}xd D]}tr}|td tj||||d }tj||||d } t| j |j tj||||d }tj||||d } t| |WdQRXqtWqjWtd } ttj| |ddj ddS)Nrr)rr)rrrrrKrr)Nrr)FTzAll-NaN slice encountered)rr)rrrr)rrK)r)rKrr) rrr:r r[rDrrrrN) rZpercr!rZ large_matrZkeepdimr]r^Znan_valZmegamatrrrtest_multiple_percentiles`s*   "       z5TestNanFunctions_Percentile.test_multiple_percentilesN) rTrUrVrr&r*r5rFr`rJrrrrrrrs r__main__)"Z __future__rrrr<ZnumpyrZ numpy.testingrrrrr r r r r r9r:rr4rrrrZrcrQrrrrrrrTrrrrsB, ;Ka"SH%