o
    5³c44  ã                   @  s  d dl mZ d dlmZmZ d dlZd dlZd dlm	Z
mZ d dlmZmZ d dlmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZ d d	lmZ d d
lm Z m!Z! G dd„ de ƒZ"i Z#de#d< G dd„ de"ƒZ$G dd„ de$ƒZ%G dd„ de$ƒZ&G dd„ de"ƒZ'dS )é    )Úannotations)ÚCallableÚHashableN)ÚindexÚlib)ÚDtypeÚnpt)Úcache_readonlyÚdoc)Úfind_stack_level)Úis_dtype_equalÚis_float_dtypeÚis_integer_dtypeÚis_numeric_dtypeÚ	is_scalarÚis_signed_integer_dtypeÚis_unsigned_integer_dtypeÚpandas_dtype)Ú	ABCSeries)ÚIndexÚmaybe_extract_namec                      sø  e Zd ZU dZdZded< dZded< edfZd	ed
< dZ	dZ
dZded< e ej¡eje ej¡eje ej¡eje ej¡eje ej¡eje ej¡eje ej¡eje ej¡eje ej¡ej e ej!¡ej"e ej#¡ej$e ej%¡ej&iZ'ded< e(d?dd„ƒZ)e*d@dd„ƒZ+	dAdBdd„Z,e-dCdd„ƒZ.e-dDd d!„ƒZ/e-dEd"d#„ƒZ0e*e1e2j3ƒdFd$d%„ƒƒZ3e1e2j4ƒdGdH‡ fd*d+„ƒZ4e1e2j5ƒe6j7fdId-d.„ƒZ5e1e2j8ƒe6j7fdJ‡ fd1d2„ƒZ8‡ fd3d4„Z9e-dKd7d8„ƒZ:d9dd:dd;œdL‡ fd=d>„Z;‡  Z<S )MÚNumericIndexa!  
    Immutable numeric sequence used for indexing and alignment.

    The basic object storing axis labels for all pandas objects.
    NumericIndex is a special case of `Index` with purely numpy int/uint/float labels.

    .. versionadded:: 1.4.0

    Parameters
    ----------
    data : array-like (1-dimensional)
    dtype : NumPy dtype (default: None)
    copy : bool
        Make a copy of input ndarray.
    name : object
        Name to be stored in the index.

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

    Methods
    -------
    None

    See Also
    --------
    Index : The base pandas Index type.
    Int64Index : Index of purely int64 labels (deprecated).
    UInt64Index : Index of purely uint64 labels (deprecated).
    Float64Index : Index of  purely float64 labels (deprecated).

    Notes
    -----
    An NumericIndex instance can **only** contain numpy int64/32/16/8, uint64/32/16/8 or
    float64/32/16 dtype. In particular, ``NumericIndex`` *can not* hold Pandas numeric
    dtypes (:class:`Int64Dtype`, :class:`Int32Dtype` etc.).
    Únumericindexú
