a
    Pf	                     @  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   e/var/www/ai-form-bot/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   