
    Ǆg,e                        d Z ddgZddlZddlmZ ddlmZ dd	lmZ dd
lm	Z
 ddlmZmZmZ ddlmZmZmZmZ d Zd Z G d d      Ze
j,                  e
j.                  e
j0                  e
j2                  e
j4                  e
j6                  iZdZe
j<                   ee
j@                  dejC                  d            e
j.                   ee
jD                  dejC                  d            e
j6                   ee
jF                  dejC                  d            e
jH                   ee
jJ                  dejC                  d            iZ&i Z'd Z(i Z)d Z*d Z+d Z, ed       G d  d             Z- ed       G d! d             Z.y)"zJMachine limits for Float32 and Float64 and (long double) if available...

finfoiinfo    N   )
set_module   )MachAr)numeric)numerictypes)arrayinfnan)log10exp2	nextafterisnanc                 R    | j                   dk(  r| j                         } d| _        | S )zfix rank-0 --> rank-1r   )r   )ndimcopyshapeas    ]/home/mcse/projects/flask_80/flask-venv/lib/python3.12/site-packages/numpy/_core/getlimits.py_fr0r      s$    vv{FFHH    c                 R    | j                   dk(  r| j                         } d| _        | S )zfix rank > 0 --> rank-0r    )sizer   r   r   s    r   _fr1r      s$    vv{FFHHr   c                   N    e Zd ZdZdddZed        Zed        Zd Zd Z	d	 Z
y)

MachArLikez$ Object to simulate MachAr instance N)smallest_subnormalc                ~   t         |   | _        || _        | j                  d   | _        |s<t	        | j                  d      | j                  d      | j                        | _        n|| _        | j                  |      x| _        | _        | j                  |      | _	        | j                  |      x| _
        | _        | j                  |      | _        | j                  |      x| _        | _         | j                  d   |      | _        | j                   j#                  |       t%        t'        | j                               | _        | j                  | j+                  d      | j(                   z        | _        | j/                  | j                        | _        | j/                  | j                        | _        | j/                  | j                        | _        | j/                  | j                        | _        | j/                  | j,                        | _        | j/                  | j                        | _        y )Ntitler   r   dtypeitype
   )_MACHAR_PARAMSparamsftyper#   r   _smallest_subnormal_float_to_floatepsilonepsepsnegxmaxhugexminsmallest_normaltinyibeta__dict__updateintr   	precision_float_conv
resolution_float_to_str_str_eps_str_epsneg	_str_xmin	_str_xmax_str_resolution_str_smallest_normal)	selfr*   r.   r/   r1   r4   r5   r!   kwargss	            r   __init__zMachArLike.__init__"   s   $U+
[[)
!'0

1tzz!}DJJ(@D$ (:D$"&"6"6s";;tx**62 $ 4 4T ::	DI((.	+/+?+?+EEty)T[[)%0
V$eDHHo-...R dnn_57**4884--dkk:++DII6++DII6#11$//B$($6$6tyy$A!r   c                     | j                   }| j                  d      |k(  r5t        j                  dj	                  | j                        t
        d       | j                  |      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.
        r   z8The value of the smallest subnormal for {} type is zero.r   
stacklevel)r+   r*   warningswarnformatUserWarningr,   rC   values     r   r!   zMachArLike.smallest_subnormal>   sV      ((::a=E!MM!6$**-{qJ ##E**r   c                 8    | j                  | j                        S )z;Return the string representation of the smallest subnormal.)r<   r!   rC   s    r   _str_smallest_subnormalz"MachArLike._str_smallest_subnormalV   s     !!$"9"9::r   c                 6    t        | j                  |            S )zConverts float to float.

        Parameters
        ----------
        value : float
            value to be converted.
        )r   r:   rM   s     r   r,   zMachArLike._float_to_float[   s     D$$U+,,r   c                 0    t        |g| j                        S )zConverts float to conv.

        Parameters
        ----------
        value : float
            value to be converted.
        )r   r*   rM   s     r   r:   zMachArLike._float_conve   s     eWdjj))r   c                 f    | j                   d   t        t        |      d   | j                        z  S )zConverts float to str.

        Parameters
        ----------
        value : float
            value to be converted.
        fmtr   )r)   r   r   r*   rM   s     r   r<   zMachArLike._float_to_stro   s+     {{5!E$u+a.$**$EEEr   )__name__
__module____qualname____doc__rE   propertyr!   rQ   r,   r:   r<   r   r   r   r    r        sF    .+/B8 + +. ; ;-*Fr   r    z(numpy {} precision floating point numberz%24.16edouble)r&   rU   r#   z%15.7esinglez%szlong doublez%12.5ehalfc                     | t         |<   y N)_KNOWN_TYPES)macharbytepats     r   _register_typerc      s    "Lr   c                  (   t         j                  } t        | dddddddddt         | d            t         | d             | d	       | d
            }t	        |d       |t
        d<   t         j                  }t        |dddddddddt         |d            t         |d             |dddz  z        t         |d                  }t	        |d       |t
        d<   t         j                  }d}d}t        |dddddddddd|d|z
  |z   |d       z  |      }t	        |d!       |t
        d"<   t         j                  }t         |d#            }	t         |d$            }