np.ndarrayÚ_valuesNúnp.dtype | NoneÚ_default_dtypeznumeric typeztuple[Callable[..., bool], str]Ú_dtype_validation_metadataTFÚboolÚ(_is_backward_compat_public_numeric_indexz*dict[np.dtype, type[libindex.IndexEngine]]Ú_engine_typesÚreturnútype[libindex.IndexEngine]c                 C  s   | j | j S ©N)r    Údtype©Úself© r'   úQ/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/core/indexes/numeric.pyÚ_engine_typem   s   zNumericIndex._engine_typeÚstrc                 C  s   dddddœ| j j S )NÚintegerÚfloatingÚcomplex)ÚiÚuÚfÚc)r$   Úkindr%   r'   r'   r(   Úinferred_types   s   üûzNumericIndex.inferred_typer$   úDtype | Nonec                 C  s(   t ||| ƒ}|  |||¡}| j||dS )N©Úname)r   Ú_ensure_arrayÚ_simple_new)ÚclsÚdatar$   Úcopyr6   Úsubarrr'   r'   r(   Ú__new__|   s   zNumericIndex.__new__r;   c              	   C  s6  |   |¡ t|tjtfƒsGt|ƒr|  |¡‚t|ttt	fƒs"t|ƒ}|}tj
||d}|du rG|jjdkrG| tu rG|dk ¡ rGtj
|tjd}t|jjtƒrS|  |¡ |  |¡}|s`t|j|ƒs‰ztj|||d}|   |j¡ W n ttfy   td| j› ƒ‚w |  ||¡ n|}|jdkr”tdƒ‚t 
|¡}|S )	zF
        Ensure we have a valid array to pass to _simple_new.
        )r$   Nr0   r   )r$   r;   zdata is not compatible with é   z Index data must be 1-dimensional)Ú_validate_dtypeÚ
isinstanceÚnpÚndarrayr   r   Ú_scalar_data_errorr   ÚlistÚtupleÚasarrayr$   r2   ÚUInt64IndexÚallÚuint64Ú
issubclassÚtyper*   Ú_string_data_errorÚ_ensure_dtyper   ÚarrayÚ	TypeErrorÚ
ValueErrorÚ__name__Ú_assert_safe_castingÚndim)r9   r:   r$   r;   Úorigr<   r'   r'   r(   r7   „   s6   



ÿ

zNumericIndex._ensure_arrayÚNonec                 C  s6   |d u rd S | j \}}||ƒstd|› d|› ƒ‚d S )Nz#Incorrect `dtype` passed: expected z, received )r   rP   )r9   r$   Úvalidation_funcÚexpectedr'   r'   r(   r?   µ   s   
ÿÿzNumericIndex._validate_dtypec                 C  s6   |du r| j S t|ƒ}t|tjƒsJ ‚| jr|S | j S )z’
        Ensure int64 dtype for Int64Index etc. but allow int32 etc. for NumericIndex.

        Assumes dtype has already been validated.
        N)r   r   r@   rA   r$   r   )r9   r$   r'   r'   r(   rM   À   s   zNumericIndex._ensure_dtypec                 C  s   dS )NFr'   r%   r'   r'   r(   Ú_should_fallback_to_positionalØ   s   z+NumericIndex._should_fallback_to_positionalÚkeyÚslicer2   Úis_framec                   s<   t | jƒr|dv sJ ‚|  |j|j|j¡S tƒ j|||dS )N)ÚlocÚgetitem)r2   r[   )r   r$   Úslice_indexerÚstartÚstopÚstepÚsuperÚ_convert_slice_indexer)r&   rY   r2   r[   ©Ú	__class__r'   r(   rc   Ý   s   
z#NumericIndex._convert_slice_indexerÚsidec                 C  s.   |ddd t jfv sJ ‚|  |dd¡ |  |¡S )Nr\   r]   r2   Ú_maybe_cast_slice_bound)r   Ú
no_defaultÚ_deprecated_argÚ_maybe_cast_indexer)r&   Úlabelrf   r2   r'   r'   r(   rg   ì   s   
z$NumericIndex._maybe_cast_slice_boundr6   r   c                   sD   | j s|jjdkr|tju r| jn|}tj||dS tƒ j	||dS )Nr0   r5   )Úvaluesr6   )
Ú_can_hold_nar$   r2   r   rh   Ú_nameÚFloat64Indexr8   rb   Ú_shallow_copy)r&   rl   r6   rd   r'   r(   rp   ö   s   zNumericIndex._shallow_copyc                   s`   t ƒ  ||¡}t |jtj¡s.|jdkrtdt| ƒj	› dƒ‚tdt| ƒj	› dt
|ƒ› ƒ‚|S )Nr   ztolerance argument for z1 must contain numeric elements if it is list typez$ must be numeric if it is a scalar: )rb   Ú_convert_tolerancerA   Ú
issubdtyper$   ÚnumberrS   rP   rK   rQ   Úrepr)r&   Ú	toleranceÚtargetrd   r'   r(   rq   þ   s   
ÿÿÿzNumericIndex._convert_tolerancer:   r<   c                 C  s&   t |jƒrt ||¡stdƒ‚dS dS )zï
        Ensure incoming data can be represented with matching signed-ness.

        Needed if the process of casting data from some accepted dtype to the internal
        dtype(s) bears the risk of truncation (e.g. float to int).
        z.Unsafe NumPy casting, you must explicitly castN)r   r$   rA   Úarray_equalrO   )r9   r:   r<   r'   r'   r(   rR     s
   
þz!NumericIndex._assert_safe_castingÚ Ú.©Úna_repÚfloat_formatÚdecimalÚquotingúnpt.NDArray[np.object_]c                  sP   ddl m} t| jƒr|| j||||dd}| ¡ S tƒ jd||||dœ|¤ŽS )Nr   )ÚFloatArrayFormatterF)r{   r|   r}   r~   Úfixed_widthrz   r'   )Úpandas.io.formats.formatr€   r   r$   r   Úget_result_as_arrayrb   Ú_format_native_types)r&   r{   r|   r}   r~   Úkwargsr€   Ú	formatterrd   r'   r(   r„     s&   
úüûz!NumericIndex._format_native_types)r!   r"   )r!   r*   )NNFN)r$   r4   r!   r   )r;   r   )r$   r4   r!   rU   )r$   r4   r!   r   )r!   r   )F)rY   rZ   r2   r*   r[   r   )rf   r*   )r6   r   )r:   r   r<   r   r!   rU   )r!   r   )=rQ   Ú
__module__Ú__qualname__Ú__doc__Ú_typÚ__annotations__r   r   r   Ú_is_numeric_dtypeÚ_can_hold_stringsr   rA   r$   Úint8ÚlibindexÚ
Int8EngineÚint16ÚInt16EngineÚint32ÚInt32EngineÚint64ÚInt64EngineÚuint8ÚUInt8EngineÚuint16ÚUInt16EngineÚuint32ÚUInt32EnginerI   ÚUInt64EngineÚfloat32ÚFloat32EngineÚfloat64ÚFloat64EngineÚ	complex64ÚComplex64EngineÚ
complex128ÚComplex128Enginer    Úpropertyr)   r	   r3   r=   Úclassmethodr7   r?   rM   r
   r   rX   rc   rg   r   rh   rp   rq   rR   r„   Ú__classcell__r'   r'   rd   r(   r   +   sd   
 'þô	ÿ0
	ÿr   aŠ  
    Immutable sequence used for indexing and alignment.

    .. deprecated:: 1.4.0
        In pandas v2.0 %(klass)s will be removed and :class:`NumericIndex` used instead.
        %(klass)s will remain fully functional for the duration of pandas 1.x.

    The basic object storing axis labels for all pandas objects.
    %(klass)s is a special case of `Index` with purely %(ltype)s labels. %(extra)s.

    Parameters
    ----------
    data : array-like (1-dimensional)
    dtype : NumPy dtype (default: %(dtype)s)
    copy : bool
        Make a copy of input ndarray.
    name : object
        Name to be stored in the index.

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

    Methods
    -------
    None

    See Also
    --------
    Index : The base pandas Index type.
    NumericIndex : Index of numpy int/uint/float data.

    Notes
    -----
    An Index instance can **only** contain hashable objects.
Úclass_descrc                   @  s,   e Zd ZU dZdZded< ed
dd„ƒZd	S )ÚIntegerIndexz@
    This is an abstract class for Int64Index, UInt64Index.
    Fr   r   r!   únpt.NDArray[np.int64]c                 C  s    t jdttƒ d | j | j¡S )NzAIndex.asi8 is deprecated and will be removed in a future version.)Ú
