o
    U=ºiö`  ã                   @   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   N)ÚndimÚcopyÚshape©Úa© r   úZC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\numpy/core/getlimits.pyÚ_fr0   ó   
r   c                 C   r   )zfix rank > 0 --> rank-0r   r   N)Ú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ÚepsnegZxmaxÚhugeZ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-   r.   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.é   ©Ú
stacklevelN)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.N)r5   r   ©r<   r   r   r   Ú_str_smallest_subnormalV   s   z"MachArLike._str_smallest_subnormalc                 C   s   t |  |¡ƒS )z�Converts float to float.

        Parameters
        ----------
        value : float
            value to be converted.
        N)r   r3   rF   r   r   r   r'   [   ó   zMachArLike._float_to_floatc                 C   s   t |g| jƒS )z€Converts float to conv.

        Parameters
        ----------
        value : float
            value to be converted.
        N)r	   r%   rF   r   r   r   r3   e   rJ   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   N)r$   r	   r   r%   rF   r   r   r   r5   o   s   zMachArLike._float_to_str)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r>   Úpropertyr   rI   r'   r3   r5   r   r   r   r   r       s    ÿ



r   z(numpy {} precision floating point numberz%24.16eÚdouble)r!   rK   r   z%15.7eÚsinglez%szlong doublez%12.5eÚhalfc                 C   s   | t |< d S ©N)Ú_KNOWN_TYPES)ÚmacharZbytepatr   r   r   Ú_register_type™   s   rW   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 s°w   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 );Niöÿÿÿiõÿÿÿiòÿÿÿé   r"   é   r?   r   iàÿ  g      ?)ÚmachepÚnegepÚminexpÚmaxexpÚitÚiexpr.   ÚirndÚngrdr)   r*   r+   r-   s   f®iéÿÿÿièÿÿÿi‚ÿÿÿé€   é   é   g   àÿÿï?s   ÍÌÌ½é    g       <g       iÌÿÿÿiËÿÿÿiüÿÿi   é4   é   g      °<g      ð?é   s   š™™™™™¹¿é@   i�ÿÿÿiÀÿÿÚignore)Úallr   i�ÿÿÿi @  ép   é   s   š™™™™™™™™™™™™™û¿iÀÿÿÿiÁÿÿÿé?   s
   ÍÌÌÌÌÌÌÌû¿éP   r   g        i—ÿÿÿi–ÿÿÿéi   )rZ   r[   r\   r]   r^   r_   r.   r`   ra   r)   r*   r+   r-   r   s   š™™™™™Y<š™™™™™¹¿s   š™™™™™¹¿š™™™™™Y<Údd)ÚntypesZfloat16r   r   rW   Ú	_float_maZfloat32Zfloat64Ú
longdoubler   Zerrstater   r
   r   )Zf16Z
float16_maZf32Z
float32_maZf64Z
epsneg_f64Ztiny_f64Z
float64_maÚldZepsneg_f128Z	tiny_f128Z	huge_f128Zfloat128_maZ
epsneg_f80Ztiny_f80Zhuge_f80Z
float80_maZhuge_ddZsmallest_normal_ddZsmallest_subnormal_ddZfloat_dd_mar   r   r   Ú_register_known_typesž   s  

ó



ó
ó
ÿ
óÿÿÿ
ó


òÿÿrv   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!r?   r@   )r#   ÚgetÚ
ValueErrorÚreprZnewbyteorderÚtobytesrr   rt   rU   rB   rC   rE   Ú_discovered_machar)r%   r$   ÚkeyZ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 rT   )r	   ©Úv©r%   r   r   Ú<lambda>e  s    z$_discovered_machar.<locals>.<lambda>c                    s   t |  ˆ d ¡ƒd S )Nr!   r   )r   Z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 )NrK   r   rƒ   r   ©r%   r$   r   r   r‚   h  s    r   N)r#   r   r�   r   r„   r   r|   a  s   

ür|   Z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_cacherx   Z
obj2sctypeÚappendÚ
issubclassZinexactry   ZfloatingÚ_convert_to_floatÚobjectÚ__new__Ú_init)Úclsr    ÚobjZdtypesZ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)r2   r_   r]   r\   r[   rZ   )r4   r*   r   r   rd   )r   r    r~   ÚsetattrÚgetattrÚflatÚitemsizeÚbitsr+   ÚmaxÚminr)   r_   Znexpr^   ZnmantÚ_macharr8   ÚstripZ	_str_tinyr9   Z_str_maxr7   r6   r:   r;   rI   )r<   r    rV   Ú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
---------------------------------------------------------------
)r/   ©r<   rK   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__rL   r/   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 doubler?   r@   N)r   r˜   r,   r“   rB   rC   rE   rH   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.
        N)r,   rH   r   r   r   r-   3  s   z
finfo.tinyc                 C   s   t jdtdd� | jS )z€The object which calculated these parameters and holds more
        detailed information.

        .. deprecated:: 1.22
        z)`finfo.machar` is deprecated (NumPy 1.22)r?   r@   N)rB   rC   ÚDeprecationWarningr˜   rH   r   r   r   rV   D  s
   þzfinfo.macharN)rL   rM   rN   rO   r‡   rŒ   r�   rœ   r¡   rP   r,   r-   rV   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 )Nrd   z%s%dÚiuzInvalid integer data type %r.)	r   r    r…   r†   Úkindr”   r•   r}   ry   )r<   Z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   N)r¤   r   Ú	_min_valsr}   ÚKeyErrorr1   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   N)r   Ú	_max_valsr}   r§   r¤   r1   r•   r¨   r   r   r   r–      s   ú
úz	iinfo.maxc                 C   s   d}|| j | j| jdœ S )zString representation.z½Machine parameters for %(dtype)s
---------------------------------------------------------------
min = %(min)s
max = %(max)s
---------------------------------------------------------------
©r    r—   r–   Nr«   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ž   rL   r—   r–   r    rH   r   r   r   r¡   ¸  s   ÿziinfo.__repr__N)rL   rM   rN   rO   r¦   rª   r>   rP   r—   r–   rœ   r¡   r   r   r   r   r   S  s    0

)0rO   Ú__all__rB   r˜   r   Z	overridesr   Ú r   r   rr   r	   r
   r   Zumathr   r   r   r   r   r   r   ZcsinglerR   Zcomplex_Zfloat_Z
clongfloatZ	longfloatrŠ   Z
_title_fmtrQ   ÚdictZint64rD   Zint32rt   ZlonglongrS   Zint16r#   rU   rW   rs   rv   r~   r|   r   r   r   r   r   r   Ú<module>   sd    [ýýýýýó 0 g