o
    �¨ÊhÀ	  ã                   @  s€   d Z ddlmZ ddlZddlmZ ddlZddlm	Z	 ddl
ZddlmZ er.ddlmZ G dd	„ d	e	ƒZG d
d„ deƒZdS )zX
Test extension array that has custom attribute information (not stored on the dtype).

é    )ÚannotationsN)ÚTYPE_CHECKING)ÚExtensionDtype)ÚExtensionArray)Útype_tc                   @  s(   e Zd ZeZdZejZe	ddd„ƒZ
dS )ÚFloatAttrDtypeÚ
float_attrÚreturnútype_t[FloatAttrArray]c                 C  s   t S )zq
        Return the array type associated with this dtype.

        Returns
        -------
        type
        )ÚFloatAttrArray)Úcls© r   ú^/var/www/html/env/lib/python3.10/site-packages/pandas/tests/extension/array_with_attr/array.pyÚconstruct_array_type   s   	z#FloatAttrDtype.construct_array_typeN)r	   r
   )Ú__name__Ú
__module__Ú__qualname__ÚfloatÚtypeÚnameÚnpÚnanÚna_valueÚclassmethodr   r   r   r   r   r      s    r   c                   @  sn   e Zd Zeƒ ZdZdddd„Zedddœd	d
„ƒZdd„ Z	ddd„Z
dd„ Zddd„Zdd„ Zedd„ ƒZdS )r   iè  Nr	   ÚNonec                 C  s6   t |tjƒs
tdƒ‚|jdkstdƒ‚|| _|| _d S )Nz5Need to pass a numpy array of float64 dtype as valuesÚfloat64)Ú
isinstancer   ÚndarrayÚ	TypeErrorÚdtypeÚdataÚattr)ÚselfÚvaluesr!   r   r   r   Ú__init__*   s   

zFloatAttrArray.__init__F©r   Úcopyc                C  s2   |st j|dd�}| |ƒS t j|d|d�}| |ƒS )Nr   )r   r%   )r   ÚasarrayÚarray)r   Úscalarsr   r&   r    r   r   r   Ú_from_sequence2   s
   ÿzFloatAttrArray._from_sequencec                 C  s<   t |tjƒr| j| S tjj | |¡}t| ƒ| j| | j	ƒS ©N)
r   ÚnumbersÚIntegralr    ÚpdÚapiÚindexersÚcheck_array_indexerr   r!   )r"   Úitemr   r   r   Ú__getitem__:   s   
zFloatAttrArray.__getitem__Úintc                 C  s
   t | jƒS r+   )Úlenr    ©r"   r   r   r   Ú__len__B   s   
zFloatAttrArray.__len__c                 C  s   t  | j¡S r+   )r   Úisnanr    r6   r   r   r   ÚisnaE   s   zFloatAttrArray.isnac                 C  sF   ddl m} | j}|r|d u r| jj}|||||d�}t| ƒ|| jƒS )Nr   )Útake)Ú
fill_valueÚ
allow_fill)Úpandas.api.extensionsr:   r    r   r   r   r!   )r"   Úindexerr<   r;   r:   r    Úresultr   r   r   r:   H   s   zFloatAttrArray.takec                 C  s   t | ƒ| j ¡ | jƒS r+   )r   r    r&   r!   r6   r   r   r   r&   R   s   zFloatAttrArray.copyc                 C  s4   t  dd„ |D ƒ¡}t|ƒr|d jnd }| ||ƒS )Nc                 S  s   g | ]}|j ‘qS r   )r    )Ú.0Úxr   r   r   Ú
<listcomp>W   s    z4FloatAttrArray._concat_same_type.<locals>.<listcomp>r   )r   Úconcatenater5   r!   )r   Ú	to_concatr    r!   r   r   r   Ú_concat_same_typeU   s   
z FloatAttrArray._concat_same_typer+   )r	   r   )r	   r4   )FN)r   r   r   r   r   Ú__array_priority__r$   r   r*   r3   r7   r9   r:   r&   rE   r   r   r   r   r   &   s    


r   )Ú__doc__Ú
__future__r   r,   Útypingr   Únumpyr   Úpandas.core.dtypes.baser   Úpandasr.   Úpandas.core.arraysr   Úpandas._typingr   r   r   r   r   r   r   Ú<module>   s    