stacklevel)ÚwarningsÚwarnÚFutureWarningr   r   Úviewr   r%   r'   r'   r(   Úasi8e  s   ýzIntegerIndex.asi8N)r!   r«   )rQ   r‡   rˆ   r‰   r   r‹   r¦   r±   r'   r'   r'   r(   rª   ^  s
   
 rª   c                   @  sL   e Zd Zd ddddœZed e ZdZe ej	¡Z
edfZedd
d„ƒZdS )Ú
Int64Indexr+   r•   rx   ©ÚklassÚltyper$   Úextrar©   Ú
int64indexzsigned integerr!   útype[libindex.Int64Engine]c                 C  ó   t jS r#   )r   r–   r%   r'   r'   r(   r)   }  ó   zInt64Index._engine_typeN)r!   r¸   )rQ   r‡   rˆ   Ú_index_descr_argsÚ_num_index_shared_docsr‰   rŠ   rA   r$   r•   r   r   r   r¦   r)   r'   r'   r'   r(   r²   p  ó    ür²   c                   @  sL   e Zd Zd ddddœZed e ZdZe ej	¡Z
edfZedd	d
„ƒZdS )rG   zunsigned integerrI   rx   r³   r©   Úuint64indexr!   útype[libindex.UInt64Engine]c                 C  r¹   r#   )r   r   r%   r'   r'   r(   r)     rº   zUInt64Index._engine_typeN)r!   r¿   )rQ   r‡   rˆ   r»   r¼   r‰   rŠ   rA   r$   rI   r   r   r   r¦   r)   r'   r'   r'   r(   rG   ‚  r½   rG   c                   @  sZ   e Zd ZU d ddddœZed e ZdZe ej	¡Z
edfZdZded	< eddd„ƒZdS )ro   r    Úfloatrx   )r´   r$   rµ   r¶   r©   Úfloat64indexFr   r   r!   útype[libindex.Float64Engine]c                 C  r¹   r#   )r   r¡   r%   r'   r'   r(   r)   ¢  rº   zFloat64Index._engine_typeN)r!   rÂ   )rQ   r‡   rˆ   r»   r¼   r‰   rŠ   rA   r$   r    r   r   r   r   r‹   r¦   r)   r'   r'   r'   r(   ro   ”  s   
 üro   )(Ú
__future__r   Útypingr   r   r­   ÚnumpyrA   Úpandas._libsr   r   r   Úpandas._typingr   r   Úpandas.util._decoratorsr	   r
   Úpandas.util._exceptionsr   Úpandas.core.dtypes.commonr   r   r   r   r   r   r   r   Úpandas.core.dtypes.genericr   Úpandas.core.indexes.baser   r   r   r¼   rª   r²   rG   ro   r'   r'   r'   r(   Ú<module>   s.    (
  
þÿ(