bg edZddgZddlZddlmZddlmZdd lmZdd lm Z dd lm Z m Z m Z dd lmZmZmZmZd ZdZGddZe je je je je je jiZdZe jee j de!de jee j"de!de j#ee j$de!de j%ee j&de!diZ'iZ(dZ)iZ*dZ+dZ,dZ-edGd dZ.edGd!dZ/dS)"zJMachine limits for Float32 and Float64 and (long double) if available... finfoiinfoN) set_module)MachAr)numeric) numerictypes)arrayinfNaN)log10exp2 nextafterisnancR|jdkr|}d|_|S)zfix rank-0 --> rank-1r)r)ndimcopyshapeas K/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/core/getlimits.py_fr0rs&v{{ FFHH HcR|jdkr|}d|_|S)zfix rank > 0 --> rank-0r)sizerrrs r_fr1rs&v{{ FFHH Hrc\eZdZdZdddZedZedZdZdZ d Z dS) MachArLikez$ Object to simulate MachAr instance N)smallest_subnormalc t||_||_|jd|_|sCt |d|d|j|_n||_||x|_|_|||_ ||x|_ |_ |||_ ||x|_ |_|jd||_|j|t%t'|j |_||d|j z|_||j|_||j |_||j |_||j |_||j|_||j |_dS)Ntitlerrdtypeitype )_MACHAR_PARAMSparamsftyper#r_smallest_subnormal_float_to_floatepsilonepsepsnegxmaxhugexminsmallest_normaltinyibeta__dict__updateintr precision _float_conv resolution _float_to_str_str_eps _str_epsneg _str_xmin _str_xmax_str_resolution_str_smallest_normal) selfr*r.r/r1r4r5r!kwargss r__init__zMachArLike.__init__"s$U+  [) ! :'0 1 tzz!}}DJ(@(@(@D $ $(:D $"&"6"6s";";; tx**622 $ 4 4T : :: DI((.. +/+?+?+E+EEty)T[)%00  V$$$eDHoo-....   R dn_ 577**4844 --dk::++DI66++DI66#11$/BB$($6$6ty$A$A!!!rc|j}|d|kr4tjd|jt d||S)a Return the value for the smallest subnormal. Returns ------- smallest_subnormal : float value for the smallest subnormal. Warns ----- UserWarning If the calculated value for the smallest subnormal is zero. rz8The value of the smallest subnormal for {} type is zero.r stacklevel)r+r*warningswarnformat UserWarningr,rCvalues rr!zMachArLike.smallest_subnormal>sl ( ::a==E ! ! M!6$*--{q J J J J##E***rc6||jS)z;Return the string representation of the smallest subnormal.)r<r!rCs r_str_smallest_subnormalz"MachArLike._str_smallest_subnormalVs!!$"9:::rcFt||S)zConverts float to float. Parameters ---------- value : float value to be converted. )rr:rMs rr,zMachArLike._float_to_float[s D$$U++,,,rc.t|g|jS)zConverts float to conv. Parameters ---------- value : float value to be converted. )r r*rMs rr:zMachArLike._float_conveseWdj)))rcn|jdtt|d|jzS)zConverts float to str. Parameters ---------- value : float value to be converted. fmtr)r)r rr*rMs rr<zMachArLike._float_to_stros,{5!E$u++a.$*$E$EEEr) __name__ __module__ __qualname____doc__rEpropertyr!rQr,r:r<rrrr r s..+/BBBBB8++X+.;;X;---***FFFFFrr z(numpy {} precision floating point numberz%24.16edouble)r&rUr#z%15.7esinglez%sz long doublez%12.5ehalfc|t|<dSN) _KNOWN_TYPES)macharbytepats r_register_typercs"Lrctj}t|dddddddddt|dt|d|d |d  }t |d |t d<tj}t|d ddddddddt|d t|d|dddzzt|d }t |d|t d<tj}d}d}t|dddddddddd|d|z |z |d z| }t |d!|t d"<tj}t|d#} t|d$} tj d%&5|d'| z | z |d z} dddn #1swxYwYt|d(d#d$d)d*d+dddt|d(| | | } t | d,| t d<t|d-} t|d$}tj d%&5|d'| z |z |d z}dddn #1swxYwYt|d.d-d$d)d/d+dddt|d.| || }t |d0|t d1<t|t|d|2}t}|td3d}t|d4d5ddd6ddddt|d4t|d5|||7}t |d8t |d9|t d:<dS);Niiir'rrig?) machepnegepminexpmaxexpitiexpr5irndngrdr.r/r1r4sfiiig?s̽ g>!$U!$X 0 0 0J:x(((IbM .CC#&"%#'#&!!""#!"!" $SSXX#'C>>!$laf%Q!G!) + + +J:BCCCIbM  Brr$xx..KRRZZ  I  h ' ' '>>RUU[(I51= >>>>>>>>>>>>>>>R$(#'$*$) #"$#$"#"#!%bbhh$/"+"+ - - -K;KMMM IcNbbggJBBvJJH  h ' ' ';;BqEEJ&(2RRUU:;;;;;;;;;;;;;;;B#&"%#)#(!!#"#!"!" $RRWW #-!)!) + + +J:JKKKIbM 3Ab111GByR0011R$(#'$)$( #"$#$"#"#!%bbhh$(DNN")"40EGGGK ;EGGG;EGGG!IdOOOs$G**G.1G.J11J58J5ct|}|tt||d|dz d}d}|t jkr"t|dd}|t|}|St|dkr@dt D}||dd}||Stj d|d |d td t|S) a Get MachAr instance or MachAr-like instance Get parameters for floating point type, by first trying signatures of various known floating point types, then, if none match, attempting to identify parameters by analysis. Parameters ---------- ftype : class Numpy floating point type class (e.g. ``np.float64``) Returns ------- ma_like : instance of :class:`MachAr` or :class:`MachArLike` Object giving floating point parameters for `ftype`. Warns ----- UserWarning If the binary signature of the float type is not in the dictionary of known float types. Ngg$@z_get_machar.._s1JJJTQSVVr\\q"vq\\\rz Signature z for zz does not match any known type: falling back to type probe function. This warnings indicates broken support for the dtype!rrG)r(get ValueErrorrepr newbyteordertobytesrrr`ritemsrIrJrL_discovered_machar)r*r)keyma_like_kts r _get_macharr3s_.   & &F ~e%%% 5;;s # 1 1# 6 6 > > @ @CG !!! ""3ss8,,""3''3s88r>>KJ\%7%7%9%9JJJ''#crc(## M @S @ @u @ @ @  #### e $ $$rclttfdfdfdfddS)z Create MachAr instance with found information on float types TODO: MachAr should be retired completely ideally. We currently only ever use it system with broken longdouble (valgrind, WSL). c&t|gSr_)r rr*s rz$_discovered_machar..ssE1#u--rc`t|ddS)Nr&r)rastype)rr)s rrz$_discovered_machar..ts$4 9 9::1=rcJtt|dS)Nrr rrs rrz$_discovered_machar..us5aU33rc\dtt|dzS)NrUrr)rr*r)s rrz$_discovered_machar..vs$F5ME$q''!*e,D,DDrr#)r(r)r*r)s`@rrrls\ E "F ----====3333DDDDD/  # ##rnumpycZeZdZdZiZdZdZdZdZe dZ e dZ dS) ra finfo(dtype) Machine limits for floating point types. Attributes ---------- bits : int The number of bits occupied by the type. dtype : dtype Returns the dtype for which `finfo` returns information. For complex input, the returned dtype is the associated ``float*`` dtype for its real and complex components. eps : float The difference between 1.0 and the next smallest representable float larger than 1.0. For example, for 64-bit binary floats in the IEEE-754 standard, ``eps = 2**-52``, approximately 2.22e-16. epsneg : float The difference between 1.0 and the next smallest representable float less than 1.0. For example, for 64-bit binary floats in the IEEE-754 standard, ``epsneg = 2**-53``, approximately 1.11e-16. iexp : int The number of bits in the exponent portion of the floating point representation. 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 An alias for `smallest_normal`, kept for backwards compatibility. smallest_normal : float The smallest positive floating point number with 1 as leading bit in the mantissa following IEEE-754 (see Notes). smallest_subnormal : float The smallest positive floating point number with 0 as leading bit in the mantissa following IEEE-754. Parameters ---------- dtype : float, dtype, or instance Kind of floating point or complex floating point data-type about which to get information. See Also -------- iinfo : The equivalent for integer data types. spacing : The distance between a value and the nearest adjacent number nextafter : The next floating point value after x1 towards x2 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. Note that ``smallest_normal`` is not actually the smallest positive representable value in a NumPy floating point type. As in the IEEE-754 standard [1]_, NumPy floating point types make use of subnormal numbers to fill the gap between 0 and ``smallest_normal``. However, subnormal numbers may have significantly reduced precision [2]_. This function can also be used for complex data types as well. If used, the output will be the same as the corresponding real float type (e.g. numpy.finfo(numpy.csingle) is the same as numpy.finfo(numpy.single)). However, the output is true for the real and imaginary components. References ---------- .. [1] IEEE Standard for Floating-Point Arithmetic, IEEE Std 754-2008, pp.1-70, 2008, http://www.doi.org/10.1109/IEEESTD.2008.4610935 .. [2] Wikipedia, "Denormal Numbers", https://en.wikipedia.org/wiki/Denormal_number Examples -------- >>> np.finfo(np.float64).dtype dtype('float64') >>> np.finfo(np.complex64).dtype dtype('float32') c |j|}||Sn#t$rYnwxYw|tjdt d t j|}n1#t$r$t jt|}YnwxYw|j|}||S|g}t j |}||ur| ||}t|t j std|z|j|}||St|t jsVt|}||urE| ||}|j|d}||D] }||j|< |St ||}|D] }||j|< |S)Nzifinfo() dtype cannot be None. This behavior will raise an error in the future. (Deprecated in NumPy 1.25)rrGzdata type %r not inexact) _finfo_cacher TypeErrorrIrJDeprecationWarningr r%type obj2sctypeappend issubclassinexactrfloating_convert_to_floatobject__new___init)clsr%objdtypesnewdtypedts rrz finfo.__new__s- "&&u--C     D  = MK"      /M%((EE / / /M$u++..EEE /""5)) ?J%e,, 5 MM( # # #E%11 C75ABB B""5)) ?J%!122 (/Hu$$ h''' &**5$77?%33/2(,,JnnS!!''.. ' 'B#&C R  s! ..A%%+BBc |tj||_t|}dD]!}t||t ||"dD],}t||t ||jd-|jjdz|_|jjd|_ |j |_ |j jd|_ |j |_ |j|_||_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|S)N)r9rlrjrirhrg)r;r/r!rrq)r r%rsetattrgetattrflatitemsizebitsr1maxminr.rlnexprknmant_macharr?strip _str_tinyr@_str_maxr>r=rArBrQ)rCr%rawords rrz finfo._inits]5)) U## 7 7D D$ 5 5 6 6 6 6B ? ?D D$ 5 5 :1 = > > > >J'!+ ;#A&H9:?1%K Y  )//11(..00 !-3355--// %5;;==$*$?$E$E$G$G!'-'E'K'K'M'M$ rcd}||jzS)Na+Machine 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 smallest_normal = %(_str_smallest_normal)s smallest_subnormal = %(_str_smallest_subnormal)s --------------------------------------------------------------- )r6rCrUs r__str__z finfo.__str__6s P T]""rc`|jj}|j}||d<d|zS)NklasszZ%(klass)s(resolution=%(resolution)s, min=-%(_str_max)s, max=%(_str_max)s, dtype=%(dtype)s)) __class__rVr6r)rCcds r__repr__zfinfo.__repr__Fs: N # M   ' 7:;< =rct|jjjdrt jdt d|jjjdS)a7Return the value for the smallest normal. Returns ------- smallest_normal : float Value for the smallest normal. Warns ----- UserWarning If the calculated value for the smallest normal is requested for double-double. rz;The value of smallest normal is undefined for double doublerrG)rrr3rrIrJrLrPs rr3zfinfo.smallest_normalMsW" -215 6 6 + MM + + + +|+033rc|jS)aQReturn the value for tiny, alias of smallest_normal. Returns ------- tiny : float Value for the smallest normal, alias of smallest_normal. Warns ----- UserWarning If the calculated value for the smallest normal is requested for double-double. )r3rPs rr4z finfo.tinyds ##rN) rVrWrXrYrrrrrrZr3r4rrrrrzsddLL666p4### ===44X4,$$X$$$rcXeZdZdZiZiZdZedZedZ dZ dZ dS)ra iinfo(type) Machine limits for integer types. Attributes ---------- bits : int The number of bits occupied by the type. dtype : dtype Returns the dtype for which `iinfo` returns information. 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 c` tj||_n6#t$r)tjt||_YnwxYw|jj|_|jjdz|_d|j|jfz|_|jdvrtd|jddS)Nrqz%s%diuzInvalid integer data type .) r r%rrkindrrrr)rCint_types rrEziinfo.__init__s 7 x00DJJ 7 7 7 tH~~66DJJJ 7JO J'!+ TY 22 9D * KLL L ! s0AAc|jdkrdS tj|j}n?#t$r2t d|jdz z }|tj|j<YnwxYw|S)zMinimum value of given dtype.urr)rr _min_valsrKeyErrorr8rrCvals rrz iinfo.mins| 9  1 0odh/ 0 0 0A$)A+./00,/))) 0Js'9A#"A#c tj|j}ng#t$rZ|jdkrt d|jzdz }nt d|jdz zdz }|tj|j<YnwxYw|S)zMaximum value of given dtype.rr)r _max_valsrrrr8rrs rrz iinfo.maxs ,/$(+CC , , ,yC1 >Q.//11-233(+EODH % % %  ,  sA!A>=A>c6d}||j|j|jdzS)zString representation.zMachine parameters for %(dtype)s --------------------------------------------------------------- min = %(min)s max = %(max)s --------------------------------------------------------------- r%rrrrs rrz iinfo.__str__s* P tz$(48LLLLrcP|jjd|jd|jd|jdS)Nz(min=z, max=z, dtype=))rrVrrr%rPs rrziinfo.__repr__s5151H1H1H$(HHHdhhh D DrN) rVrWrXrYrrrErZrrrrrrrrrvs00dII M M M  X   X  M M MDDDDDr)0rY__all__rI_utilsrrrr r rr r r umathrrrrrrr csingler\complex_float_ clongfloat longfloatr _title_fmtr[dictint64rKint32rlonglongr]int16r(r`rcrrrrrrrrrrs G $$$$$$$$$$$$$$$$000000000000      WFWFWFWFWFWFWFWFv NFM OV] v'8  M44 !!(++--- M44 !!(++--- tt!!-00222 K !!&))+++,4 ###  N"N"N"b6%6%6%r # # # Gx$x$x$x$x$x$x$x$v GhDhDhDhDhDhDhDhDhDhDr