o
    �¨ÊhF  ã                   @  sŽ  U d dl mZ d dlmZ d dlZd dlmZ d dlm	Z	 d dl
mZmZ G dd„ deƒZG d	d
„ d
eƒZdZeG dd„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZeG dd„ deƒƒZe ej¡eƒ e ej¡eƒ e ej¡eƒ e ej¡eƒ e ej¡eƒ e ej¡eƒ e ej¡eƒ e ej ¡eƒ iZ!de"d< dS )é    )Úannotations)ÚClassVarN)Úregister_extension_dtype)Úis_integer_dtype)ÚNumericArrayÚNumericDtypec                   @  sJ   e Zd ZdZe ej¡ZeZ	e
ddd„ƒZe
ddd„ƒZe
ddd„ƒZdS )ÚIntegerDtypea'  
    An ExtensionDtype to hold a single size & kind of integer dtype.

    These specific implementations are subclasses of the non-public
    IntegerDtype. For example, we have Int8Dtype to represent signed int 8s.

    The attributes name & type are set when these subclasses are created.
    Úreturnútype[IntegerArray]c                 C  ó   t S )zq
        Return the array type associated with this dtype.

        Returns
        -------
        type
        )ÚIntegerArray©Úcls© r   úL/var/www/html/env/lib/python3.10/site-packages/pandas/core/arrays/integer.pyÚconstruct_array_type   s   	z!IntegerDtype.construct_array_typeúdict[np.dtype, IntegerDtype]c                 C  r   )N)ÚNUMPY_INT_TO_DTYPEr   r   r   r   Ú_get_dtype_mapping(   s   zIntegerDtype._get_dtype_mappingÚvaluesú
np.ndarrayÚdtypeúnp.dtypeÚcopyÚboolc              
   C  st   z	|j |d|d�W S  ty9 } z$|j ||d�}||k ¡ r&|W  Y d}~S td|j› dt |¡› �ƒ|‚d}~ww )zÉ
        Safely cast the values to the given dtype.

        "safe" in this context means the casting is lossless. e.g. if 'values'
        has a floating dtype, each value must be an integer.
        Úsafe)Úcastingr   )r   Nz"cannot safely cast non-equivalent z to )ÚastypeÚ	TypeErrorÚallr   Únp)r   r   r   r   ÚerrÚcastedr   r   r   Ú
_safe_cast,   s   ÿþ€ûzIntegerDtype._safe_castN)r	   r
   )r	   r   )r   r   r   r   r   r   r	   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    r   Úint64Ú_default_np_dtyper   Ú_checkerÚclassmethodr   r   r#   r   r   r   r   r      s    	
r   c                   @  s    e Zd ZdZeZdZdZdZdS )r   aó  
    Array of integer (optional missing) values.

    Uses :attr:`pandas.NA` as the missing value.

    .. warning::

       IntegerArray is currently experimental, and its API or internal
       implementation may change without warning.

    We represent an IntegerArray with 2 numpy arrays:

    - data: contains a numpy integer array of the appropriate dtype
    - mask: a boolean array holding a mask on the data, True is missing

    To construct an IntegerArray from generic array-like input, use
    :func:`pandas.array` with one of the integer dtypes (see examples).

    See :ref:`integer_na` for more.

    Parameters
    ----------
    values : numpy.ndarray
        A 1-d integer-dtype array.
    mask : numpy.ndarray
        A 1-d boolean-dtype array indicating missing values.
    copy : bool, default False
        Whether to copy the `values` and `mask`.

    Attributes
    ----------
    None

    Methods
    -------
    None

    Returns
    -------
    IntegerArray

    Examples
    --------
    Create an IntegerArray with :func:`pandas.array`.

    >>> int_array = pd.array([1, None, 3], dtype=pd.Int32Dtype())
    >>> int_array
    <IntegerArray>
    [1, <NA>, 3]
    Length: 3, dtype: Int32

    String aliases for the dtypes are also available. They are capitalized.

    >>> pd.array([1, None, 3], dtype='Int32')
    <IntegerArray>
    [1, <NA>, 3]
    Length: 3, dtype: Int32

    >>> pd.array([1, None, 3], dtype='UInt16')
    <IntegerArray>
    [1, <NA>, 3]
    Length: 3, dtype: UInt16
    é   r   N)	r$   r%   r&   r'   r   Ú
