a
    DBìjÀ	  ã                   @  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d„ƒZ
dS )ÚFloatAttrDtypeZ
float_attrztype_t[FloatAttrArray]©Úreturnc                 C  s   t S )zq
        Return the array type associated with this dtype.

        Returns
        -------
        type
        )ÚFloatAttrArray)Úcls© r   úk/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pandas/tests/extension/array_with_attr/array.pyÚconstruct_array_type   s    	z#FloatAttrDtype.construct_array_typeN)Ú__name__Ú
__module__Ú__qualname__ÚfloatÚtypeÚnameÚnpÚnanÚna_valueÚclassmethodr   r   r   r   r   r      s
   r   c                   @  sv   e Zd Zeƒ ZdZdddœdd„Zedddœd	d
„ƒZdd„ Z	ddœdd„Z
dd„ Zddd„Zdd„ Zedd„ ƒZdS )r
   iè  NÚNoner   c                 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   ZndarrayÚ	TypeErrorÚdtypeÚdataÚattr)ÚselfÚvaluesr   r   r   r   Ú__init__*   s    
zFloatAttrArray.__init__F©r   Úcopyc                C  s,   |st j|dd�}nt j|d|d�}| |ƒS )Nr   )r   r#   )r   ZasarrayÚarray)r   Z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 d S ©N)
r   ÚnumbersÚIntegralr   ÚpdÚapiZindexersZ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   r0   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)Zpandas.api.extensionsr4   r   r   r   r   r   )r    Zindexerr6   r5   r4   r   Úresultr   r   r   r4   H   s    zFloatAttrArray.takec                 C  s   t | ƒ| j ¡ | jƒS r'   )r   r   r$   r   r0   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   ó    z4FloatAttrArray._concat_same_type.<locals>.<listcomp>r   )r   Zconcatenater/   r   )r   Z	to_concatr   r   r   r   r   Ú_concat_same_typeU   s    z FloatAttrArray._concat_same_type)N)FN)r   r   r   r   r   Z__array_priority__r"   r   r&   r-   r1   r3   r4   r$   r<   r   r   r   r   r
   &   s   

r
   )Ú__doc__Ú
__future__r   r(   Útypingr   Únumpyr   Zpandas.core.dtypes.baser   Zpandasr*   Zpandas.core.arraysr   Zpandas._typingr   r   r
   r   r   r   r   Ú<module>   s   