o
    tBh<^                     @   sj  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d Zdd ZG dd dZe
je
je
je
je
je
jiZdZe
jee
j de!dde
jee
j"de!dde
j#ee
j$de!dde
j%ee
j&de!ddiZ'i Z(dd Z)i Z*dd Z+d d! Z,d"d# Z-ed$G d%d dZ.ed$G d&d dZ/dS )'zJMachine limits for Float32 and Float64 and (long double) if available...

finfoiinfo    N   )MachAr)
set_module)numeric)numerictypes)arrayinfNaN)log10exp2	nextafterisnanc                 C      | j dkr|  } d| _| S )zfix rank-0 --> rank-1r   )r   )ndimcopyshapea r   k/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/numpy/core/getlimits.py_fr0      
r   c                 C   r   )zfix rank > 0 --> rank-0r   r   )sizer   r   r   r   r   r   _fr1   r   r   c                   @   sN   e Zd ZdZddddZedd Zedd	 Zd
d Zdd Z	dd Z
dS )
MachArLikez$ Object to simulate MachAr instance N)smallest_subnormalc          	      K   s4  t | | _|| _| jd | _|s t| d| d| jd| _n|| _| | | _| _| || _	| | | _
| _| || _| | | _| _| jd || _| j| tt| j | _| | d| j  | _| | j| _| | j	| _| | j| _| | j
| _| | j| _| | j| _d S )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*   r,   r/   r0   r   kwargsr   r   r   __init__"   s2   

zMachArLike.__init__c                 C   s6   | j }| d|krtjd| jtd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.
        r   z8The value of the smallest subnormal for {} type is zero.   
stacklevel)r&   r%   warningswarnformatUserWarningr'   r>   valuer   r   r   r   >   s   
zMachArLike.smallest_subnormalc                 C   s   |  | jS )z;Return the string representation of the smallest subnormal.)r7   r   r>   r   r   r   _str_smallest_subnormalV   s   z"MachArLike._str_smallest_subnormalc                 C   s   t | |S )zConverts float to float.

        Parameters
        ----------
        value : float
            value to be converted.
        )r   r5   rH   r   r   r   r'   [      zMachArLike._float_to_floatc                 C   s   t |g| jS )zConverts float to conv.

        Parameters
        ----------
        value : float
            value to be converted.
        )r	   r%   rH   r   r   r   r5   e   rL   zMachArLike._float_convc                 C   s   | j d tt|d | j S )zConverts float to str.

        Parameters
        ----------
        value : float
            value to be converted.
        fmtr   )r$   r	   r   r%   rH   r   r   r   r7   o   s   zMachArLike._float_to_str)__name__
__module____qualname____doc__r@   propertyr   rK   r'   r5   r7   r   r   r   r   r       s    



