o
    ‡Å€g}  ã                   @  sd   d dl mZ d dlmZmZ d dlmZmZ er d dlZ	d dl
ZG dd„ deƒZG dd„ deƒZdS )	é    )Úannotations)ÚTYPE_CHECKINGÚAny)ÚBufferÚDlpackDeviceTypeNc                   @  sV   e Zd ZdZddd	d
„Zeddd„ƒZeddd„ƒZddd„Zddd„Z	ddd„Z
dS ) ÚPandasBufferúF
    Data in the buffer is guaranteed to be contiguous in memory.
    TÚxú
np.ndarrayÚ
allow_copyÚboolÚreturnÚNonec                 C  s:   |j d r|j |jjfks|r| ¡ }ntdƒ‚|| _dS )zG
        Handle only regular columns (= numpy arrays) for now.
        r   zBExports cannot be zero-copy in the case of a non-contiguous bufferN)ÚstridesÚdtypeÚitemsizeÚcopyÚRuntimeErrorÚ_x)Úselfr	   r   © r   úR/var/www/html/myenv/lib/python3.10/site-packages/pandas/core/interchange/buffer.pyÚ__init__   s   
ÿ
zPandasBuffer.__init__Úintc                 C  s   | j j| j jj S ©z'
        Buffer size in bytes.
        )r   Úsizer   r   ©r   r   r   r   Úbufsize*   s   zPandasBuffer.bufsizec                 C  s   | j jd d S )ú?
        Pointer to start of the buffer as an integer.
        Údatar   )r   Ú__array_interface__r   r   r   r   Úptr1   s   zPandasBuffer.ptrr   c                 C  s
   | j  ¡ S ©z?
        Represent this structure as DLPack interface.
        )r   Ú
__dlpack__r   r   r   r   r#   8   ó   
zPandasBuffer.__dlpack__ú#tuple[DlpackDeviceType, int | None]c                 C  ó
   t jdfS ©zU
        Device type and device ID for where the data in the buffer resides.
        N©r   ÚCPUr   r   r   r   Ú__dlpack_device__>   r$   zPandasBuffer.__dlpack_device__Ústrc                 C  s&   dt | j| j|  ¡ d jdœƒ d S )NzPandasBuffer(r   ©r   r!   Údeviceú))r+   r   r!   r*   Únamer   r   r   r   Ú__repr__D   s   ýÿÿøÿzPandasBuffer.__repr__N)T)r	   r
   r   r   r   r   ©r   r   ©r   r   ©r   r%   ©r   r+   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r!   r#   r*   r0   r   r   r   r   r      s    

r   c                   @  sT   e Zd ZdZddd	„Zedd
d„ƒZeddd„ƒZddd„Zddd„Z	ddd„Z
dS )ÚPandasBufferPyarrowr   Úbufferú	pa.BufferÚlengthr   r   r   c                C  s   || _ || _dS )z0
        Handle pyarrow chunked arrays.
        N)Ú_bufferÚ_length)r   r<   r>   r   r   r   r   W   s   	
zPandasBufferPyarrow.__init__c                 C  ó   | j jS r   )r?   r   r   r   r   r   r   c   ó   zPandasBufferPyarrow.bufsizec                 C  rA   )r   )r?   Úaddressr   r   r   r   r!   j   rB   zPandasBufferPyarrow.ptrr   c                 C  s   t ƒ ‚r"   )ÚNotImplementedErrorr   r   r   r   r#   q   s   zPandasBufferPyarrow.__dlpack__r%   c                 C  r&   r'   r(   r   r   r   r   r*   w   r$   z%PandasBufferPyarrow.__dlpack_device__r+   c                 C  s   dt | j| jddœƒ d S )NzPandasBuffer[pyarrow](r)   r,   r.   )r+   r   r!   r   r   r   r   r0   }   s   ýÿÿøÿzPandasBufferPyarrow.__repr__N)r<   r=   r>   r   r   r   r1   r2   r3   r4   r5   r   r   r   r   r;   R   s    


r;   )Ú
__future__r   Útypingr   r   Ú*pandas.core.interchange.dataframe_protocolr   r   ÚnumpyÚnpÚpyarrowÚpar   r;   r   r   r   r   Ú<module>   s    @