o 6aK8@sddlmZmZmZmZmZmZmZmZm Z m Z m Z m Z m Z ddlmZmZmZmZmZGdddeZGddde ZGdddZGd d d ZGd d d Zd S)) logspacelinspace geomspacedtypearraysctypesarangeisnanndarraysqrt nextafterstackerrstate)assert_ assert_equal assert_raisesassert_array_equalassert_allclosec@sLeZdZddZddZeZddZddZd d ZeZ d d Z d dZ dS)PhysicalQuantitycCs t||SN)float__new__)clsvaluerE/usr/lib/python3/dist-packages/numpy/core/tests/test_function_base.pyr s zPhysicalQuantity.__new__cCs"tt|ttt|t|Srr isinstancerrselfxrrr__add__zPhysicalQuantity.__add__cCs"tt|ttt|t|Srrrrrr__sub__r"zPhysicalQuantity.__sub__cCs"tt|ttt|t|Srrrrrr__rsub__r"zPhysicalQuantity.__rsub__cCstt|t|Srrrrrrr__mul__zPhysicalQuantity.__mul__cCstt|t|Srr%rrrr__div__r'zPhysicalQuantity.__div__cCstt|t|Srr%rrrr__rdiv__"r'zPhysicalQuantity.__rdiv__N) __name__ __module__ __qualname__rr!__radd__r#r$r&__rmul__r(r)rrrrr s rc@seZdZdZdS)PhysicalQuantity2 N)r*r+r,__array_priority__rrrrr/&sr/c@s4eZdZddZddZddZddZd d Zd S) TestLogspacecCsvtdd}tt|dktdddd}t|ddktdddd }t|ddktddd d}t|gd dS) Nr2dnum@BFendpointr0r5@@@gj@.A)rrlenrryrrr test_basic,s zTestLogspace.test_basiccstddg}tddgt|d}tddt|Ddd }t||t|d d}tfd d|Ddd }t||t|dd d }t||jdS) N?g@@r3cSg|] \}}t||dqS)r3r.0_start_stoprrr :z6TestLogspace.test_start_stop_array..r>axisrcg|] }t|ddqS)rr3rJrLrMstoprrrO>r8)rrr ziprTrstartt1t2t3t4t5rrUrtest_start_stop_array6s$      z"TestLogspace.test_start_stop_arraycC^tdddd}t|jtdtdddd}t|jtdtdddd}t|jtddSNrr3float32rfloat64int32)rrrrCrrr test_dtypeD zTestLogspace.test_dtypecC*td}td}tt||tdddSNrGg@)rrrrabrrrtest_physical_quantitiesLz%TestLogspace.test_physical_quantitiescCxtdt}tdt}t||}t|tusJt|tddt||d}t|tus1Jt|tddddSNr>r<rGrH)rviewr/rtyperrrmrnlsrrr test_subclassQ  zTestLogspace.test_subclassN)r*r+r,rErarhrorwrrrrr2*s   r2c@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS) TestGeomspacecCstdd}tt|dktdddd}t|ddktdddd }t|ddktddd d}t|gd td d dd}t|gdt|jdtdddd}t|gdt|jdtdddd}t|gdt|jddS)Nr>rAr4r5r6r8r9Fr:r<r=)rzr{r)r8r~)r~rr8)rrrBrrimagrCrrrrE^s"   zTestGeomspace.test_basiccCsd}d}t||dd}t|d|t||ddd}t|d|t||dd}t|d|t|d |t||ddd}t|d|dS) Ng333333?gL4@r>r6rFr7r;r|r8)rrrr[rVrDrrr,test_boundaries_match_start_and_stop_exactlytsz:TestGeomspace.test_boundaries_match_start_and_stop_exactlycCstddtdddd}Wdn1swYt|ddtt|d d t|dd tddtdddd d }Wdn1sNwYt|ddtt|d ddS)Nignore)invalidr|r}r6rgr>r8g@Fr)rrrrr allrCrrrtest_nan_interiors  zTestGeomspace.test_nan_interiorcCstdddd}t|gdt|jdtdddd}t|gd t|jdtd d d d}t|gd tddd d}t|gdtdddtd}t|gdtddd}t|ddtddtddgtddd}t|ddtddtddgtddd}t|ddtddtddgtddd}t|ddtddtddgtddd}t|gdtdd d}t|dd gtd dd}t|d dgdS)!N?0@r6)ry@y@y @rr@t)ry(yBy[r??@@@@r})ry$@$@yY@Y@r?@@@)ry$$@yYY@rr8r>r|r7r)r8rr>y@yrr{y@y@@r<)ry9ҿŒ~y{xC@V]yMuU@PrN y0@5Sy m^>@w@@r)rrrrealcomplexr rCrrr test_complexs4   $ $ $ $   zTestGeomspace.test_complexcCstdddd}t|jtdtdddd}t|jtdtdddd}t|jtdtddtd}t|jtdtddtd}t|jtddS) Nr>rArdrerfrgfloat_r)rrrrrrCrrrrhszTestGeomspace.test_dtypec Cstddgdd}tddgdd}tddgd d}t|d |d d }t|d |d d }t|d |d d }td dd }tddd }tddd } t||ddt||ddt|| dddS)Nxr5int8rer~uint16rr>r^@Y@^Y@r?g{Gz?)rtolgh㈵>)rrr rlim1lim2lim3r\r]r^r_r`t6rrrtest_start_stop_array_scalars   z*TestGeomspace.test_start_stop_array_scalarcstgd}tgdt|d}tddt|Ddd}t||t|dd}tfd d|Ddd}t||t|dd d}t||jdS) N)rGg@@rrrr8)r@@rry@@r>rcSrIrrrKrrrrOrPz7TestGeomspace.test_start_stop_array..r>rQrcrSrrrrTrUrrrOrWr8)rrr rXrrYrZrrUrras$      z#TestGeomspace.test_start_stop_arraycCrjrk)rrrrlrrrrorpz&TestGeomspace.test_physical_quantitiescCrqrr)rrsr/rrtr)rrmrngsrrrrwrxzTestGeomspace.test_subclasscCs.tttddtttddtttdddS)Nrr0)r ValueErrorrrrrr test_boundsszTestGeomspace.test_boundsN) r*r+r,rErrrrhrrarorwrrrrrry\s( ryc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdS) TestLinspacecCsltdd}tt|dktdddd}t|ddktdddd }t|ddktttdddddS) Nrr0r4r{r5r6r8Fr:)rrrBrrrCrrrrEs zTestLinspace.test_basiccCs6ttddd}t|dgk|tttdddddS)Nrr>rFg@r6)listrrr TypeErrorrCrrr test_corner szTestLinspace.test_cornercCsBtdddj}tdddj}tdddj}t||t||dS)Nrr>r{)rrr)rr\r]r^rrr test_types  zTestLinspace.test_typecCrbrc)rrrrCrrrrhrizTestLinspace.test_dtypec Cstddgdd}tddgdd}tddgd d}t|d |d d }t|d |d d }t|d |d d }td dd }tddd }tddd } t||t||t|| dS)Nrr5rrerr~rrrrr>rrrrrrr?)rrrrrrrrs     z)TestLinspace.test_start_stop_array_scalarcstddgdd}tddgddt|d}tdd t|Dd d }t||t|d d}tfd d |Dd d }t||t|ddd }t||jdS)Nrrrrer5r~rcSrIrrrKrrrrO1rPz6TestLinspace.test_start_stop_array..r>rQrcrSrrrTrUrrrO5rWr8)rrr rXrrYrZrrUrra-s$    z"TestLinspace.test_start_stop_arraycCsHtddd}tgd}tddd}tgd}t||t||dS)N?@@@r)ry?@y@@y@ @rrr0)ry@?y@?y@?y$@)rrr)rrr\rr]rrrr;s     zTestLinspace.test_complexcCrj)NrFrG)rrrrlrrrroCrpz%TestLinspace.test_physical_quantitiescCsxtdt}tdt}t||}t|tusJt|tddt||d}t|tus1Jt|tddddS)Nrr>rFrG)rrsr/rrtrrurrrrwHrxzTestLinspace.test_subclasscCsHGddd}|tddd}|tddd}tt||tdddS)Nc@s,eZdZdZddZeddZddZdS) z3TestLinspace.test_array_interface..Arrayisha A generic object that supports the __array_interface__ and hence can in principle be converted to a numeric scalar, but is not otherwise recognized as numeric, but also happens to support multiplication by floats. Data should be an object that implements the buffer interface, and contains at least 4 bytes. cSs ||_dSr_data)rdatarrr__init__bs z.Arrayish.__init__cSsdd|jddS)Nr.Arrayish.__array_interface__cSs|Srr)rotherrrrr&jsz;TestLinspace.test_array_interface..Arrayish.__mul__N)r*r+r,__doc__rpropertyrr&rrrrArrayishWs    rr>rrer)rrr)rronefiverrrtest_array_interfaceRsz!TestLinspace.test_array_interfacec CsBtdD]}t|d|dd}tttd|dd|dqdS)Nrrr>rr0F)r;r)rr ranyr)rftyperVrrrtest_denormal_numbersts z"TestLinspace.test_denormal_numberscCs8tdD]}ttd||dtdt|dtdqdS)Nrrr>re)rangerrintr)rjrrrtest_equivalent_to_arange{s z&TestLinspace.test_equivalent_to_arangec CsdD]f}dD]a}tdd||dd}t|trt|dksJ|dkr=|r(dd gndd g}t|d|t|d|dq|dkrS|sSt|ddgt|dd qt|ddgd|t|dsgJqqdS) N)rr>r{)FTrr>T)r;retstepr{rFrGg?)rrtuplerBrrr )rr7eptrD y0_expectrrr test_retsteps zTestLinspace.test_retstepcCs:tddd}tddd}t||d}t|tgddS)Nr>Orer{r|)rGg?r)rrrrrrr test_objects   zTestLinspace.test_objectcCs.tdddtd}tgdtd}t||dS)Nr8r|rzr)r8r8rrr>r>r{r|re)rrrr)rrDtrrrtest_round_negativesz TestLinspace.test_round_negativeN)r*r+r,rErrrhrrarrorwrrrrrrrrrrrs   " rN)numpyrrrrrrrr r r r r r numpy.testingrrrrrrrr/r2ryrrrrrs<2%