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/venv/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                   @  sh   e Zd Ze ZdZddddZe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__Fc                 C  s   t j|d|d}| |S )Nr   )r   copy)r   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__7   s   
zFloatAttrArray.__getitem__intc                 C  s
   t | jS r)   )lenr    r"   r   r   r   __len__?   s   
zFloatAttrArray.__len__c                 C  s   t | jS r)   )r   isnanr    r4   r   r   r   isnaB   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.extensionsr8   r    r   r   r   r!   )r"   indexerr:   r9   r8   r    resultr   r   r   r8   E   s   zFloatAttrArray.takec                 C  s   t | | j | jS r)   )r   r    r%   r!   r4   r   r   r   r%   O   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>T   s    z4FloatAttrArray._concat_same_type.<locals>.<listcomp>r   )r   concatenater3   r!   )r   	to_concatr    r!   r   r   r   _concat_same_typeR   s   
z FloatAttrArray._concat_same_typer)   )r	   r   )NF)r	   r2   )FN)r   r   r   r   r   __array_priority__r$   r   r(   r1   r5   r7   r8   r%   rC   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    