_dtype_clsÚ_internal_fill_valueÚ_truthy_valueÚ_falsey_valuer   r   r   r   r   @   s    @r   aä  
An ExtensionDtype for {dtype} integer data.

Uses :attr:`pandas.NA` as its missing value, rather than :attr:`numpy.nan`.

Attributes
----------
None

Methods
-------
None

Examples
--------
For Int8Dtype:

>>> ser = pd.Series([2, pd.NA], dtype=pd.Int8Dtype())
>>> ser.dtype
Int8Dtype()

For Int16Dtype:

>>> ser = pd.Series([2, pd.NA], dtype=pd.Int16Dtype())
>>> ser.dtype
Int16Dtype()

For Int32Dtype:

>>> ser = pd.Series([2, pd.NA], dtype=pd.Int32Dtype())
>>> ser.dtype
Int32Dtype()

For Int64Dtype:

>>> ser = pd.Series([2, pd.NA], dtype=pd.Int64Dtype())
>>> ser.dtype
Int64Dtype()

For UInt8Dtype:

>>> ser = pd.Series([2, pd.NA], dtype=pd.UInt8Dtype())
>>> ser.dtype
UInt8Dtype()

For UInt16Dtype:

>>> ser = pd.Series([2, pd.NA], dtype=pd.UInt16Dtype())
>>> ser.dtype
UInt16Dtype()

For UInt32Dtype:

>>> ser = pd.Series([2, pd.NA], dtype=pd.UInt32Dtype())
>>> ser.dtype
UInt32Dtype()

For UInt64Dtype:

>>> ser = pd.Series([2, pd.NA], dtype=pd.UInt64Dtype())
>>> ser.dtype
UInt64Dtype()
c                   @  ó,   e Zd ZU ejZdZded< ej	dd�Z
dS )Ú	Int8DtypeÚInt8úClassVar[str]ÚnameÚint8©r   N)r$   r%   r&   r    r6   Útyper5   Ú__annotations__Ú_dtype_docstringÚformatr'   r   r   r   r   r2   Ï   ó   
 r2   c                   @  r1   )Ú
Int16DtypeÚInt16r4   r5   Úint16r7   N)r$   r%   r&   r    r?   r8   r5   r9   r:   r;   r'   r   r   r   r   r=   Ö   r<   r=   c                   @  r1   )Ú
Int32DtypeÚInt32r4   r5   Úint32r7   N)r$   r%   r&   r    rB   r8   r5   r9   r:   r;   r'   r   r   r   r   r@   Ý   r<   r@   c                   @  r1   )Ú
Int64DtypeÚInt64r4   r5   r(   r7   N)r$   r%   r&   r    r(   r8   r5   r9   r:   r;   r'   r   r   r   r   rC   ä   r<   rC   c                   @  r1   )Ú
UInt8DtypeÚUInt8r4   r5   Úuint8r7   N)r$   r%   r&   r    rG   r8   r5   r9   r:   r;   r'   r   r   r   r   rE   ë   r<   rE   c                   @  r1   )ÚUInt16DtypeÚUInt16r4   r5   Úuint16r7   N)r$   r%   r&   r    rJ   r8   r5   r9   r:   r;   r'   r   r   r   r   rH   ò   r<   rH   c                   @  r1   )ÚUInt32DtypeÚUInt32r4   r5   Úuint32r7   N)r$   r%   r&   r    rM   r8   r5   r9   r:   r;   r'   r   r   r   r   rK   ù   r<   rK   c                   @  r1   )ÚUInt64DtypeÚUInt64r4   r5   Úuint64r7   N)r$   r%   r&   r    rP   r8   r5   r9   r:   r;   r'   r   r   r   r   rN      r<   rN   r   r   )#Ú
__future__r   Útypingr   Únumpyr    Úpandas.core.dtypes.baser   Úpandas.core.dtypes.commonr   Úpandas.core.arrays.numericr   r   r   r   r:   r2   r=   r@   rC   rE   rH   rK   rN   r   r6   r?   rB   r(   rG   rJ   rM   rP   r   r9   r   r   r   r   Ú<module>   sD    0LCø