r   z(numpy {} precision floating point numberz%24.16edouble)r!   rM   r   z%15.7esinglez%szlong doublez%12.5ehalfc                 C   s   | t |< d S N)_KNOWN_TYPES)macharbytepatr   r   r   _register_type   s   rZ   c                  C   s  t j} t| dddddddddt| dt| d| 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  t|dd}t|d |td< t j}d}d}t|dddddddddd|d| | |d  |d}t|d! |td"< t j}t|d#}	t|d$}
t	j
d%d& |d'|	 |
 |d  }W d    n1 sw   Y  t|d(d#d$d)d*d+dddt|d(|	||
d}t|d, t|d, |td< t|d-}t|d$}t	j
d%d& |d'| | |d  }W d    n	1 sw   Y  t|d.d-d$d)d/d+dddt|d.|||d}t|d0 |td1< t|t|d|d2}t}|td3d}t|d4d5ddd6ddddt|d4t|d5|||d7}t|d8 t|d9 |td:< d S );Niii   r"      rA   r   i  g      ?)machepnegepminexpmaxexpitiexpr0   irndngrdr)   r*   r,   r/   s   fiii         g   ?s   ̽    g      <g       iiii   4      g      <g      ?   s   @   iiignore)allr   ii @  p      s   ii?   s
   P   r   g        iii   )r]   r^   r_   r`   ra   rb   r0   rc   rd   r)   r*   r,   r/   r   s   Y<s   Y<dd)ntypesfloat16r   r   rZ   	_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_mar   r   r   _register_known_types   s  












r   c                 C   s   t | }|du rtt| | dd }d}| tjkr(t|dd }|du r1t|}|dur7|S t	j
d| d|  dtdd	 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.
    Nz-0.1<r"   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!rA   rB   )r#   get
ValueErrorreprnewbyteordertobytesru   rz   rW   rD   rE   rG   _discovered_machar)r%   r$   keyma_liker   r   r   _get_machar1  s    


r   c                    s>   t   t fddfdd fdd fddd S )zB Create MachAr instance with found information on float types
    c                    s   t | g S rV   )r	   vr%   r   r   <lambda>e  s    z$_discovered_machar.<locals>.<lambda>c                    s   t |  d d S )Nr!   r   )r   astyper   )r$   r   r   r   f  s    c                    s   t t| d  S )Nr   r	   r   r   r   r   r   r   g  s    c                    s   d t t| d   S )NrM   r   r   r   r%   r$   r   r   r   h  s    r   )r#   r   r   r   r   r   r   a  s   

r   numpyc                   @   sX   e Zd ZdZi Zdd Zdd Zdd Zdd	 Ze	d
d Z
e	dd Ze	dd ZdS )r   a7  
    finfo(dtype)

    Machine limits for floating point types.

    Attributes
    ----------
    bits : int
        The number of bits occupied by the type.
    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.
    machar : MachAr
        The object which calculated these parameters and holds more
        detailed information.

        .. deprecated:: 1.22
    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 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.
    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]_.

    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
    c                 C   s  zt |}W n ty   t t|}Y nw | j|d }|d ur%|S |g}t |}||ur8|| |}t|t j	sDt
d| | j|d }|d urQ|S t|t jsft| }||urf|| |}| j|d }|d urs|S t| |}|D ]}|| j|< q}|S )Nzdata type %r not inexact)r   r    	TypeErrortype_finfo_cacher   
obj2sctypeappend
issubclassinexactr   floating_convert_to_floatobject__new___init)clsr    objdtypesnewdtypedtr   r   r   r     s<   


zfinfo.__new__c                 C   s   t || _t|}dD ]}t| |t|| qdD ]}t| |t||jd  q| jjd | _|jjd | _	| j	 | _
|jjd | _|j| _|j| _|| _|j | _|j | _|j | _|j | _|j | _|j | _|j | _| S )N)r4   rb   r`   r_   r^   r]   )r6   r*   r   r   rg   )r   r    r   setattrgetattrflatitemsizebitsr,   maxminr)   rb   nexpra   nmant_macharr:   strip	_str_tinyr;   _str_maxr9   r8   r<   r=   rK   )r>   r    rX   wordr   r   r   r     s*   
zfinfo._initc                 C   s   d}|| j  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
---------------------------------------------------------------
)r1   r>   rM   r   r   r   __str__  s   
zfinfo.__str__c                 C   s"   | j j}| j }||d< d| S )NklasszZ%(klass)s(resolution=%(resolution)s, min=-%(_str_max)s, max=%(_str_max)s, dtype=%(dtype)s))	__class__rN   r1   r   )r>   cdr   r   r   __repr__  s   
zfinfo.__repr__c                 C   s0   t | jjjd rtjdtd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 doublerA   rB   )r   r   r.   r   rD   rE   rG   rJ   r   r   r   r.     s   zfinfo.smallest_normalc                 C   s   | 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.
        )r.   rJ   r   r   r   r/   3  s   z
finfo.tinyc                 C   s   t jdtdd | jS )zThe object which calculated these parameters and holds more
        detailed information.

        .. deprecated:: 1.22
        z)`finfo.machar` is deprecated (NumPy 1.22)rA   rB   )rD   rE   DeprecationWarningr   rJ   r   r   r   rX   D  s
   zfinfo.macharN)rN   rO   rP   rQ   r   r   r   r   r   rR   r.   r/   rX   r   r   r   r   r   l  s    Z!

c                   @   sH   e Zd ZdZi Zi Zdd Zedd Zedd Z	dd	 Z
d
d ZdS )r   al  
    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

    c                 C   s|   zt || _W n ty   t t|| _Y nw | jj| _| jjd | _d| j| jf | _| jdvr<td| jf d S )Nrg   z%s%diuzInvalid integer data type %r.)	r   r    r   r   kindr   r   r   r   )r>   int_typer   r   r   r@     s   

ziinfo.__init__c                 C   sV   | j dkrdS z	tj| j }W |S  ty*   td| jd >  }|tj| j< Y |S w )zMinimum value of given dtype.ur   r   )r   r   	_min_valsr   KeyErrorr3   r   r>   valr   r   r   r     s   
z	iinfo.minc                 C   sh   z	t j| j }W |S  ty3   | jdkrtd| j> d }ntd| jd > d }|t j| j< Y |S w )zMaximum value of given dtype.r   r   )r   	_max_valsr   r   r   r3   r   r   r   r   r   r     s   
z	iinfo.maxc                 C   s   d}|| j | j| jd S )zString representation.zMachine parameters for %(dtype)s
---------------------------------------------------------------
min = %(min)s
max = %(max)s
---------------------------------------------------------------
r    r   r   r   r   r   r   r   r     s   ziinfo.__str__c                 C   s   d| j j| j| j| jf S )Nz%s(min=%s, max=%s, dtype=%s))r   rN   r   r   r    rJ   r   r   r   r     s   ziinfo.__repr__N)rN   rO   rP   rQ   r   r   r@   rR   r   r   r   r   r   r   r   r   r   S  s    0

)0rQ   __all__rD   r   r   	overridesr    r   r   ru   r	   r
   r   umathr   r   r   r   r   r   r   csinglerT   complex_float_
clongfloat	longfloatr   
_title_fmtrS   dictint64rF   int32rz   longlongrU   int16r#   rW   rZ   rw   r   r   r   r   r   r   r   r   r   <module>   sd    [ 0 g