
    gc                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ erddl	m
Z
 eee
f   ZneZdgZ G d	 de      Zy
)zxSchema.

Adapted from Polars implementation at:
https://github.com/pola-rs/polars/blob/main/py-polars/polars/schema.py.
    )annotations)OrderedDict)TYPE_CHECKING)Iterable)Mapping)DTypeSchemac                  F     e Zd ZdZ	 d	 	 	 d fdZddZd	dZd
dZ xZS )r	   a  Ordered mapping of column names to their data type.

    Arguments:
        schema: Mapping[str, DType] | Iterable[tuple[str, DType]] | None
            The schema definition given by column names and their associated.
            *instantiated* Narwhals data type. Accepts a mapping or an iterable of tuples.

    Examples:
        Define a schema by passing *instantiated* data types.

        >>> import narwhals as nw
        >>> schema = nw.Schema({"foo": nw.Int8(), "bar": nw.String()})
        >>> schema
        Schema({'foo': Int8, 'bar': String})

        Access the data type associated with a specific column name.

        >>> schema["foo"]
        Int8

        Access various schema properties using the `names`, `dtypes`, and `len` methods.

        >>> schema.names()
        ['foo', 'bar']
        >>> schema.dtypes()
        [Int8, String]
        >>> schema.len()
        2
    c                0    |xs i }t         |   |       y N)super__init__)selfschema	__class__s     D/var/www/openai/venv/lib/python3.12/site-packages/narwhals/schema.pyr   zSchema.__init__8   s     2     c                4    t        | j                               S )zXGet the column names of the schema.

        Returns:
            Column names.
        )listkeysr   s    r   nameszSchema.names>   s     DIIK  r   c                4    t        | j                               S )z^Get the data types of the schema.

        Returns:
            Data types of schema.
        )r   valuesr   s    r   dtypeszSchema.dtypesF   s     DKKM""r   c                    t        |       S )zbGet the number of columns in the schema.

        Returns:
            Number of columns.
        )lenr   s    r   r   z
Schema.lenN   s     4yr   r   )r   z8Mapping[str, DType] | Iterable[tuple[str, DType]] | NonereturnNone)r   z	list[str])r   zlist[DType])r   int)	__name__
__module____qualname____doc__r   r   r   r   __classcell__)r   s   @r   r	   r	      s3    > RV!N!	!!#r   N)r$   
__future__r   collectionsr   typingr   r   r   narwhals.dtypesr   str
BaseSchema__all__r	    r   r   <module>r.      sI    # #    %S%Z(J J*;Z ;r   