o
    Ò·hÇ  ã                   @  sb   d dl mZ d dlmZ d dlZd dlmZmZ d dl	m
Z
 e
ejƒe
dƒkZG dd„ deƒZdS )	é    )Úannotations)ÚAnyN)ÚBufferÚDlpackDeviceType)ÚVersionz1.22.0c                   @  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 ) ÚPandasBufferzF
    Data in the buffer is guaranteed to be contiguous in memory.
    TÚxú
np.ndarrayÚ
allow_copyÚboolÚreturnÚNonec                 C  s0   |j |jjfks|r| ¡ }ntdƒ‚|| _dS )zG
        Handle only regular columns (= numpy arrays) for now.
        zBExports cannot be zero-copy in the case of a non-contiguous bufferN)ÚstridesÚdtypeÚitemsizeÚcopyÚRuntimeErrorÚ_x)Úselfr   r
   © r   úQ/var/www/html/venv/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 )z?
        Pointer to start of the buffer as an integer.
        Údatar   )r   Ú__array_interface__r   r   r   r   Úptr/   s   zPandasBuffer.ptrr   c                 C  s   t r| j ¡ S tdƒ‚)z?
        Represent this structure as DLPack interface.
        Ú
__dlpack__)Ú_NUMPY_HAS_DLPACKr   r   ÚNotImplementedErrorr   r   r   r   r   6   s   
zPandasBuffer.__dlpack__ú#tuple[DlpackDeviceType, int | None]c                 C  s
   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__>   s   
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$   r)   r   r   r   r   r      s    

r   )Ú
__future__r   Útypingr   ÚnumpyÚnpÚ*pandas.core.interchange.dataframe_protocolr   r   Úpandas.util.versionr   Ú__version__r    r   r   r   r   r   Ú<module>   s    