t        j                  d%&      5   |d'      |	z
  |
z   |d       z  }d d d        t        |d(d#d$d)d*d+dddt         |d(            |	|
      }t	        |d,       |t
        d<   t         |d-            }t         |d$            }t        j                  d%&      5   |d'      |z
  |z   |d       z  }d d d        t        |d.d-d$d)d/d+dddt         |d.            ||      }t	        |d0       |t
        d1<   t         |t               |d      |2      }t        } |t        d3d            }t        |d4d5ddd6ddddt         |d4            t         |d5            |||7      }t	        |d8       t	        |d9       |t
        d:<   y # 1 sw Y   lxY w# 1 sw Y   xY w);Niii   r'      r   r   i  g      ?)machepnegepminexpmaxexpitiexpr5   irndngrdr.   r/   r1   r4   s   fiii         g   ?s   ̽    g      <g       iiii   4      g      <g      ?   s   @   iiignore)allr   ii @  p      s   ii?   s
   P   r$   g        iii   )rg   rh   ri   rj   rk   rl   r5   rm   rn   r.   r/   r1   r4   r!   s   Y<s   Y<dd)ntypesfloat16r    r   rc   	_float_mafloat32float64
longdoubler	   errstater   r   r   )f16
float16_maf32
float32_maf64
epsneg_f64tiny_f64
float64_maldepsneg_f128	tiny_f128	huge_f128float128_ma
epsneg_f80tiny_f80huge_f80
float80_mahuge_ddsmallest_normal_ddsmallest_subnormal_ddfloat_dd_mas                        r   _register_known_typesr      sc    ..CC#&"%#&#%!!""#!"!" $SX#'C>!$U!$X0J :x(IbM ..CC#&"%#'#&!!""#!"!" $SX#'C>!$laf%<!=!%c$i2J :23IbM ..CJHC#&"%#(#'!!#"#!"!" ,#-"%
"2h!>Q!G!)+J :BCIbM 
		Br$x.KRZ I			h	' >U[(I51=	>R$(#'$*$) #"$#$"#"#!%bh$/"+"+-K ;KM IcN bgJBvJH			h	' ;qEJ&(2RU:;B#&"%#)#(!!#"#!"!" $RW#-!)!)+J :JKIbM 3Ab1G yR01R$(#'$)$( #"$#$"#"#!%bh$(DN")"40EGK  ;EG ;EG!IdOY> >2; ;s   9K;L;LLc                    t         j                  |       }|t        t        |              | d       | d      z  }|j	                  |j
                  j                  d            j                         }d}| t        j                  k(  rt        j                  |dd       }|t        j                  |      }|[t        |      dk(  rMt        j                         D ci c]  \  }}t        |      dk(  s|dd | }}}|j                  |dd       }||S t        j                  d| d|  d	t        d
       t!        |       S c c}}w )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.
    Ng      g      $@<r'   re   z
