
    ˀh"                    .   U d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
 d dlmZ er4d dlZd dlmZmZ d dlmZ d dlmZ ej*                  d	k\  rd d
lmZ nd d
lmZ  G d de      Z G d de      Zeeeeef   Zded<    G d de      Z G d de
      Z  G d de
      Z! G d de	      Z" G d de	      Z# G d de	      Z$ G d de	      Z% G d d       Z& G d! d"e'      Z( G d# d$      Z)e)jU                  d       e)_+        e)jU                  d%      e)_,        y)&    )annotations)IntEnum)TYPE_CHECKINGAnyClassVarLiteralProtocol	TypedDict)issue_unstable_warningN)IterableSequence)PolarsBuffer)PolarsColumn)   
   )	TypeAliasc                  0    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zy
)DlpackDeviceTypez3Integer enum for device type codes matching DLPack.      r            	   r   N)__name__
__module____qualname____doc__CPUCUDA
CPU_PINNEDOPENCLVULKANMETALVPIROCM     w/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/polars/interchange/protocol.pyr   r      s-    =
CDJFFE
CDr(   r   c                  ,    e Zd ZdZdZdZdZdZdZdZ	dZ
y	)
	DtypeKinda  
    Integer enum for data types.

    Attributes
    ----------
    INT : int
        Matches to signed integer data type.
    UINT : int
        Matches to unsigned integer data type.
    FLOAT : int
        Matches to floating point data type.
    BOOL : int
        Matches to boolean data type.
    STRING : int
        Matches to string data type (UTF-8 encoded).
    DATETIME : int
        Matches to datetime data type.
    CATEGORICAL : int
        Matches to categorical data type.
    r   r   r               N)r   r   r   r   INTUINTFLOATBOOLSTRINGDATETIMECATEGORICALr'   r(   r)   r+   r+   )   s,    * CDEDFHKr(   r+   r   Dtypec                  $    e Zd ZdZdZdZdZdZdZy)ColumnNullTypea  
    Integer enum for null type representation.

    Attributes
    ----------
    NON_NULLABLE : int
        Non-nullable column.
    USE_NAN : int
        Use explicit float NaN value.
    USE_SENTINEL : int
        Sentinel value besides NaN.
    USE_BITMASK : int
        The bit is set/unset representing a null on a certain position.
    USE_BYTEMASK : int
        The byte is set/unset representing a null on a certain position.
    r   r   r   r   r   N)	r   r   r   r   NON_NULLABLEUSE_NANUSE_SENTINELUSE_BITMASKUSE_BYTEMASKr'   r(   r)   r9   r9   K   s"    " LGLKLr(   r9   c                  0    e Zd ZU dZded<   ded<   ded<   y)ColumnBufferszBuffers backing a column.ztuple[PolarsBuffer, Dtype]dataz!tuple[PolarsBuffer, Dtype] | NonevalidityoffsetsNr   r   r   r   __annotations__r'   r(   r)   r@   r@   d   s    # %$
 0/ /.r(   r@   c                  0    e Zd ZU dZded<   ded<   ded<   y)	CategoricalDescriptionz$Description of a categorical column.bool
