o
    ŀg	                     @  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/myenv/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    