U
     )3g³  ã                   @  s|   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„ deƒZd
S )zo
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                      sT   e Zd ZdZddddœ‡ fdd„Zdd	œd
d„Zdd	œdd„Zdd	œdd„Z‡  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
    Nz8Mapping[str, DType] | Iterable[tuple[str, DType]] | NoneÚNone)ÚschemaÚreturnc                   s   |pi }t ƒ  |¡ d S )N)ÚsuperÚ__init__)Úselfr
   ©Ú	__class__© ú3/tmp/pip-unpacked-wheel-hfsjijke/narwhals/schema.pyr   8   s    zSchema.__init__z	list[str])r   c                 C  s   t |  ¡ ƒS )z#Get the column names of the schema.)ÚlistÚkeys©r   r   r   r   Únames>   s    zSchema.nameszlist[DType]c                 C  s   t |  ¡ ƒS )z!Get the data types of the schema.)r   Úvaluesr   r   r   r   ÚdtypesB   s    zSchema.dtypesÚintc                 C  s   t | ƒS )z(Get the number of columns in the schema.)Úlenr   r   r   r   r   F   s    z
Schema.len)N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ú__classcell__r   r   r   r   r      s     ÿN)r   Ú
__future__r   Úcollectionsr   Útypingr   r   r   Znarwhals.dtypesr   ÚstrZ
BaseSchemaÚ__all__r   r   r   r   r   Ú<module>   s   