Signature z for zz does not match any known type: falling back to type probe function.
This warnings indicates broken support for the dtype!r   rG   )r(   get
ValueErrorreprviewr%   newbyteordertobytesr   r   r`   lenitemsrI   rJ   rL   _discovered_machar)r*   r)   keyma_likekv_kts          r   _get_macharr   5  sE   . &F~e%% ;s#C
((399))#.
/
7
7
9CG!!!
 ""3s8,""3'3s8r> &2%7%7%9JTQSVr\q"vqyJJ''#cr(#MM
SEug &@ 	@ 		#
 e$$ Ks    E7Ec                 V     t             t         fdfd fd fdd         S )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        | g      S r_   )r   r   r*   s    r   <lambda>z$_discovered_machar.<locals>.<lambda>v  s    E1#u- r   c                 D    t        | j                  d               d   S )Nr&   r   )r   astype)r   r)   s    r   r   z$_discovered_machar.<locals>.<lambda>w  s    D&/!:;A> r   c                 4    t        t        |       d         S )Nr   r   r   r   s    r   r   z$_discovered_machar.<locals>.<lambda>x  s    E$q'!*e4 r   c                 @    d   t        t        |       d         z  S )NrU   r   r   )r   r*   r)   s    r   r   z$_discovered_machar.<locals>.<lambda>y  s    F5ME$q'!*e,DD r   r#   )r(   r   )r*   r)   s   `@r   r   r   o  s/     E"F->4D/	# #r   numpyc                   L    e Zd ZdZi Zd Zd Zd Zd Ze	d        Z
e	d        Zy)	r   a  
    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, https://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                   j                  |      }||S 	 |t        j                  dt
        d       	 t        j                  |      }| j                   j                  |      }||S |g}t        j                  |      }||ur|j                  |       |}t        |t        j                        st        d|z        | j                   j                  |      }||S t        |t        j                        sVt         |   }||urI|j                  |       |}| j                   j                  |d       }||D ]  }|| j                   |<    |S t"        j%                  |       j'                  |      }|D ]  }|| j                   |<    |S # t        $ r Y w xY w# t        $ r" t        j                  t        |            }Y {w xY w)Nzifinfo() dtype cannot be None. This behavior will raise an error in the future. (Deprecated in NumPy 1.25)r   rG   zdata type %r not inexact)_finfo_cacher   	TypeErrorrI   rJ   DeprecationWarningr	   r%   typer   
obj2sctypeappend
issubclassinexactr   floating_convert_to_floatobject__new___init)clsr%   objdtypesnewdtypedts         r   r   zfinfo.__new__  s   	""&&u-C
 
 =MMK"		/MM%(E
 ""5)?J$$U+5 MM(#E%175ABB""5)?J%!1!12(/Hu$h' &&**5$7? % 3/2((,3JnnS!''. 	'B#&CR 	'
c  		  	/MM$u+.E	/s#   F F' 	F$#F$''GGc           	         t        j                  |      | _        t        |      }dD ]  }t        | |t	        ||              dD ]&  }t        | |t	        ||      j
                  d          ( | j                  j                  dz  | _        |j                  j
                  d   | _	        | j                   | _
        |j                  j
                  d   | _        |j                  | _        |j                  | _        || _        |j"                  j%                         | _        |j(                  j%                         | _        |j,                  j%                         | _        |j.                  j%                         | _        |j0                  j%                         | _        |j2                  j%                         | _        |j4                  j%                         | _        | S )N)r9   rl   rj   ri   rh   rg   )r;   r/   r!   r   rq   )r	   r%   r   setattrgetattrflatitemsizebitsr1   maxminr.   rl   nexprk   nmant_macharr?   strip	_str_tinyr@   _str_maxr>   r=   rA   rB   rQ   )rC   r%   ra   words       r   r   zfinfo._init  s}   ]]5)
U# 	7D D$ 56	7 C 	?DD$ 5 : :1 =>	?JJ''!+	;;##A&HH9::??1%KK	YY
))//1((..0!--335--/%55;;=$*$?$?$E$E$G!'-'E'E'K'K'M$r   c                 $    d}|| j                   z  S )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
---------------------------------------------------------------
)r6   rC   rU   s     r   __str__zfinfo.__str__9  s    
P 	 T]]""r   c                 v    | j                   j                  }| j                  j                         }||d<   d|z  S )NklasszZ%(klass)s(resolution=%(resolution)s, min=-%(_str_max)s, max=%(_str_max)s, dtype=%(dtype)s))	__class__rV   r6   r   )rC   cds      r   __repr__zfinfo.__repr__I  s>    NN##MM '
7:;< 	=r   c                     t        | j                  j                  j                  d         rt	        j
                  dt        d       | j                  j                  j                  d   S )a7  Return 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.
        r   z;The value of smallest normal is undefined for double doubler   rG   )r   r   r3   r   rI   rJ   rL   rP   s    r   r3   zfinfo.smallest_normalP  sR    " --22156MMM+ ||++0033r   c                     | j                   S )aQ  Return 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.
        )r3   rP   s    r   r4   z
