o 6a@sdZddlZddlmZmZddlmZmZmZm Z ddl m Z m Z m Z ddlmZmZGdddZGd d d ZGd d d ZGd ddZGdddZGdddZGdddZGdddZddZddZddZddZdS)z$ Test functions for limits module. N)finfoiinfo)halfsingledouble longdouble) assert_equalassert_ assert_raises)_discovered_machar _float_mac@eZdZddZdS)TestPythonFloatcC&tt}tt}tt|t|dSN)rfloatridselfftypeftype2rA/usr/lib/python3/dist-packages/numpy/core/tests/test_getlimits.pytest_singleton zTestPythonFloat.test_singletonN__name__ __module__ __qualname__rrrrrr  rc@r )TestHalfcCrr)rrrrrrrrrrzTestHalf.test_singletonNrrrrrr rr c@r ) TestSinglecCrr)rrrrrrrrrrzTestSingle.test_singletonNrrrrrr!rr!c@r ) TestDoublecCrr)rrrrrrrrrrzTestDouble.test_singletonNrrrrrr"rr"c@r )TestLongdoublecCrr)rrrrrrrrr%rzTestLongdouble.test_singletonNrrrrrr#$rr#c@r ) TestFinfocCsnttgdtjtjtjtjtjg}|D]\}}dD]}tt t ||t t |||qqt t t ddS)N)f2f4f8c8c16)bitsepsepsnegiexpmacharmachepmaxmaxexpminminexpnegepnexpnmant precision resolutiontinyi4) listzipnpfloat16float32float64 complex64 complex128rgetattrrr ValueErrorrdtsdt1dt2attrrrr test_basic+s  zTestFinfo.test_basicN)rrrrJrrrrr$*rr$c@eZdZddZddZdS) TestIinfoc Cszttgdtjtjtjtjtjtjtj tj g}|D]\}}dD]}t t t ||t t |||q!qttt ddS)N)i1i2r:i8u1u2u4u8)r*r2r0r&)r;r<r=int8int16int32int64uint8uint16uint32uint64rrCrr rDrErrrrJ8s  zTestIinfo.test_basiccCs,tjd}|D] }tt|j|dqdS)Nuint)r=sctypesrrr0)rtypesTrrrtest_unsigned_maxCs zTestIinfo.test_unsigned_maxN)rrrrJrarrrrrL7s rLc@rK)TestReprcCd}ttttj|dS)Nz)iinfo(min=-32768, max=32767, dtype=int16))rreprr=rrUrexpectedrrrtest_iinfo_reprIszTestRepr.test_iinfo_reprcCrc)NzMfinfo(resolution=1e-06, min=-3.4028235e+38, max=3.4028235e+38, dtype=float32))rrdr=rr?rerrrtest_finfo_reprMszTestRepr.test_finfo_reprN)rrrrgrhrrrrrbHs rbcCstdtddS)N g@)rrrrrrtest_instancesSs rjcCsZ|jD]%\}}t|t||t|dr*t|jt||jt|jt||jqdS)Nshape)__dict__itemsrrChasattrrkdtype) discoveredma_likekeyvaluerrrassert_ma_equalXs rtcCstjtdftjtdftjtdffD] \}}tt||qtjdd ttj}Wdn1s6wYt tjj }|j |j fdkrW|dvrWt|tddS|j |j fd krl|dkrnt|td dSdSdS) N @ignore)all)?@) ruP)pr{) r=r>r r?r@rtr errstaterroitemsizeitr1)rrqld_mabytesrrrtest_known_typesas     rcCsRtjdtjdD]}t|}t|jdkt|jdkt|jdkq dS)Nrcomplexr])r=r^rr r6r3r1)rinforrrtest_plausible_finfoss  r)__doc__numpyr= numpy.corerrrrrr numpy.testingrr r numpy.core.getlimitsr r rr r!r"r#r$rLrbrjrtrrrrrrs$