
    'hJ	                    |    S SK Jr  S SKJr  S SKJrJrJrJr  S SK	J
r
  \(       a  S SKJr  S SKJr   " S S\5      rg	)
    )annotations)TYPE_CHECKING)BufferCopyNotAllowedErrorDlpackDeviceType	DtypeKind)polars_dtype_to_dtype)NoReturn)Seriesc                  p    \ rS rSrSrSS.SS jjr\SS j5       r\SS j5       rSS jr	SS	 jr
SS
 jrSrg)PolarsBuffer   a-  
A buffer object backed by a Polars Series consisting of a single chunk.

Parameters
----------
data
    The Polars Series backing the buffer object.
allow_copy
    Allow data to be copied during operations on this column. If set to `False`,
    a RuntimeError will be raised if data would be copied.
T)
allow_copyc                   UR                  5       S:  a$  U(       d  Sn[        U5      eUR                  5       nXl        g )N   z-non-contiguous buffer must be made contiguous)n_chunksr   rechunk_data)selfdatar   msgs       lC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\polars/interchange/buffer.py__init__PolarsBuffer.__init__    s3    ==?QE)#..<<>D
    c                ,   [        U R                  R                  5      nUS   [        R                  :X  a<  U R                  R                  5       u  p#nX4-   n[        US5      u  pgUS:X  a  U$ US-   $ U R                  R                  5       US   S-  -  $ )zBuffer size in bytes.r      r   )r	   r   dtyper   BOOL_get_buffer_infodivmodlen)r   r   _offsetlengthn_bitsn_bytesrests           r   bufsizePolarsBuffer.bufsize)   s     &djj&6&678y~~% $

 ; ; =Av_F"61-MGqy{"zz~~58q=11r   c                B    U R                   R                  5       u  n  nU$ )z-Pointer to start of the buffer as an integer.)r   r    )r   pointerr#   s      r   ptrPolarsBuffer.ptr:   s!     

335Ar   c                    Sn[        U5      e)z-Represent this structure as DLPack interface.
__dlpack__)NotImplementedError)r   r   s     r   r0   PolarsBuffer.__dlpack__@   s    !#&&r   c                &    [         R                  S4$ )zCDevice type and device ID for where the data in the buffer resides.N)r   CPU)r   s    r   __dlpack_device__PolarsBuffer.__dlpack_device__E   s     $$d++r   c                    U R                   nU R                  nU R                  5       S   R                  nSU SU SU< S3$ )Nr   zPolarsBuffer(bufsize=z, ptr=z	, device=))r)   r-   r5   name)r   r)   r-   devices       r   __repr__PolarsBuffer.__repr__I   sH    ,,hh'')!,11&wivcU)F:QOOr   )r   N)r   r   r   boolreturnNone)r>   int)r>   r
   )r>   ztuple[DlpackDeviceType, None])r>   str)__name__
__module____qualname____firstlineno____doc__r   propertyr)   r-   r0   r5   r;   __static_attributes__ r   r   r   r      sJ    
 <@  2 2   
'
,Pr   r   N)
__future__r   typingr   polars.interchange.protocolr   r   r   r   polars.interchange.utilsr	   r
   polarsr   r   rI   r   r   <module>rO      s1    "    ;:P6 :Pr   