is_orderedzLiteral[True]is_dictionaryr   
categoriesNrD   r'   r(   r)   rG   rG   w   s    .    r(   rG   c                  D    e Zd ZdZedd       Zedd       ZddZd	dZy)
BufferzInterchange buffer object.c                     y)zBuffer size in bytes.Nr'   selfs    r)   bufsizezBuffer.bufsize       r(   c                     y)z-Pointer to start of the buffer as an integer.Nr'   rO   s    r)   ptrz
Buffer.ptr   rR   r(   c                     y)z-Represent this structure as DLPack interface.Nr'   rO   s    r)   
__dlpack__zBuffer.__dlpack__   rR   r(   c                     y)zCDevice type and device ID for where the data in the buffer resides.Nr'   rO   s    r)   __dlpack_device__zBuffer.__dlpack_device__   rR   r(   Nreturnint)rZ   r   )rZ   z#tuple[DlpackDeviceType, int | None])	r   r   r   r   propertyrQ   rT   rV   rX   r'   r(   r)   rM   rM      s6    $$ $ < <<Rr(   rM   c                      e Zd ZdZddZedd       Zedd       Zedd       Zedd       Z	edd       Z
edd       Zdd	ZdddZddZy
)ColumnzInterchange column object.c                     y)zSize of the column in elements.Nr'   rO   s    r)   sizezColumn.size   rR   r(   c                     y)zOOffset of the first element with respect to the start of the underlying buffer.Nr'   rO   s    r)   offsetzColumn.offset   rR   r(   c                     y)zData type of the column.Nr'   rO   s    r)   dtypezColumn.dtype   rR   r(   c                     y)z7Description of the categorical data type of the column.Nr'   rO   s    r)   describe_categoricalzColumn.describe_categorical   rR   r(   c                     y)z7Description of the null representation the column uses.Nr'   rO   s    r)   describe_nullzColumn.describe_null   rR   r(   c                     y)z"Number of null elements, if known.Nr'   rO   s    r)   
null_countzColumn.null_count   rR   r(   c                     y)zThe metadata for the column.Nr'   rO   s    r)   metadatazColumn.metadata   rR   r(   c                     y)z3Return the number of chunks the column consists of.Nr'   rO   s    r)   
num_chunkszColumn.num_chunks   rR   r(   Nc                     y)z.Return an iterator yielding the column chunks.Nr'   rP   n_chunkss     r)   
get_chunkszColumn.get_chunks   rR   r(   c                     y)z6Return a dictionary containing the underlying buffers.Nr'   rO   s    r)   get_bufferszColumn.get_buffers   rR   r(   rY   )rZ   r7   )rZ   rG   )rZ   ztuple[ColumnNullType, Any]rZ   
int | NonerZ   zdict[str, Any]N)rq   rv   rZ   Iterable[Column])rZ   r@   )r   r   r   r   r`   r\   rb   rd   rf   rh   rj   rl   rn   rr   rt   r'   r(   r)   r^   r^      s    $. ^ ^ ' ' F F F F 1 1 + +B=Er(   r^   c                      e Zd ZU dZded<   	 	 d	 	 	 	 	 ddZedd       ZddZddZ	ddZ
dd	Zdd
ZddZddZddZddZdddZy)	DataFramezInterchange dataframe object.zClassVar[int]versionc                     yzNConvert to a dataframe object implementing the dataframe interchange protocol.Nr'   rP   nan_as_null
allow_copys      r)   __dataframe__zDataFrame.__dataframe__   rR   r(   c                     y)zThe metadata for the dataframe.Nr'   rO   s    r)   rl   zDataFrame.metadata   rR   r(   c                     y)z.Return the number of columns in the dataframe.Nr'   rO   s    r)   num_columnszDataFrame.num_columns   rR   r(   c                     y)z9Return the number of rows in the dataframe, if available.Nr'   rO   s    r)   num_rowszDataFrame.num_rows   rR   r(   c                     y)z7Return the number of chunks the dataframe consists of..Nr'   rO   s    r)   rn   zDataFrame.num_chunks   rR   r(   c                     y)zReturn the column names.Nr'   rO   s    r)   column_nameszDataFrame.column_names   rR   r(   c                     y)z,Return the column at the indicated position.Nr'   )rP   is     r)   
get_columnzDataFrame.get_column   rR   r(   c                     y)z&Return the column with the given name.Nr'   )rP   names     r)   get_column_by_namezDataFrame.get_column_by_name   rR   r(   c                     y)z(Return an iterator yielding the columns.Nr'   rO   s    r)   get_columnszDataFrame.get_columns   rR   r(   c                     y)zACreate a new dataframe by selecting a subset of columns by index.Nr'   )rP   indicess     r)   select_columnszDataFrame.select_columns   rR   r(   c                     y)z@Create a new dataframe by selecting a subset of columns by name.Nr'   )rP   namess     r)   select_columns_by_namez DataFrame.select_columns_by_name   rR   r(   Nc                     y)z8Return an iterator yielding the chunks of the dataframe.Nr'   rp   s     r)   rr   zDataFrame.get_chunks   rR   r(   FT)r   rH   r   rH   rZ   r{   rw   rY   ru   )rZ   zIterable[str])r   r[   rZ   r^   )r   strrZ   r^   )rZ   ry   )r   zSequence[int]rZ   r{   )r   zSequence[str]rZ   r{   rx   )rq   rv   rZ   zIterable[DataFrame])r   r   r   r   rE   r   r\   rl   r   r   rn   r   r   r   r   r   r   rr   r'   r(   r)   r{   r{      s    ' "]] ] 
	] . .=HF';57POGr(   r{   c                  (    e Zd ZdZ	 	 d	 	 	 	 	 ddZy)SupportsInterchangezHDataframe that supports conversion into an interchange dataframe object.c                     yr~   r'   r   s      r)   r   z!SupportsInterchange.__dataframe__   rR   r(   Nr   )r   rH   r   rH   rZ   r   )r   r   r   r   r   r'   r(   r)   r   r      s2    R "]] ] 
	]r(   r   c                       e Zd ZdZdZdZdZdZy)
Endiannessz.Enum indicating the byte-order of a data type.<>=|N)r   r   r   r   LITTLEBIGNATIVENAr'   r(   r)   r   r      s    8F
CF	Br(   r   c                      e Zd ZdZy)CopyNotAllowedErrorzMException raised when a copy is required, but `allow_copy` is set to `False`.N)r   r   r   r   r'   r(   r)   r   r      s    Wr(   r   c                  h    e Zd ZdZd	dZed
d       Zedd       Zedd       Zedd       Z	ddZ
y)CompatLevelz#Data structure compatibility level.c                    d}t        |      )Nz0it is not allowed to create a CompatLevel object)	TypeError)rP   msgs     r)   __init__zCompatLevel.__init__  s    @nr(   c                F    t         j                  t               }| |_        |S rx   )r   __new___version)r|   compat_levels     r)   _with_versionzCompatLevel._with_version  s     "**;7 'r(   c                 "    t         j                  S rx   )r   _future1r'   r(   r)   _newestzCompatLevel._newest  s    ###r(   c                 @    t        d       t        j                         S )z
        Get the highest supported compatibility level.

        .. warning::
            Highest compatibility level is considered **unstable**. It may be changed
            at any point without it being considered a breaking change.
        z=using the highest compatibility level is considered unstable.)r   r   r   r'   r(   r)   newestzCompatLevel.newest  s      	K	
 ""$$r(   c                 "    t         j                  S )zGet the most compatible level.)r   _compatibler'   r(   r)   oldestzCompatLevel.oldest#  s     &&&r(   c                ~    d| j                   j                   d| j                   j                   d| j                   dS )Nr   .z: r   )	__class__r   r   r   rO   s    r)   __repr__zCompatLevel.__repr__(  s8    4>>,,-Qt~~/J/J.K2dmm_\]^^r(   N)rZ   None)r|   r[   rZ   r   )rZ   r   )rZ   r   )r   r   r   r   r   staticmethodr   r   r   r   r   r'   r(   r)   r   r     s`    -  
 $ $ % % ' '_r(   r   r   )-
__future__r   enumr   typingr   r   r   r   r	   r
   polars._utils.unstabler   syscollections.abcr   r   polars.interchange.bufferr   polars.interchange.columnr   version_infor   typing_extensionsr   r+   tupler[   r   r7   rE   r9   r@   rG   rM   r^   r{   r   r   RuntimeErrorr   r   r   r   r   r'   r(   r)   <module>r      s   "   :266
7"$/
w 
 > Cc12y 2W 2/I /&	Y 	RX R$%EX %EP,G ,G^]( ] X, X%_ %_P &33A6 "003 r(   