U C^I @sdZddlmZmZmZddgZddlZddlmZddl m Z dd l m Z dd l m Zdd l mZmZdd lmZmZdd l mZddZddZGdddeZejejejejejejiZdZej e!ej"de#ddeje!ej$de#ddej%e!ej&de#ddej'e!ej(de#ddiZ)iZ*ddZ+iZ,d d!Z-d"d#Z.d$d%Z/e d&Gd'ddeZ0e d&Gd(ddeZ1dS))zJMachine limits for Float32 and Float64 and (long double) if available... )divisionabsolute_importprint_functionfinfoiinfoN)MachAr) set_module)numeric) numerictypes)arrayinf)log10exp2)umathcCs|jdkr|}d|_|S)zfix rank-0 --> rank-1r)r)ndimcopyshapear7/tmp/pip-install-6_kvzl1k/numpy/numpy/core/getlimits.py_fr0s rcCs|jdkr|}d|_|S)zfix rank > 0 --> rank-0rr)sizerrrrrr_fr1s rc@seZdZdZddZdS) MachArLikez$ Object to simulate MachAr instance c stfddfdd}fdd}d|_||d|_|_||d|_||d|_|_||d |_|_ d |d |_ |j |t t|j |_|d |j |_||j|_||j|_||j|_||j|_||j|_dS) Ncs t|gSNr vftyperr)z%MachArLike.__init__..cs t|Sr)rr) float_convrrr"*r#csdtt|dSNfmtrr rrr!paramsrrr"+r#titleepsepsneghugetinyitypeibeta )_MACHAR_PARAMSr*popepsilonr+r,Zxmaxr-Zxminr.r0__dict__updateintr precision resolution_str_eps _str_epsneg _str_xmin _str_xmax_str_resolution)selfr!kwargsZfloat_to_floatZ float_to_strr)r$r!r)r__init__%s$        zMachArLike.__init__N)__name__ __module__ __qualname____doc__rArrrrr"srz(numpy {} precision floating point numberz%24.16edouble)r/r&r*z%15.7esinglez%sz long doublez%12.5ehalfcCs |t|<dSr) _KNOWN_TYPES)macharZbytepatrrr_register_type\srKcCstj}t|dddddddddt|dt|d|d |d d }t|d |td<tj}t|d ddddddddt|d t|d|dddt|dd }t|d|td<tj}d}d}t|dddddddddd|d|||d |d }t|d!|td"<tj}t|d#} t|d$} t j d%d&|d'| | |d } W5QRXt|d(d#d$d)d*d+dddt|d(| | | d } t| d,t| d,| td<t|d-} t|d$}t j d%d&|d'| ||d }W5QRXt|d.d-d$d)d/d+dddt|d.| ||d }t|d0|td1<t t d2rDt |t|dn|j}t|d3d4ddd5ddddt|d3t|d4|t|dd }t|d6t|d7|td8<dS)9Niiir1rig?) machepnegepminexpmaxexpitiexpr0ZirndZngrdr+r,r-r.sfiiig?s̽ gttfddfddfddfdddS)zB Create MachAr instance with found information on float types cs t|gSrrrr rrr"r#z$_discovered_machar..cst|ddS)Nr/r)rZastyper)r)rrr"r#cstt|dS)Nrr'rr rrr" r#csdtt|dSr%r'rr(rrr"!r#r*)r2rr rr(rrus    ruZnumpyc@s4eZdZdZiZddZddZddZdd Zd S) ran finfo(dtype) Machine limits for floating point types. Attributes ---------- bits : int The number of bits occupied by the type. eps : float The smallest representable positive number such that ``1.0 + eps != 1.0``. Type of `eps` is an appropriate floating point type. epsneg : floating point number of the appropriate type The smallest representable positive number such that ``1.0 - epsneg != 1.0``. iexp : int The number of bits in the exponent portion of the floating point representation. machar : MachAr The object which calculated these parameters and holds more detailed information. machep : int The exponent that yields `eps`. max : floating point number of the appropriate type The largest representable number. maxexp : int The smallest positive power of the base (2) that causes overflow. min : floating point number of the appropriate type The smallest representable number, typically ``-max``. minexp : int The most negative power of the base (2) consistent with there being no leading 0's in the mantissa. negep : int The exponent that yields `epsneg`. nexp : int The number of bits in the exponent including its sign and bias. nmant : int The number of bits in the mantissa. precision : int The approximate number of decimal digits to which this kind of float is precise. resolution : floating point number of the appropriate type The approximate decimal resolution of this type, i.e., ``10**-precision``. tiny : float The smallest positive usable number. Type of `tiny` is an appropriate floating point type. Parameters ---------- dtype : float, dtype, or instance Kind of floating point data-type about which to get information. See Also -------- MachAr : The implementation of the tests that produce this information. iinfo : The equivalent for integer data types. Notes ----- For developers of NumPy: do not instantiate this at the module level. The initial calculation of these parameters is expensive and negatively impacts import times. These objects are cached, so calling ``finfo()`` repeatedly inside your functions is not a problem. cCszt|}Wn"tk r0tt|}YnX|j|d}|dk rL|S|g}t|}||k rr|||}t|tj st d||j|d}|dk r|St|tj st |}||k r|||}|j|d}|dk r|St ||}|D]}||j|<q|S)Nzdata type %r not inexact)r dtype TypeErrortype _finfo_cachermZ obj2sctypeappend issubclassZinexactrnZfloating_convert_to_floatobject__new___init)clsrxobjZdtypesZnewdtypedtrrrrms:       z finfo.__new__cCst||_t|}dD]}t||t||qdD]}t||t||jdq4|jjd|_|jjd|_ |j |_ |j jd|_ |j |_ |j|_||_|j|_|j|_|j|_|j|_|j|_|S)N)r8rTrRrQrPrO)r.r9r,rrW)r rxrwsetattrgetattrZflatitemsizebitsr-maxminr+rTZnexprSZnmantrJr<stripZ _str_tinyr=Z_str_maxr;r:r>)r?rxrJwordrrrrs&       z finfo._initcCsd}||jS)NaMachine parameters for %(dtype)s --------------------------------------------------------------- precision = %(precision)3s resolution = %(_str_resolution)s machep = %(machep)6s eps = %(_str_eps)s negep = %(negep)6s epsneg = %(_str_epsneg)s minexp = %(minexp)6s tiny = %(_str_tiny)s maxexp = %(maxexp)6s max = %(_str_max)s nexp = %(nexp)6s min = -max --------------------------------------------------------------- )r5r?r&rrr__str__s z finfo.__str__cCs"|jj}|j}||d<d|S)NklasszZ%(klass)s(resolution=%(resolution)s, min=-%(_str_max)s, max=%(_str_max)s, dtype=%(dtype)s)) __class__rBr5r)r?cdrrr__repr__s  zfinfo.__repr__N) rBrCrDrEr{rrrrrrrrr%s D!c@sHeZdZdZiZiZddZeddZeddZ dd Z d d Z d S) ral iinfo(type) Machine limits for integer types. Attributes ---------- bits : int The number of bits occupied by the type. min : int The smallest integer expressible by the type. max : int The largest integer expressible by the type. Parameters ---------- int_type : integer type, dtype, or instance The kind of integer data type to get information about. See Also -------- finfo : The equivalent for floating point data types. Examples -------- With types: >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max 2147483647 With instances: >>> ii32 = np.iinfo(np.int32(10)) >>> ii32.min -2147483648 >>> ii32.max 2147483647 cCs~zt||_Wn$tk r4tt||_YnX|jj|_|jjd|_d|j|jf|_|jdkrztd|jfdS)NrWz%s%diuzInvalid integer data type %r.) r rxryrzkindrrrvrn)r?Zint_typerrrrAs  ziinfo.__init__cCs\|jdkrdSztj|j}Wn4tk rRtd|jd> }|tj|j<YnX|SdS)zMinimum value of given dtype.urrN)rr _min_valsrvKeyErrorr7rr?valrrrrs z iinfo.mincCsjztj|j}WnTtk rd|jdkr>td|j>d}ntd|jd>d}|tj|j<YnX|S)zMaximum value of given dtype.rr)r _max_valsrvrrr7rrrrrr s z iinfo.maxcCsd}||j|j|jdS)zString representation.zMachine parameters for %(dtype)s --------------------------------------------------------------- min = %(min)s max = %(max)s --------------------------------------------------------------- rxrrrrrrrrsz iinfo.__str__cCsd|jj|j|j|jfS)Nz%s(min=%s, max=%s, dtype=%s))rrBrrrx)r?rrrr!s ziinfo.__repr__N) rBrCrDrErrrApropertyrrrrrrrrrs0    )2rE __future__rrr__all__rqrJrZ overridesr r r rfr r rrrrrrrZcsinglerGZcomplex_Zfloat_Z clongfloatZ longfloatr~Z _title_fmtrFdictZint64rsZint32rhZlonglongrHZint16r2rIrKrgrjrwrurrrrrrst     +