finfo.tinyg  s     ###r   N)rV   rW   rX   rY   r   r   r   r   r   rZ   r3   r4   r   r   r   r   r   }  sM    dL L6p4# = 4 4, $ $r   c                   J    e Zd ZdZi Zi Zd Zed        Zed        Z	d Z
d Zy)r   a  
    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                    	 t        j                  |      | _        | j                  j                  | _        | j                  j
                  dz  | _        d| j                  | j                  fz  | _        | j                  dvrt        d| j                  d      y # t        $ r& t        j                  t        |            | _        Y w xY w)Nrq   z%s%diuzInvalid integer data type .)	r	   r%   r   r   kindr   r   r   r   )rC   int_types     r   rE   ziinfo.__init__  s    	7 x0DJ JJOO	JJ''!+	TYY		2299D 		KLL !  	7 tH~6DJ	7s   B ,CCc                     | j                   dk(  ry	 t        j                  | j                     }|S # t        $ r= t        d| j                  dz
  z         }|t        j                  | j                  <   Y |S w xY w)zMinimum value of given dtype.ur   r   )r   r   	_min_valsr   KeyErrorr8   r   rC   vals     r   r   z	iinfo.min  ss     990oodhh/ J  0A$))A+./0,/)J0s   1 AA76A7c                 .   	 t         j                  | j                     }|S # t        $ rj | j                  dk(  rt        d| j                  z  dz
        }nt        d| j                  dz
  z  dz
        }|t         j                  | j                  <   Y |S w xY w)zMaximum value of given dtype.r   r   )r   	_max_valsr   r   r   r8   r   r   s     r   r   z	iinfo.max  s    	,//$((+C 
  	,yyC1		>Q./11-23(+EOODHH%
	,s   ! A/BBc                 T    d}|| j                   | j                  | j                  dz  S )zString representation.zMachine parameters for %(dtype)s
---------------------------------------------------------------
min = %(min)s
max = %(max)s
---------------------------------------------------------------
r%   r   r   r   r   s     r   r   ziinfo.__str__  s-    P 	 tzz$((488LLLr   c                     | j                   j                  d| j                  d| j                  d| j                  dS )Nz(min=z, max=z, dtype=))r   rV   r   r   r%   rP   s    r   r   ziinfo.__repr__  s.    151H1H$(HHdhh

D 	Dr   N)rV   rW   rX   rY   r   r   rE   rZ   r   r   r   r   r   r   r   r   r   y  sN    0d II	M 
 
 
 
	MDr   )/rY   __all__rI   _utilsr   r   r    r	   r
   r   r   r   r   umathr   r   r   r   r   r   r    csingler\   
complex128r   clongdoubler   r   
_title_fmtr[   dictint64rK   int32longlongr]   int16r(   r`   rc   r   r   r   r   r   r   r   r   r   <module>r     s   G
     $ $ $ 0 0WF WFv NNFMM
v~~
))  8

MM4!!(+- MM4!!(+- t!!-02 KK!!&)+,4 # 	N"b7%t# Gx$ x$ x$v GhD hD hDr   