a
    hÝEb^  ã                   @   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   s   | j dkr|  ¡ } d| _| S )zfix rank-0 --> rank-1r   )r   )ÚndimÚcopyÚshape©Úa© r   úT/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/numpy/core/getlimits.pyÚ_fr0   s    
r   c                 C   s   | j dkr|  ¡ } d| _| S )zfix rank > 0 --> rank-0r   r   )Úsizer   r   r   r   r   r   Ú_fr1   s    
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.é   ©Ú
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.)r3   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.
        )r   r1   rD   r   r   r   r%   [   s    zMachArLike._float_to_floatc                 C   s   t |g| jƒS )z€Converts float to conv.

        Parameters
        ----------
        value : float
            value to be converted.
        )r	   r#   rD   r   r   r   r1   e   s    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#   rD   r   r   r   r3   o   s    zMachArLike._float_to_str)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r<   Úpropertyr   rG   r%   r1   r3   r   r   r   r   r       s   ÿ



r   z(numpy {} precision floating point numberz%24.16eÚdouble)r   rH   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    rT   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 �sb0    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0    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   )rW   rX   rY   rZ   r[   r\   r,   r]   r^   r'   r(   r)   r+   r   s   š™™™™™Y<š™™™™™¹¿s   š™™™™™¹¿š™™™™™Y<Údd)ÚntypesZfloat16r   r   rT   Ú	_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   

ó



ó
ó
8
óÿÿ8
ó


òÿÿrs   c                 C   sŽ   t  | ¡}|du rtt| ƒƒ‚| dƒ d¡ ¡ }d}| tjkrPt |dd… ¡}|du rbt |¡}|durn|S t	j
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    zVSignature {} for {} does not match any known type: falling back to type probe functionr=   r>   )r!   ÚgetÚ
ValueErrorÚreprZnewbyteorderÚtobytesro   rq   rR   r@   rA   rB   rC   Ú_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 rQ   )r	   ©Úv©r#   r   r   Ú<lambda>d  ó    z$_discovered_machar.<locals>.<lambda>c                    s   t |  ˆ d ¡ƒd S )Nr   r   )r   Zastyper|   )r"   r   r   r   e  r€   c                    s   t t| ƒd ˆ ƒS )Nr   ©r	   r   r|   r~   r   r   r   f  r€   c                    s   ˆd t t| ƒd ˆ ƒ S )NrH   r   r�   r|   ©r#   r"   r   r   r   g  r€   r   )r!   r   r~   r   r‚   r   ry   `  s    

üry   Ú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0 | j |d ¡}|d urJ|S |g}t  |¡}||urp| |¡ |}t|t j	ƒsˆt
d| ƒ‚| j |d ¡}|d ur¢|S t|t jƒsÌt| }||urÌ| |¡ |}| j |d ¡}|d uræ|S t | ¡ |¡}|D ]}|| j|< qú|S )Nzdata type %r not inexact)r   r   Ú	TypeErrorÚtypeÚ_finfo_cacheru   Z
obj2sctypeÚappendÚ
issubclassZinexactrv   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 ƒ q4| jjd | _|jjd | _	| j	 | _
|jjd | _|j| _|j| _|| _|j ¡ | _|j ¡ | _|j ¡ | _|j ¡ | _|j ¡ | _|j ¡ | _|j ¡ | _| S )N)r0   r\   rZ   rY   rX   rW   )r2   r(   r   r   ra   )r   r   r{   ÚsetattrÚgetattrÚflatÚitemsizeÚbitsr)   ÚmaxÚminr'   r\   Znexpr[   ZnmantÚ_macharr6   ÚstripZ	_str_tinyr7   Z_str_maxr5   r4   r8   r9   rG   )r:   r   rS   Ú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:   rH   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__rI   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>   )r   r—   r*   r’   r@   rA   rC   rF   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*   rF   r   r   r   r+   2  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>   )r@   rA   ÚDeprecationWarningr—   rF   r   r   r   rS   C  s
    þzfinfo.macharN)rI   rJ   rK   rL   r†   r‹   rŒ   r›   r    rM   r*   r+   rS   r   r   r   r   r   k  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y2   t  t|ƒ¡| _Y n0 | jj| _| jjd | _d| j| jf | _| jdvrxtd| jf ƒ‚d S )Nra   z%s%dÚiuzInvalid integer data type %r.)	r   r   r„   r…   Úkindr“   r”   rz   rv   )r:   Zint_typer   r   r   r<   ‡  s    

ziinfo.__init__c                 C   sZ   | j dkrdS ztj| j }W n2 tyP   td| jd >  ƒ}|tj| j< Y n0 |S dS )zMinimum value of given dtype.Úur   r   N)r£   r   Ú	_min_valsrz   ÚKeyErrorr/   r”   ©r:   Úvalr   r   r   r–   ’  s    
z	iinfo.minc                 C   sh   zt j| j }W nR tyb   | jdkr<td| j> d ƒ}ntd| jd > d ƒ}|t j| j< Y n0 |S )zMaximum value of given dtype.r¤   r   )r   Ú	_max_valsrz   r¦   r£   r/   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•   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�   rI   r–   r•   r   rF   r   r   r   r    ·  s    ÿziinfo.__repr__N)rI   rJ   rK   rL   r¥   r©   r<   rM   r–   r•   r›   r    r   r   r   r   r   R  s   0

)0rL   Ú__all__r@   r—   r   Z	overridesr   Ú r   r   ro   r	   r
   r   Zumathr   r   r   r   r   r   r   ZcsinglerO   Zcomplex_Zfloat_Z
clongfloatZ	longfloatr‰   Z
_title_fmtrN   ÚdictZint64rB   Zint32rq   ZlonglongrP   Zint16r!   rR   rT   rp   rs   r{   ry   r   r   r   r   r   r   Ú<module>   sb   [ýýýýýó / g