o
    L¾±hq ã                   @  s
  U d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	m
Z
 d dlmZ d dlmZmZ d dlmZmZmZmZ d dlmZ d dlmZmZ d d	lmZ 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&m'Z'm(Z(m)Z)m*Z* d dl+m,Z, d dl-m.Z. d dl/m0Z0m1Z1 d dl2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZC d dlDmEZEmFZFmGZG e!r¯d dlmHZH d dlImJZJ d dlKZLd dlMZNd dlOZPd dlQmRZRmSZSmTZTmUZUmVZVmWZW d dlXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_ d dl`maZambZb d dlcmdZd d dlemfZfmgZgmhZh d dlimjZjmkZkmlZlmmZmmnZn d dlompZpmqZq d dlrmsZs d dltmuZu d dlvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZm€Z€mZm‚Z‚mƒZƒm„Z„m…Z… e†Z‡deˆd< e'd e(eqe" epe" eue" f d!Z‰e'd"ƒZŠe'd#ƒZ‹e'd$ƒZŒe'd%ƒZe'd&ƒZŽe'd'ƒZe'd(ƒZe'd)d*d!Z‘eTd+ƒZ’e'd,ƒZ“e'd-ƒZ”e'd.ƒZ•G d/d0„ d0e&ƒZ–G d1d2„ d2e&ƒZ—G d3d4„ d4e&ƒZ˜e'd5ƒZ™e'd6d7d8Zše'd9d7d8Z›e'd:d;d!Zœd<Zdeˆd=< d>Zždeˆd?< G d@dA„ dAe&eš ƒZŸG dBdC„ dCe&e› ƒZ G dDdE„ dEe&ƒZ¡G dFdG„ dGe&ƒZ¢G dHdI„ dIe&ƒZ£G dJdK„ dKe£e¢e&ƒZ¤G dLd;„ d;e¡e¤e&ƒZ¥G dMdN„ dNe£e&ƒZ¦G dOdP„ dPeƒZ§G dQdR„ dRe,ƒZ¨e¨j©dSe¨jªdTe¨j«dUe¨j¬dVe¨j­dWe¨j®dWe¨j¯dXe¨j°dYe¨j±dZe¨j²d[e¨j³d\iZ´d]eˆd^< e¨j°d_e¨jªd`e¨j­dae¨j®dbiZµdceˆdd< 	 ededfd¥dkdl„ƒZ¶ed¦dodp„ƒZ·d§dtdu„Z¸d¨dwdx„Z¹d©d{d|„Zºdªdd€„Z»e*d«d†d‡„ƒZ¼e*d¬dŠd‡„ƒZ¼e*d­dd‡„ƒZ¼e*d®dd‡„ƒZ¼e*d¯d’d‡„ƒZ¼e*d°d”d‡„ƒZ¼e*d±d—d‡„ƒZ¼e*d²d™d‡„ƒZ¼e*d³dœd‡„ƒZ¼e*d´džd‡„ƒZ¼e*dµd¡d‡„ƒZ¼e*d¶d£d‡„ƒZ¼e*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½dºd»„Z¿	d¾dd¼œd¿dÁdÂ„ZÀdÀdÃdÄ„ZÁe!r;eeÂd7dÅZÃnd dlÄZÄeÄjÅdÆkrLeeÂd7dÅZÃndÁdÉdÊ„ZÃdÂdÍdÎ„ZÆdÃdÑdÒ„ZÇdÄdÕdÖ„ZÈdÅdÜdÝ„ZÉdÆdàdá„ZÊdÇdådæ„ZËdÇdçdè„ZÌdÈdîdï„ZÍdÉdódô„ZÎdÊdöd÷„ZÏdËdùdú„ZÐdÌdüdý„ZÑdÍdÿd „ZÒdÎdd„ZÓdÏdd„ZÔdÐdd	„ZÕdÑdd„ZÖdÒdd„Z×dÓdd„ZØdddœdÔdd„ZÙdÕd!d"„ZÚdÖd%d&„ZÛd×d*d+„ZÜdØd,d-„ZÝdÙd3d4„ZÞdÚd=d>„ZßdÛd@dA„ZàdÜdCdD„ZádÝdFdG„ZâdÞdIdJ„ZãdßdMdN„ZädàdQdR„ZådádUdV„ZædádWdX„Zçdâd[d\„Zèdãd_d`„Zédädbdc„Zêdådedf„Zëdædhdi„Zìdçdkdl„Zídèdqdr„Zîdédwdx„Zïdêdzd{„Zðdëd}d~„ZñG dd€„ d€ƒZòdìd„d…„ZóG d†d‡„ d‡ƒZôdíd‹dŒ„Zõdîdd‘„Zödïd“d”„Z÷dd•œdðd™dš„ZøG d›dœ„ dœe$e™ ƒZùeddfdñd d¡„ƒZúdòd£d¤„ZûdS (ó  é    )ÚannotationsN)Ú
CollectionÚ	ContainerÚIterableÚIteratorÚMappingÚSequence)Útimezone)ÚEnumÚauto)ÚcacheÚ	lru_cacheÚpartialÚwraps)Ú	find_spec)Úgetattr_staticÚgetdoc)Úchain)Ú
attrgetter)Ú	token_hex)
ÚTYPE_CHECKINGÚAnyÚCallableÚGenericÚLiteralÚProtocolÚTypeVarÚUnionÚcastÚoverload)Ú
NoAutoEnum)Úissue_deprecation_warning)Úassert_neverÚ
deprecated)Úget_cudfÚget_dask_dataframeÚ
get_duckdbÚget_ibisÚ	get_modinÚ
get_pandasÚ
get_polarsÚget_pyarrowÚget_pyspark_connectÚget_pyspark_sqlÚget_sqlframeÚis_narwhals_seriesÚis_narwhals_series_intÚis_numpy_array_1dÚis_numpy_array_1d_intÚis_pandas_like_dataframeÚis_pandas_like_series)ÚColumnNotFoundErrorÚDuplicateErrorÚInvalidOperationError)ÚSet)Ú
ModuleType)ÚConcatenateÚLiteralStringÚ	ParamSpecÚSelfÚ	TypeAliasÚTypeIs)ÚCompliantExprÚCompliantExprTÚCompliantFrameTÚCompliantSeriesOrNativeExprT_coÚCompliantSeriesTÚNativeFrameT_coÚNativeSeriesT_co)Ú	EvalNamesÚNativeLazyFrameT©Ú	Namespace)ÚArrowStreamExportableÚIntoArrowTableÚToNarwhalsT_co)ÚBackendÚIntoBackendÚ_DataFrameLazyImplÚ_EagerAllowedImplÚ_LazyFrameCollectImpl©Ú	DataFrameÚ	LazyFrame©ÚDType©ÚSeries)ÚCompliantDataFrameÚCompliantLazyFrameÚCompliantSeriesÚDTypesÚIntoSeriesTÚMultiIndexSelectorÚSingleIndexSelectorÚSizedMultiIndexSelectorÚSizeUnitÚSupportsNativeNamespaceÚTimeUnitÚ_1DArrayÚ_SliceIndexÚ
_SliceNameÚ
_SliceNoner>   ÚUnknownBackendNameÚFrameOrSeriesT)ÚboundÚ_T1Ú_T2Ú_T3Ú_T4Ú_T5Ú_T6Ú_T7Ú_FnzCallable[..., Any]ÚPÚRÚR1ÚR2c                   @  ó   e Zd ZU ded< dS )Ú_SupportsVersionÚstrÚ__version__N©Ú__name__Ú
__module__Ú__qualname__Ú__annotations__© r   r   úP/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/narwhals/_utils.pyry   ~   s   
 ry   c                   @  s   e Zd Zd	d
dd„ZdS )Ú_SupportsGetNÚinstancer   Úownerú
Any | NoneÚreturnc                C  ó   d S ©Nr   )Úselfr„   r…   r   r   r‚   Ú__get__‚   s    z_SupportsGet.__get__r‰   )r„   r   r…   r†   r‡   r   )r}   r~   r   r‹   r   r   r   r‚   rƒ      s    rƒ   c                   @  ó   e Zd Zeddd„ƒZdS )Ú_StoresColumnsr‡   úSequence[str]c                 C  rˆ   r‰   r   ©rŠ   r   r   r‚   Úcolumns…   ó   z_StoresColumns.columnsN)r‡   rŽ   )r}   r~   r   Úpropertyr   r   r   r   r‚   r   „   ó    r   Ú_TÚ
NativeT_coT)Ú	covariantÚCompliantT_coÚ	_ContextTÚ_FullContextz&Callable[Concatenate[_ContextT, P], R]Ú_Methodz Callable[Concatenate[_T, P], R2]Ú_Constructorc                   @  ó   e Zd ZdZeddd„ƒZdS )Ú_StoresNativez’Provides access to a native object.

    Native objects have types like:

    >>> from pandas import Series
    >>> from pyarrow import Table
    r‡   r•   c                 C  ó   dS )zReturn the native object.Nr   r   r   r   r‚   Únativeš   ó   z_StoresNative.nativeN)r‡   r•   )r}   r~   r   Ú__doc__r’   rŸ   r   r   r   r‚   r   ‘   ó    r   c                   @  rœ   )Ú_StoresCompliantzÓProvides access to a compliant object.

    Compliant objects have types like:

    >>> from narwhals._pandas_like.series import PandasLikeSeries
    >>> from narwhals._arrow.dataframe import ArrowDataFrame
    r‡   r—   c                 C  rž   )zReturn the compliant object.Nr   r   r   r   r‚   Ú	compliant©   r    z_StoresCompliant.compliantN)r‡   r—   )r}   r~   r   r¡   r’   r¤   r   r   r   r‚   r£       r¢   r£   c                   @  rŒ   )Ú_StoresBackendVersionr‡   útuple[int, ...]c                 C  rž   )z#Version tuple for a native package.Nr   r   r   r   r‚   Ú_backend_version°   r    z&_StoresBackendVersion._backend_versionN©r‡   r¦   )r}   r~   r   r’   r§   r   r   r   r‚   r¥   ¯   r“   r¥   c                   @  rx   )Ú_StoresVersionÚVersionÚ_versionNr|   r   r   r   r‚   r©   ¶   ó   
 r©   c                   @  rx   )Ú_StoresImplementationÚImplementationÚ_implementationNr|   r   r   r   r‚   r­   »   r¬   r­   c                   @  ó   e Zd ZdZdS )Ú_LimitedContextzEProvides 2 attributes.

    - `_implementation`
    - `_version`
    N©r}   r~   r   r¡   r   r   r   r‚   r±   À   ó    r±   c                   @  r°   )r™   z^Provides 3 attributes.

    - `_implementation`
    - `_backend_version`
    - `_version`
    Nr²   r   r   r   r‚   r™   È   r³   c                   @  s   e Zd ZdZddd„ZdS )ÚValidateBackendVersionz=Ensure the target `Implementation` is on a supported version.r‡   ÚNonec                 C  s   | j  ¡ }dS )z½Raise if installed version below `nw._utils.MIN_VERSIONS`.

        **Only use this when moving between backends.**
        Otherwise, the validation will have taken place already.
        N)r¯   r§   )rŠ   Ú_r   r   r‚   Ú_validate_backend_versionÔ   s   z0ValidateBackendVersion._validate_backend_versionN)r‡   rµ   )r}   r~   r   r¡   r·   r   r   r   r‚   r´   Ñ   s    r´   c                   @  sd   e Zd Zeƒ Zeƒ Zeƒ Zeddd„ƒZeddd„ƒZ	edd	d
„ƒZ
eddd„ƒZeddd„ƒZdS )rª   r‡   útype[Namespace[Any]]c                 C  óD   | t ju rddlm} |S | t ju rddlm} |S ddlm} |S )Nr   rI   )rª   ÚV1Únarwhals.stable.v1._namespacerJ   ÚV2Únarwhals.stable.v2._namespaceÚnarwhals._namespace)rŠ   ÚNamespaceV1ÚNamespaceV2rJ   r   r   r‚   Ú	namespaceâ   ó   

zVersion.namespacer]   c                 C  r¹   )Nr   )Údtypes)rª   rº   Únarwhals.stable.v1rÃ   r¼   Únarwhals.stable.v2Únarwhals)rŠ   Ú	dtypes_v1Ú	dtypes_v2rÃ   r   r   r‚   rÃ   ð   rÂ   zVersion.dtypesútype[DataFrame[Any]]c                 C  r¹   )Nr   ©rT   )rª   rº   rÄ   rT   r¼   rÅ   Únarwhals.dataframe)rŠ   ÚDataFrameV1ÚDataFrameV2rT   r   r   r‚   Ú	dataframeþ   rÂ   zVersion.dataframeútype[LazyFrame[Any]]c                 C  r¹   )Nr   ©rU   )rª   rº   rÄ   rU   r¼   rÅ   rË   )rŠ   ÚLazyFrameV1ÚLazyFrameV2rU   r   r   r‚   Ú	lazyframe  rÂ   zVersion.lazyframeútype[Series[Any]]c                 C  r¹   )Nr   rX   )rª   rº   rÄ   rY   r¼   rÅ   Únarwhals.series)rŠ   ÚSeriesV1ÚSeriesV2rY   r   r   r‚   Úseries  rÂ   zVersion.seriesN)r‡   r¸   )r‡   r]   )r‡   rÉ   )r‡   rÏ   )r‡   rÔ   )r}   r~   r   r   rº   r¼   ÚMAINr’   rÁ   rÃ   rÎ   rÓ   rØ   r   r   r   r‚   rª   Ý   s    rª   c                   @  s"  e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ		 dZ
	 d	Z	 d
Z	 dZ	 dZ	 dZ	 d@dd„ZedAdd„ƒZedBdd„ƒZedCdd„ƒZdDdd „ZdEd"d#„ZdEd$d%„ZdEd&d'„ZdEd(d)„ZdEd*d+„ZdEd,d-„ZdEd.d/„ZdEd0d1„ZdEd2d3„ZdEd4d5„ZdEd6d7„Z dEd8d9„Z!dEd:d;„Z"dFd=d>„Z#d?S )Gr®   z?Implementation of native object (pandas, Polars, PyArrow, ...).ÚpandasÚmodinÚcudfÚpyarrowÚpysparkÚpolarsÚdaskÚduckdbÚibisÚsqlframezpyspark[connect]Úunknownr‡   rz   c                 C  s
   t | jƒS r‰   )rz   Úvaluer   r   r   r‚   Ú__str__E  ó   
zImplementation.__str__Úclsú
type[Self]Únative_namespacer9   c                 C  sj   t ƒ tjtƒ tjtƒ tjtƒ tjt	ƒ tj
tƒ tjtƒ tjtƒ tjtƒ tjtƒ tjtƒ tji}| |tj¡S )zŽInstantiate Implementation object from a native namespace module.

        Arguments:
            native_namespace: Native namespace.
        )r)   r®   ÚPANDASr(   ÚMODINr$   ÚCUDFr+   ÚPYARROWr-   ÚPYSPARKr*   ÚPOLARSr%   ÚDASKr&   ÚDUCKDBr'   ÚIBISr.   ÚSQLFRAMEr,   ÚPYSPARK_CONNECTÚgetÚUNKNOWN)rè   rê   Úmappingr   r   r‚   Úfrom_native_namespaceH  s   
õz$Implementation.from_native_namespaceÚbackend_namec                 C  s$   z| |ƒW S  t y   tj Y S w )zžInstantiate Implementation object from a native namespace module.

        Arguments:
            backend_name: Name of backend, expressed as string.
        )Ú
ValueErrorr®   r÷   )rè   rú   r   r   r‚   Úfrom_string`  s
   

ÿzImplementation.from_stringÚbackendú)IntoBackend[Backend] | UnknownBackendNamec                 C  s,   t |tƒr
|  |¡S t |tƒr|S |  |¡S )z¢Instantiate from native namespace module, string, or Implementation.

        Arguments:
            backend: Backend to instantiate Implementation from.
        )Ú
isinstancerz   rü   r®   rù   )rè   rý   r   r   r‚   Úfrom_backendl  s   
ÿÿÿýûzImplementation.from_backendc                 C  s4   | t ju rd}t|ƒ‚|  ¡  t | | j¡}t|ƒS )zCReturn the native namespace module corresponding to Implementation.z:Cannot return native namespace from UNKNOWN Implementation)r®   r÷   ÚAssertionErrorr§   Ú_IMPLEMENTATION_TO_MODULE_NAMErö   rå   Ú_import_native_namespace)rŠ   ÚmsgÚmodule_namer   r   r‚   Úto_native_namespace}  s   
z"Implementation.to_native_namespaceÚboolc                 C  ó
   | t ju S )a7  Return whether implementation is pandas.

        Examples:
            >>> import pandas as pd
            >>> import narwhals as nw
            >>> df_native = pd.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_pandas()
            True
        )r®   rë   r   r   r   r‚   Ú	is_pandas‡  ó   
zImplementation.is_pandasc                 C  ó   | t jt jt jhv S )aL  Return whether implementation is pandas, Modin, or cuDF.

        Examples:
            >>> import pandas as pd
            >>> import narwhals as nw
            >>> df_native = pd.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_pandas_like()
            True
        )r®   rë   rì   rí   r   r   r   r‚   Úis_pandas_like”  s   zImplementation.is_pandas_likec                 C  r  )aI  Return whether implementation is pyspark or sqlframe.

        Examples:
            >>> import pandas as pd
            >>> import narwhals as nw
            >>> df_native = pd.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_spark_like()
            False
        )r®   rï   rô   rõ   r   r   r   r‚   Úis_spark_like¡  s
   ýzImplementation.is_spark_likec                 C  r  )a7  Return whether implementation is Polars.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_polars()
            True
        )r®   rð   r   r   r   r‚   Ú	is_polars²  r
  zImplementation.is_polarsc                 C  r  )a4  Return whether implementation is cuDF.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_cudf()
            False
        )r®   rí   r   r   r   r‚   Úis_cudf¿  r
  zImplementation.is_cudfc                 C  r  )a6  Return whether implementation is Modin.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_modin()
            False
        )r®   rì   r   r   r   r‚   Úis_modinÌ  r
  zImplementation.is_modinc                 C  r  )a:  Return whether implementation is PySpark.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_pyspark()
            False
        )r®   rï   r   r   r   r‚   Ú
is_pysparkÙ  r
  zImplementation.is_pysparkc                 C  r  )aB  Return whether implementation is PySpark.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_pyspark_connect()
            False
        )r®   rõ   r   r   r   r‚   Úis_pyspark_connectæ  r
  z!Implementation.is_pyspark_connectc                 C  r  )a:  Return whether implementation is PyArrow.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_pyarrow()
            False
        )r®   rî   r   r   r   r‚   Ú
is_pyarrowó  r
  zImplementation.is_pyarrowc                 C  r  )a4  Return whether implementation is Dask.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_dask()
            False
        )r®   rñ   r   r   r   r‚   Úis_dask   r
  zImplementation.is_daskc                 C  r  )a8  Return whether implementation is DuckDB.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_duckdb()
            False
        )r®   rò   r   r   r   r‚   Ú	is_duckdb  r
  zImplementation.is_duckdbc                 C  r  )a4  Return whether implementation is Ibis.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_ibis()
            False
        )r®   ró   r   r   r   r‚   Úis_ibis  r
  zImplementation.is_ibisc                 C  r  )a<  Return whether implementation is SQLFrame.

        Examples:
            >>> import polars as pl
            >>> import narwhals as nw
            >>> df_native = pl.DataFrame({"a": [1, 2, 3]})
            >>> df = nw.from_native(df_native)
            >>> df.implementation.is_sqlframe()
            False
        )r®   rô   r   r   r   r‚   Úis_sqlframe'  r
  zImplementation.is_sqlframer¦   c                 C  s   t | ƒS )zReturns backend version.©Úbackend_versionr   r   r   r‚   r§   4  s   zImplementation._backend_versionN©r‡   rz   )rè   ré   rê   r9   r‡   r®   )rè   ré   rú   rz   r‡   r®   )rè   ré   rý   rþ   r‡   r®   )r‡   r9   )r‡   r  r¨   )$r}   r~   r   r¡   rë   rì   rí   rî   rï   rð   rñ   rò   ró   rô   rõ   r÷   ræ   Úclassmethodrù   rü   r   r  r	  r  r  r  r  r  r  r  r  r  r  r  r  r§   r   r   r   r‚   r®   )  s`    















r®   )é   r  é   )r   é   é   )é   é
   )é   )r  é   )r   é   é   )iè  r  ©r  )é   )r  é   r   z(Mapping[Implementation, tuple[int, ...]]ÚMIN_VERSIONSzdask.dataframezmodin.pandaszpyspark.sqlzpyspark.sql.connectzMapping[Implementation, str]r  é   )Úmaxsizer  rz   r‡   r9   c                 C  s   ddl m} || ƒS )Nr   )Úimport_module)Ú	importlibr,  )r  r,  r   r   r‚   r  P  s   r  Úimplementationr¦   c                C  sÌ   t | tƒs	t| ƒ | tju rd}t|ƒ‚| }t ||j¡}t|ƒ}| 	¡ r-dd l
}|j}n| ¡ s5| ¡ r<dd l}|}n| ¡ rGdd l}|}n|}t|ƒ}	|	t|  }
k rdd|› d|
› d|	› }t|ƒ‚|	S )Nz9Cannot return backend version from UNKNOWN Implementationr   zMinimum version of z supported by Narwhals is z	, found: )rÿ   r®   r"   r÷   r  r  rö   rå   r  r  Úsqlframe._versionr«   r  r  rÞ   r  rà   Úparse_versionr)  rû   )r.  r  Úimplr  rê   rã   Úinto_versionrÞ   rà   ÚversionÚmin_versionr   r   r‚   r  Z  s.   

r  Úargsr   ú	list[Any]c                 C  s*   t t| ƒdkrt| d ƒr| d ƒS | ƒS )Nr  r   )ÚlistÚlenÚ_is_iterable)r5  r   r   r‚   Úflattenz  s   *r:  Úargc                 C  s   t | ttfƒs
| fS | S r‰   )rÿ   r7  Útuple)r;  r   r   r‚   Útupleify~  s   r=  úAny | Iterable[Any]r  c                 C  sˆ   ddl m} tƒ  }d urt| |j|jfƒs*tƒ  }d ur6t| |j|j|j|jfƒr6dt| ƒ›d}t	|ƒ‚t| t
ƒoCt| tt|fƒ S )Nr   rX   z(Expected Narwhals class or scalar, got: z`.

Hint: Perhaps you
- forgot a `nw.from_native` somewhere?
- used `pl.col` instead of `nw.col`?)rÕ   rY   r)   rÿ   rT   r*   ÚExprrU   Úqualified_type_nameÚ	TypeErrorr   rz   Úbytes)r;  rY   ÚpdÚplr  r   r   r‚   r9  „  s    ÿÿr9  r3  ú#str | ModuleType | _SupportsVersionc                 C  s:   t | tƒr| n| j}t dd|¡}tdd„ | d¡D ƒƒS )zÂSimple version parser; split into a tuple of ints for comparison.

    Arguments:
        version: Version string, or object with one, to parse.

    Returns:
        Parsed version number.
    z(\D?dev.*$)Ú c                 s  s"    | ]}t t d d|¡ƒV  qdS )z\DrF  N)ÚintÚreÚsub)Ú.0Úvr   r   r‚   Ú	<genexpr>§  s   €  z parse_version.<locals>.<genexpr>Ú.)rÿ   rz   r{   rH  rI  r<  Úsplit)r3  Úversion_strr   r   r‚   r0  ™  s   r0  Ú
obj_or_clsÚtypeÚcls_or_tupleútype[_T]úTypeIs[type[_T]]c                 C  rˆ   r‰   r   ©rP  rR  r   r   r‚   Úisinstance_or_issubclassª  r    rV  úobject | typeúTypeIs[_T | type[_T]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  °  r    útuple[type[_T1], type[_T2]]úTypeIs[type[_T1 | _T2]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  ¶  r    ú#TypeIs[_T1 | _T2 | type[_T1 | _T2]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  ¼  r    ú&tuple[type[_T1], type[_T2], type[_T3]]úTypeIs[type[_T1 | _T2 | _T3]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  Â  r    ú/TypeIs[_T1 | _T2 | _T3 | type[_T1 | _T2 | _T3]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  È  r    ú1tuple[type[_T1], type[_T2], type[_T3], type[_T4]]ú#TypeIs[type[_T1 | _T2 | _T3 | _T4]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  Î  r    ú;TypeIs[_T1 | _T2 | _T3 | _T4 | type[_T1 | _T2 | _T3 | _T4]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  Ô  ó   ú<tuple[type[_T1], type[_T2], type[_T3], type[_T4], type[_T5]]ú)TypeIs[type[_T1 | _T2 | _T3 | _T4 | _T5]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  Û  rb  úGTypeIs[_T1 | _T2 | _T3 | _T4 | _T5 | type[_T1 | _T2 | _T3 | _T4 | _T5]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  â  rb  úGtuple[type[_T1], type[_T2], type[_T3], type[_T4], type[_T5], type[_T6]]ú/TypeIs[type[_T1 | _T2 | _T3 | _T4 | _T5 | _T6]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  é  rb  úSTypeIs[_T1 | _T2 | _T3 | _T4 | _T5 | _T6 | type[_T1 | _T2 | _T3 | _T4 | _T5 | _T6]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  ð  ó   úRtuple[type[_T1], type[_T2], type[_T3], type[_T4], type[_T5], type[_T6], type[_T7]]ú5TypeIs[type[_T1 | _T2 | _T3 | _T4 | _T5 | _T6 | _T7]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV  ù  ri  ú_TypeIs[_T1 | _T2 | _T3 | _T4 | _T5 | _T6 | _T7 | type[_T1 | _T2 | _T3 | _T4 | _T5 | _T6 | _T7]]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV    s   útuple[type, ...]úTypeIs[Any]c                 C  rˆ   r‰   r   rU  r   r   r‚   rV    r    c                 C  s>   ddl m} t| |ƒrt| |ƒS t| |ƒpt| tƒot| |ƒS )Nr   rV   )Únarwhals.dtypesrW   rÿ   rQ  Ú
issubclass)rP  rR  rW   r   r   r‚   rV    s   


ÿÚitemsúIterable[Any]rµ   c                   s\   ddl m‰ m‰ t‡ fdd„| D ƒƒst‡fdd„| D ƒƒr d S ddd„ | D ƒ› }t|ƒ‚)	Nr   rS   c                 3  ó    | ]}t |ˆ ƒV  qd S r‰   ©rÿ   ©rJ  ÚitemrÊ   r   r‚   rL  '  ó   € z$validate_laziness.<locals>.<genexpr>c                 3  rs  r‰   rt  ru  rÐ   r   r‚   rL  (  rw  zGThe items to concatenate should either all be eager, or all lazy, got: c                 S  s   g | ]}t |ƒ‘qS r   )rQ  ru  r   r   r‚   Ú
<listcomp>+  s    z%validate_laziness.<locals>.<listcomp>)rË   rT   rU   ÚallrA  )rq  r  r   rS   r‚   Úvalidate_laziness$  s   ÿrz  ÚlhsÚrhsú-Series[Any] | DataFrame[Any] | LazyFrame[Any]c                 C  sò  ddl m} ddlm} ddd	„}td| ƒ}td|ƒ}tt|d
dƒ|ƒrLtt|d
dƒ|ƒrL||jjj	ƒ ||jjj	ƒ | 
|j |jjj|jjj	 ¡¡S tt|d
dƒ|ƒr}tt|ddƒ|ƒr}||jjj	ƒ ||jjj	ƒ | 
|j |jjj|jjj	 ¡¡S tt|ddƒ|ƒr®tt|d
dƒ|ƒr®||jjj	ƒ ||jjj	ƒ | 
|j |jjj|jjj	 ¡¡S tt|ddƒ|ƒrßtt|ddƒ|ƒrß||jjj	ƒ ||jjj	ƒ | 
|j |jjj|jjj	 ¡¡S t|ƒt|ƒkr÷dt|ƒ› dt|ƒ› }t|ƒ‚| S )aÖ  Align `lhs` to the Index of `rhs`, if they're both pandas-like.

    Arguments:
        lhs: Dataframe or Series.
        rhs: Dataframe or Series to align with.

    Returns:
        Same type as input.

    Notes:
        This is only really intended for backwards-compatibility purposes,
        for example if your library already aligns indices for users.
        If you're designing a new library, we highly encourage you to not
        rely on the Index.
        For non-pandas-like inputs, this only checks that `lhs` and `rhs`
        are the same length.

    Examples:
        >>> import pandas as pd
        >>> import polars as pl
        >>> import narwhals as nw
        >>> df_pd = pd.DataFrame({"a": [1, 2]}, index=[3, 4])
        >>> s_pd = pd.Series([6, 7], index=[4, 3])
        >>> df = nw.from_native(df_pd)
        >>> s = nw.from_native(s_pd, series_only=True)
        >>> nw.to_native(nw.maybe_align_index(df, s))
           a
        4  2
        3  1
    r   )ÚPandasLikeDataFrame)ÚPandasLikeSeriesÚindexr   r‡   rµ   c                 S  s   | j s	d}t|ƒ‚d S )Nz'given index doesn't have a unique index)Ú	is_uniquerû   )r€  r  r   r   r‚   Ú_validate_indexS  s   þz*maybe_align_index.<locals>._validate_indexÚ_compliant_frameNÚ_compliant_seriesz6Expected `lhs` and `rhs` to have the same length, got z and )r€  r   r‡   rµ   )Únarwhals._pandas_like.dataframer~  Únarwhals._pandas_like.seriesr  r   rÿ   Úgetattrrƒ  rŸ   r€  Ú_with_compliantÚ_with_nativeÚlocr„  r8  rû   )r{  r|  r~  r  r‚  Úlhs_anyÚrhs_anyr  r   r   r‚   Úmaybe_align_index/  s~   !


ÿþÿÿÿþÿÿÿÿþÿÿÿÿþÿÿÿr  Úobjú-DataFrame[Any] | LazyFrame[Any] | Series[Any]r†   c                 C  s,   t d| ƒ}| ¡ }t|ƒst|ƒr|jS dS )a¼  Get the index of a DataFrame or a Series, if it's pandas-like.

    Arguments:
        obj: Dataframe or Series.

    Returns:
        Same type as input.

    Notes:
        This is only really intended for backwards-compatibility purposes,
        for example if your library already aligns indices for users.
        If you're designing a new library, we highly encourage you to not
        rely on the Index.
        For non-pandas-like inputs, this returns `None`.

    Examples:
        >>> import pandas as pd
        >>> import polars as pl
        >>> import narwhals as nw
        >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [4, 5]})
        >>> df = nw.from_native(df_pd)
        >>> nw.maybe_get_index(df)
        RangeIndex(start=0, stop=2, step=1)
        >>> series_pd = pd.Series([1, 2])
        >>> series = nw.from_native(series_pd, series_only=True)
        >>> nw.maybe_get_index(series)
        RangeIndex(start=0, stop=2, step=1)
    r   N)r   Ú	to_nativer3   r4   r€  )rŽ  Úobj_anyÚ
native_objr   r   r‚   Úmaybe_get_indexŽ  s
   
r“  )r€  Úcolumn_namesústr | list[str] | Noner€  ú6Series[IntoSeriesT] | list[Series[IntoSeriesT]] | Nonec                  sò   ddl m‰  td| ƒ}| ¡ }|dur|durd}t|ƒ‚|s)|du r)d}t|ƒ‚|durAt|ƒr:‡ fdd„|D ƒnˆ |d	d
}n|}t|ƒrS| |j | 	|¡¡¡S t
|ƒrwddlm	} |red}t|ƒ‚|||| jjd}| |j |¡¡S |S )aÙ  Set the index of a DataFrame or a Series, if it's pandas-like.

    Arguments:
        obj: object for which maybe set the index (can be either a Narwhals `DataFrame`
            or `Series`).
        column_names: name or list of names of the columns to set as index.
            For dataframes, only one of `column_names` and `index` can be specified but
            not both. If `column_names` is passed and `df` is a Series, then a
            `ValueError` is raised.
        index: series or list of series to set as index.

    Returns:
        Same type as input.

    Raises:
        ValueError: If one of the following conditions happens

            - none of `column_names` and `index` are provided
            - both `column_names` and `index` are provided
            - `column_names` is provided and `df` is a Series

    Notes:
        This is only really intended for backwards-compatibility purposes, for example if
        your library already aligns indices for users.
        If you're designing a new library, we highly encourage you to not
        rely on the Index.

        For non-pandas-like inputs, this is a no-op.

    Examples:
        >>> import pandas as pd
        >>> import polars as pl
        >>> import narwhals as nw
        >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [4, 5]})
        >>> df = nw.from_native(df_pd)
        >>> nw.to_native(nw.maybe_set_index(df, "b"))  # doctest: +NORMALIZE_WHITESPACE
           a
        b
        4  1
        5  2
    r   ©r  r   Nz8Only one of `column_names` or `index` should be providedz3Either `column_names` or `index` should be providedc                   s   g | ]}ˆ |d d‘qS )T©Úpass_throughr   )rJ  Úidxr—  r   r‚   rx  ð  ó    z#maybe_set_index.<locals>.<listcomp>Tr˜  )Ú	set_indexz/Cannot set index using column names on a Series)r.  )Únarwhals.translater  r   rû   r9  r3   rˆ  rƒ  r‰  rœ  r4   Únarwhals._pandas_like.utilsr„  r¯   )rŽ  r”  r€  Údf_anyr’  r  Úkeysrœ  r   r—  r‚   Úmaybe_set_index²  s>   /
ÿ
ýÿýr¡  c                 C  s†   t d| ƒ}| ¡ }t|ƒr%| ¡ }t||ƒr|S | |j |jdd¡¡S t	|ƒrA| ¡ }t||ƒr4|S | |j
 |jdd¡¡S |S )aý  Reset the index to the default integer index of a DataFrame or a Series, if it's pandas-like.

    Arguments:
        obj: Dataframe or Series.

    Returns:
        Same type as input.

    Notes:
        This is only really intended for backwards-compatibility purposes,
        for example if your library already resets the index for users.
        If you're designing a new library, we highly encourage you to not
        rely on the Index.
        For non-pandas-like inputs, this is a no-op.

    Examples:
        >>> import pandas as pd
        >>> import polars as pl
        >>> import narwhals as nw
        >>> df_pd = pd.DataFrame({"a": [1, 2], "b": [4, 5]}, index=([6, 7]))
        >>> df = nw.from_native(df_pd)
        >>> nw.to_native(nw.maybe_reset_index(df))
           a  b
        0  1  4
        1  2  5
        >>> series_pd = pd.Series([1, 2])
        >>> series = nw.from_native(series_pd, series_only=True)
        >>> nw.maybe_get_index(series)
        RangeIndex(start=0, stop=2, step=1)
    r   T)Údrop)r   r  r3   Ú__native_namespace__Ú_has_default_indexrˆ  rƒ  r‰  Úreset_indexr4   r„  )rŽ  r‘  r’  rê   r   r   r‚   Úmaybe_reset_index  s"   

ÿ
ÿr¦  )Ústrict)r  r!  Ú	iterablesúIterable[tuple[Any, ...]]c                    st   t | ƒdk r
t| Ž S d‰ d	‡ fdd„}d	‡ ‡fdd„}t| ƒ}tt|ƒ|ƒ ƒ}ttt|ƒƒ‰tt|gˆ¢R Ž |ƒ ƒS )
Nr  Fr‡   r   c                   3  s
    d‰ d S )NTr   r   )Úfirst_stoppedr   r‚   Ú
first_tailN  s   €zzip_strict.<locals>.first_tailc                  3  s0    ˆ s	d} t | ƒ‚t ˆ¡D ]}d} t | ƒ‚d S )Nz$zip_strict: first iterable is longerz%zip_strict: first iterable is shorter)rû   r   Úfrom_iterable)r  r¶   ©rª  Úrestr   r‚   Úzip_tailU  s   €þzzip_strict.<locals>.zip_tail)r‡   r   )r8  ÚzipÚiterr   Únextr7  Úmap)r¨  r«  r¯  Úiterables_itÚfirstr   r­  r‚   Ú
zip_strictG  s   
r¶  rê   úTypeIs[pd.RangeIndex]c                 C  s   t | |jƒS r‰   )rÿ   Ú
RangeIndex)rŽ  rê   r   r   r‚   Ú_is_range_indexe  s   r¹  Únative_frame_or_seriesúpd.Series[Any] | pd.DataFramec                 C  s2   | j }t||ƒo|jdko|jt|ƒko|jdkS )Nr   r  )r€  r¹  ÚstartÚstopr8  Ústep)rº  rê   r€  r   r   r‚   r¤  i  s   
ÿþür¤  Úkwargsú
bool | strc                 O  sb   t d| ƒ}| ¡ }t|ƒr| |j |j|i |¤Ž¡¡S t|ƒr/| |j |j|i |¤Ž¡¡S |S )aW  Convert columns or series to the best possible dtypes using dtypes supporting ``pd.NA``, if df is pandas-like.

    Arguments:
        obj: DataFrame or Series.
        *args: Additional arguments which gets passed through.
        **kwargs: Additional arguments which gets passed through.

    Returns:
        Same type as input.

    Notes:
        For non-pandas-like inputs, this is a no-op.
        Also, `args` and `kwargs` just get passed down to the underlying library as-is.

    Examples:
        >>> import pandas as pd
        >>> import polars as pl
        >>> import narwhals as nw
        >>> import numpy as np
        >>> df_pd = pd.DataFrame(
        ...     {
        ...         "a": pd.Series([1, 2, 3], dtype=np.dtype("int32")),
        ...         "b": pd.Series([True, False, np.nan], dtype=np.dtype("O")),
        ...     }
        ... )
        >>> df = nw.from_native(df_pd)
        >>> nw.to_native(
        ...     nw.maybe_convert_dtypes(df)
        ... ).dtypes  # doctest: +NORMALIZE_WHITESPACE
        a             Int32
        b           boolean
        dtype: object
    r   )	r   r  r3   rˆ  rƒ  r‰  Úconvert_dtypesr4   r„  )rŽ  r5  r¿  r‘  r’  r   r   r‚   Úmaybe_convert_dtypesu  s   
$ÿÿÿÿrÂ  ÚszrG  Úunitrb   úint | floatc                 C  s^   |dv r| S |dv r| d S |dv r| d S |dv r| d S |dv r&| d	 S d
|›}t |ƒ‚)zÍScale size in bytes to other size units (eg: "kb", "mb", "gb", "tb").

    Arguments:
        sz: original size in bytes
        unit: size unit to convert into

    Returns:
        Integer or float.
    >   ÚbrB  >   ÚkbÚ	kilobytesi   >   ÚmbÚ	megabytesi   >   ÚgbÚ	gigabytesi   @>   ÚtbÚ	terabytesl        z9`unit` must be one of {'b', 'kb', 'mb', 'gb', 'tb'}, got ©rû   )rÃ  rÄ  r  r   r   r‚   Úscale_bytesª  s   

rÐ  rØ   úSeries[Any]c                 C  sê   ddl m} | jjj}| j}d}t||ƒr$t| j|jƒr$|jj	d }|S | j|j
kr.d}|S | j|jkr8d}|S |  ¡ }| j}| ¡ rT| ¡ dk rTtd|jƒjdk}|S | ¡ r`t|jjƒ}|S | ¡ rsdd	lm} ||jƒor|jj}|S )
a  Return whether indices of categories are semantically meaningful.

    This is a convenience function to accessing what would otherwise be
    the `is_ordered` property from the DataFrame Interchange Protocol,
    see https://data-apis.org/dataframe-protocol/latest/API.html.

    - For Polars:
      - Enums are always ordered.
      - Categoricals are ordered if `dtype.ordering == "physical"`.
    - For pandas-like APIs:
      - Categoricals are ordered if `dtype.cat.ordered == True`.
    - For PyArrow table:
      - Categoricals are ordered if `dtype.type.ordered == True`.

    Arguments:
        series: Input Series.

    Returns:
        Whether the Series is an ordered categorical.

    Examples:
        >>> import narwhals as nw
        >>> import pandas as pd
        >>> import polars as pl
        >>> data = ["x", "y"]
        >>> s_pd = pd.Series(data, dtype=pd.CategoricalDtype(ordered=True))
        >>> s_pl = pl.Series(data, dtype=pl.Categorical(ordering="lexical"))

        Let's define a library-agnostic function:

        >>> @nw.narwhalify
        ... def func(s):
        ...     return nw.is_ordered_categorical(s)

        Then, we can pass any supported library to `func`:

        >>> func(s_pd)
        True
        >>> func(s_pl)
        False
    r   )ÚInterchangeSeriesFÚ
is_orderedT)r  é    zpl.CategoricalÚphysical)Úis_dictionary)Únarwhals._interchange.seriesrÒ  r„  r«   rÃ   rÿ   ÚdtypeÚCategoricalrŸ   Údescribe_categoricalr
   r  r.  r  r§   r   Úorderingr  r  ÚcatÚorderedr  Únarwhals._arrow.utilsrÖ  rQ  )rØ   rÒ  rÃ   r¤   ÚresultrŸ   r1  rÖ  r   r   r‚   Úis_ordered_categoricalÂ  s6   *
ÿîðóúürà  Ún_bytesr   úContainer[str]c                 C  s   d}t |dd t| |dS )Nz}Use `generate_temporary_column_name` instead. `generate_unique_token` is deprecated and it will be removed in future versionsz1.13.0©r«   )rá  r   )r!   Úgenerate_temporary_column_name)rá  r   r  r   r   r‚   Úgenerate_unique_token  s   ÿrå  c                 C  sN   d}	 dt | d ƒ› }||vr|S |d7 }|dkr&d| ›d|› }t|ƒ‚q)aù  Generates a unique column name that is not present in the given list of columns.

    It relies on [python secrets token_hex](https://docs.python.org/3/library/secrets.html#secrets.token_hex)
    function to return a string nbytes random bytes.

    Arguments:
        n_bytes: The number of bytes to generate for the token.
        columns: The list of columns to check for uniqueness.

    Returns:
        A unique token that is not present in the given list of columns.

    Raises:
        AssertionError: If a unique token cannot be generated after 100 attempts.

    Examples:
        >>> import narwhals as nw
        >>> columns = ["abc", "xyz"]
        >>> nw.generate_temporary_column_name(n_bytes=8, columns=columns) not in columns
        True
    r   TÚnwr  éd   zMInternal Error: Narwhals was not able to generate a column name with n_bytes=z and not in )r   r  )rá  r   ÚcounterÚtokenr  r   r   r‚   rä    s   ÿÿÿórä  ÚframeÚsubsetúIterable[str]r§  ú	list[str]c               C  s:   |st t| jƒ |¡ƒS t |ƒ}t|| jd }r|‚|S )N)Ú	available)r7  Úsetr   ÚintersectionÚcheck_columns_exist)rê  rë  r§  Úto_dropÚerrorr   r   r‚   Úparse_columns_to_drop=  s   rô  ÚsequenceúSequence[_T] | AnyúTypeIs[Sequence[_T]]c                 C  s   t | tƒo
t | tƒ S r‰   )rÿ   r   rz   )rõ  r   r   r‚   Úis_sequence_but_not_strH  ó   rø  úTypeIs[_SliceNone]c                 C  s   t | tƒo
| td ƒkS r‰   )rÿ   Úslice©rŽ  r   r   r‚   Úis_slice_noneL  rù  rý  úCTypeIs[SizedMultiIndexSelector[Series[Any] | CompliantSeries[Any]]]c                 C  sF   t | ƒot| ƒdkrt| d tƒpt| ƒdkp"t| ƒp"t| ƒp"t| ƒS ©Nr   )rø  r8  rÿ   rG  r2   r0   Úis_compliant_series_intrü  r   r   r‚   Úis_sized_multi_index_selectorP  s   $þüûùr  ú-TypeIs[Sequence[_T] | Series[Any] | _1DArray]c                 C  s    t | ƒpt| ƒpt| ƒpt| ƒS r‰   )rø  r1   r/   Úis_compliant_seriesrü  r   r   r‚   Úis_sequence_like^  s   ÿþür  úTypeIs[_SliceIndex]c                 C  sB   t | tƒo t | jtƒp t | jtƒp t | jtƒo | jd u o | jd u S r‰   )rÿ   rû  r¼  rG  r½  r¾  rü  r   r   r‚   Úis_slice_indexi  s   

ÿýr  úTypeIs[range]c                 C  s
   t | tƒS r‰   )rÿ   Úrangerü  r   r   r‚   Úis_rangeq  rç   r	  úTypeIs[SingleIndexSelector]c                 C  s   t t| tƒot| t ƒ ƒS r‰   )r  rÿ   rG  rü  r   r   r‚   Úis_single_index_selectoru  s   r  úTTypeIs[SingleIndexSelector | MultiIndexSelector[Series[Any] | CompliantSeries[Any]]]c                 C  s   t | ƒpt| ƒpt| ƒS r‰   )r  r  r  rü  r   r   r‚   Úis_index_selectory  s
   ÿýr  ÚtpúTypeIs[list[_T]]c                 C  s    t t| tƒo| ot| d |ƒƒS rÿ  )r  rÿ   r7  )rŽ  r  r   r   r‚   Ú
is_list_ofƒ  s    r  c                 C  s(   t t| ƒott| ƒd ƒ }ot||ƒƒS r‰   )r  rø  r²  r±  rÿ   )rŽ  r  rµ  r   r   r‚   Úis_sequence_ofˆ  s   ÿýr  úbool | Noner™  Úpass_through_defaultc                C  sT   | d u r|d u r|}|S | d ur|d u r|  }|S | d u r$|d ur$	 |S d}t |ƒ‚)Nz,Cannot pass both `strict` and `pass_through`rÏ  )r§  r™  r  r  r   r   r‚   Úvalidate_strict_and_pass_though‘  s   ùûþr  rF  F)Úwarn_versionÚrequiredr  r  ú*Callable[[Callable[P, R]], Callable[P, R]]c                   s   d‡ ‡fdd„}|S )a8  Decorator to transition from `native_namespace` to `backend` argument.

    Arguments:
        warn_version: Emit a deprecation warning from this version.
        required: Raise when both `native_namespace`, `backend` are `None`.

    Returns:
        Wrapped function, with `native_namespace` **removed**.
    ÚfnúCallable[P, R]r‡   c                  s   t ˆ ƒd	‡ ‡‡fdd„ƒ}|S )
Nr5  úP.argsÚkwdsúP.kwargsr‡   ru   c                    sž   |  dd ¡}|  dd ¡}|d ur!|d u r!ˆrd}t|ˆd |}n#|d ur/|d ur/d}t|ƒ‚|d u rD|d u rDˆrDdˆ j› d}t|ƒ‚||d< ˆ | i |¤ŽS )Nrý   rê   z×`native_namespace` is deprecated, please use `backend` instead.

Note: `native_namespace` will remain available in `narwhals.stable.v1`.
See https://narwhals-dev.github.io/narwhals/backcompat/ for more information.
rã  z0Can't pass both `native_namespace` and `backend`z `backend` must be specified in `z`.)Úpopr!   rû   r}   )r5  r  rý   rê   r  )r  r  r  r   r‚   Úwrapper±  s    ÿz=deprecate_native_namespace.<locals>.decorate.<locals>.wrapper)r5  r  r  r  r‡   ru   )r   )r  r  ©r  r  ©r  r‚   Údecorate°  s   z,deprecate_native_namespace.<locals>.decorateN)r  r  r‡   r  r   )r  r  r!  r   r  r‚   Údeprecate_native_namespace£  s   r"  Úwindow_sizeÚmin_samplesú
int | Noneútuple[int, int]c                 C  sz   t | tdd t |ttd ƒdd | dk rd}t|ƒ‚|d ur7|dk r)d}t|ƒ‚|| kr3d}t|ƒ‚| |fS | }| |fS )Nr#  ©Ú
param_namer$  r  z+window_size must be greater or equal than 1z+min_samples must be greater or equal than 1z6`min_samples` must be less or equal than `window_size`)Úensure_typerG  rQ  rû   r7   )r#  r$  r  r   r   r‚   Ú_validate_rolling_argumentsÌ  s   þr*  ÚheaderÚnative_reprc              	   C  s€  zt  ¡ j}W n ty   tt  dd¡ƒ}Y nw | ¡  ¡ }tdd„ |D ƒƒ}|d |kržt|t	| ƒƒ}dd| › d}|t	| ƒ }|d	d
|d  › | › d
|d |d   › d7 }|d	d| › d7 }|| d }|| d || d  }	|D ]}
|d	d
| › |
› d
|	| t	|
ƒ  › d7 }qy|dd| › d7 }|S dt	| ƒ }dd› dd
|d  › | › d
|d |d   › dd› d	S )NÚCOLUMNSéP   c                 s  ó    | ]}t |ƒV  qd S r‰   )r8  )rJ  Úliner   r   r‚   rL  ê  ó   € z generate_repr.<locals>.<genexpr>r  u   â”Œu   â”€u   â”
ú|ú z|
ú-u   â””u   â”˜é'   uu   â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€u   â”
|u/   |
| Use `.to_native` to see native output |
â””)
ÚosÚget_terminal_sizer   ÚOSErrorrG  ÚgetenvÚ
expandtabsÚ
splitlinesÚmaxr8  )r+  r,  Úterminal_widthÚnative_linesÚmax_native_widthÚlengthÚoutputÚheader_extraÚstart_extraÚ	end_extrar0  Údiffr   r   r‚   Úgenerate_reprä  s<   ÿ0.
ÿÿÿýÿrF  úCollection[str]rî  úColumnNotFoundError | Nonec               C  s"   t | ƒ |¡ }rt ||¡S d S r‰   )rï  Ú
differencer5   Ú'from_missing_and_available_column_names)rë  rî  Úmissingr   r   r‚   rñ    s
   ÿrñ  c                 C  sh   t | ƒt t| ƒƒkr2ddlm} || ƒ}dd„ | ¡ D ƒ}d dd„ | ¡ D ƒ¡}d|› }t|ƒ‚d S )	Nr   )ÚCounterc                 S  s   i | ]\}}|d kr||“qS r&  r   ©rJ  ÚkrK  r   r   r‚   Ú
<dictcomp>  s    z1check_column_names_are_unique.<locals>.<dictcomp>rF  c                 s  s&    | ]\}}d |› d|› dV  qdS )z
- 'z' z timesNr   rM  r   r   r‚   rL    s   €$ z0check_column_names_are_unique.<locals>.<genexpr>z"Expected unique column names, got:)r8  rï  ÚcollectionsrL  rq  Újoinr6   )r   rL  rè  Ú
duplicatesr  r   r   r‚   Úcheck_column_names_are_unique  s   
ùrS  Ú	time_unitú$TimeUnit | Iterable[TimeUnit] | NoneÚ	time_zoneú7str | timezone | Iterable[str | timezone | None] | Noneú%tuple[Set[TimeUnit], Set[str | None]]c                 C  sd   | d u rh d£nt | tƒr| hnt| ƒ}|d u rd hnt |ttfƒr't|ƒhndd„ |D ƒ}||fS )N>   ÚsÚmsÚnsÚusc                 S  s    h | ]}|d urt |ƒnd ’qS r‰   )rz   )rJ  Útzr   r   r‚   Ú	<setcomp>'  s     z1_parse_time_unit_and_time_zone.<locals>.<setcomp>)rÿ   rz   rï  r	   )rT  rV  Ú
time_unitsÚ
time_zonesr   r   r‚   Ú_parse_time_unit_and_time_zone  s   ÿÿû	ÿÿûra  rØ  rW   rÃ   r]   r_  úSet[TimeUnit]r`  úSet[str | None]c                 C  s2   t | |jƒo| j|v o| j|v pd|v o| jd uS )NÚ*)rÿ   ÚDatetimerT  rV  )rØ  rÃ   r_  r`  r   r   r‚   Ú%dtype_matches_time_unit_and_time_zone,  s   ÿ
ûrf  rŽ   c                C  s   | j S r‰   ©r   )rê  r   r   r‚   Úget_column_names9  s   rh  Únamesc                   s   ‡ fdd„| j D ƒS )Nc                   s   g | ]}|ˆ vr|‘qS r   r   )rJ  Úcol_name©ri  r   r‚   rx  >  r›  z(exclude_column_names.<locals>.<listcomp>rg  )rê  ri  r   rk  r‚   Úexclude_column_names=  s   rl  úEvalNames[Any]c                  s   d‡ fdd„}|S )NÚ_framer   r‡   rŽ   c                  s   ˆ S r‰   r   )rn  rk  r   r‚   r  B  r‘   z$passthrough_column_names.<locals>.fn)rn  r   r‡   rŽ   r   )ri  r  r   rk  r‚   Úpassthrough_column_namesA  s   ro  Úattrc                 C  s   t ƒ }t| ||ƒ|uS r‰   )Úobjectr   )rŽ  rp  Úsentinelr   r   r‚   Ú_hasattr_staticH  s   rs  ú[CompliantDataFrame[CompliantSeriesT, CompliantExprT, NativeFrameT_co, ToNarwhalsT_co] | Anyú]TypeIs[CompliantDataFrame[CompliantSeriesT, CompliantExprT, NativeFrameT_co, ToNarwhalsT_co]]c                 C  ó
   t | dƒS )NÚ__narwhals_dataframe__©rs  rü  r   r   r‚   Úis_compliant_dataframeM  s   
ry  úJCompliantLazyFrame[CompliantExprT, NativeLazyFrameT, ToNarwhalsT_co] | AnyúLTypeIs[CompliantLazyFrame[CompliantExprT, NativeLazyFrameT, ToNarwhalsT_co]]c                 C  rv  )NÚ__narwhals_lazyframe__rx  rü  r   r   r‚   Úis_compliant_lazyframeX  ó   
r}  ú'CompliantSeries[NativeSeriesT_co] | Anyú)TypeIs[CompliantSeries[NativeSeriesT_co]]c                 C  rv  )NÚ__narwhals_series__rx  rü  r   r   r‚   r  ^  r~  r  c                 C  s   t | ƒo| j ¡ S r‰   )r  rØ  Ú
is_integerrü  r   r   r‚   r   d  s   r   úECompliantExpr[CompliantFrameT, CompliantSeriesOrNativeExprT_co] | AnyúGTypeIs[CompliantExpr[CompliantFrameT, CompliantSeriesOrNativeExprT_co]]c                 C  rv  )NÚ__narwhals_expr__)Úhasattrrü  r   r   r‚   Úis_compliant_exprj  r~  r‡  r1  úTypeIs[_EagerAllowedImpl]c                C  s   | t jt jt jt jt jhv S )z.Return True if `impl` allows eager operations.)r®   rë   rì   rí   rð   rî   ©r1  r   r   r‚   Úis_eager_allowedp  s   ûrŠ  úTypeIs[_LazyFrameCollectImpl]c                C  r  )z4Return True if `LazyFrame.collect(impl)` is allowed.)r®   rë   rð   rî   r‰  r   r   r‚   Úcan_lazyframe_collect{  ó   rŒ  úTypeIs[_DataFrameLazyImpl]c                C  s   | t jt jt jt jhv S )z1Return True if `DataFrame.lazy(impl)` is allowed.)r®   rñ   rò   rð   ró   r‰  r   r   r‚   Úcan_dataframe_lazy€  s   ür  úTypeIs[SupportsNativeNamespace]c                 C  rv  )Nr£  rx  rü  r   r   r‚   Úhas_native_namespaceŠ  rç   r‘  úTypeIs[ArrowStreamExportable]c                 C  rv  )NÚ__arrow_c_stream__rx  rü  r   r   r‚   Úsupports_arrow_c_streamŽ  rç   r”  Úleft_onÚright_onÚsuffixúdict[str, str]c                   s"   ‡ ‡fdd„|D ƒ}t t||ƒƒS )aO  Remap join keys to avoid collisions.

    If left keys collide with the right keys, append the suffix.
    If there's no collision, let the right keys be.

    Arguments:
        left_on: Left keys.
        right_on: Right keys.
        suffix: Suffix to append to right keys.

    Returns:
        A map of old to new right keys.
    c                 3  s(    | ]}|ˆ v r|› ˆ› n|V  qd S r‰   r   )rJ  Úkey©r•  r—  r   r‚   rL  ¢  s   € 
ÿz(_remap_full_join_keys.<locals>.<genexpr>)Údictr°  )r•  r–  r—  Úright_keys_suffixedr   rš  r‚   Ú_remap_full_join_keys’  s   ÿr  ÚdatarL   Úcontextúpa.Tablec                C  sB   t dƒr|jj d¡j}|jj| |djS dt| ƒ›d}t	|ƒ‚)zÛGuards `ArrowDataFrame.from_arrow` w/ safer imports.

    Arguments:
        data: Object which implements `__arrow_c_stream__`.
        context: Initialized compliant object.

    Returns:
        A PyArrow Table.
    rÝ   )rŸ  zB'pyarrow>=14.0.0' is required for `from_arrow` for object of type rM  )
r   r«   rÁ   r   r¤   Ú
_dataframeÚ
from_arrowrŸ   r@  ÚModuleNotFoundError)rž  rŸ  r[  r  r   r   r‚   Ú_into_arrow_table¨  s
   
r¤  r  c                C  s   | S )aã  Visual-only marker for unstable functionality.

    Arguments:
        fn: Function to decorate.

    Returns:
        Decorated function (unchanged).

    Examples:
        >>> from narwhals._utils import unstable
        >>> @unstable
        ... def a_work_in_progress_feature(*args):
        ...     return args
        >>>
        >>> a_work_in_progress_feature.__name__
        'a_work_in_progress_feature'
        >>> a_work_in_progress_feature(1, 2, 3)
        (1, 2, 3)
    r   r   r   r   r‚   Úunstable»  s   r¥  Úformatc                   s   t ‡ fdd„dD ƒƒ S )a¹  Determines if a datetime format string is 'naive', i.e., does not include timezone information.

    A format is considered naive if it does not contain any of the following

    - '%s': Unix timestamp
    - '%z': UTC offset
    - 'Z' : UTC timezone designator

    Arguments:
        format: The datetime format string to check.

    Returns:
        bool: True if the format is naive (does not include timezone info), False otherwise.
    c                 3  s    | ]}|ˆ v V  qd S r‰   r   )rJ  Úx©r¦  r   r‚   rL  á  r1  z#_is_naive_format.<locals>.<genexpr>)z%sz%zÚZ)Úanyr¨  r   r¨  r‚   Ú_is_naive_formatÒ  s   r«  c                   @  sV   e Zd ZdZd d!dd„Zd"d
d„Zd#dd„Z	d d$dd„Zd%dd„Ze	d&dd„ƒZ
dS )'Únot_implementeda¾  Mark some functionality as unsupported.

    Arguments:
        alias: optional name used instead of the data model hook [`__set_name__`].

    Returns:
        An exception-raising [descriptor].

    Notes:
        - Attribute/method name *doesn't* need to be declared twice
        - Allows different behavior when looked up on the class vs instance
        - Allows us to use `isinstance(...)` instead of monkeypatching an attribute to the function

    Examples:
        >>> from narwhals._utils import not_implemented
        >>> class Thing:
        ...     def totally_ready(self) -> str:
        ...         return "I'm ready!"
        ...
        ...     not_ready_yet = not_implemented()
        >>>
        >>> thing = Thing()
        >>> thing.totally_ready()
        "I'm ready!"
        >>> thing.not_ready_yet()
        Traceback (most recent call last):
            ...
        NotImplementedError: 'not_ready_yet' is not implemented for: 'Thing'.
        ...
        >>> isinstance(Thing.not_ready_yet, not_implemented)
        True

    [`__set_name__`]: https://docs.python.org/3/reference/datamodel.html#object.__set_name__
    [descriptor]: https://docs.python.org/3/howto/descriptor.html
    NÚaliasú
str | Noner‡   rµ   c                C  ó
   || _ d S r‰   )Ú_alias)rŠ   r­  r   r   r‚   Ú__init__	  r~  znot_implemented.__init__rz   c                 C  s    dt | ƒj› d| j› d| j› S )Nú<z>: rM  )rQ  r}   Ú_name_ownerÚ_namer   r   r   r‚   Ú__repr__  s    znot_implemented.__repr__r…   rS  Únamec                 C  s   |j | _| jp|| _d S r‰   )r}   r³  r°  r´  )rŠ   r…   r¶  r   r   r‚   Ú__set_name__  s   znot_implemented.__set_name__r„   ú_T | Literal['raise'] | Noneútype[_T] | Noner   c                C  s*   |d u r| S t |d| jƒ}t| j|ƒ d S )Nr¯   )r‡  r³  Ú_raise_not_implemented_errorr´  )rŠ   r„   r…   Úwhor   r   r‚   r‹     s
   znot_implemented.__get__r5  r  c                 O  s
   |   d¡S )NÚraise)r‹   )rŠ   r5  r  r   r   r‚   Ú__call__$  r~  znot_implemented.__call__Úmessager;   r=   c                C  s   | ƒ }t |ƒ|ƒS )zÛAlt constructor, wraps with `@deprecated`.

        Arguments:
            message: **Static-only** deprecation message, emitted in an IDE.

        [descriptor]: https://docs.python.org/3/howto/descriptor.html
        )r#   )rè   r¾  rŽ  r   r   r‚   r#   )  s   	znot_implemented.deprecatedr‰   )r­  r®  r‡   rµ   r  )r…   rS  r¶  rz   r‡   rµ   )r„   r¸  r…   r¹  r‡   r   )r5  r   r  r   r‡   r   )r¾  r;   r‡   r=   )r}   r~   r   r¡   r±  rµ  r·  r‹   r½  r  r#   r   r   r   r‚   r¬  ä  s    $

ÿ
r¬  Úwhatr»  ÚNotImplementedErrorc                C  s   | ›d|›d}t |ƒ‚)Nz is not implemented for: z†.

If you would like to see this functionality in `narwhals`, please open an issue at: https://github.com/narwhals-dev/narwhals/issues)rÀ  )r¿  r»  r  r   r   r‚   rº  6  s   ÿrº  c                   @  sT   e Zd ZU dZded< ded< edddd„ƒZeddd„ƒZddd„Z	ddd„Z
dS )Úrequiresa#  Method decorator for raising under certain constraints.

    Attributes:
        _min_version: Minimum backend version.
        _hint: Optional suggested alternative.

    Examples:
        >>> from narwhals._utils import requires, Implementation
        >>> class SomeBackend:
        ...     _implementation = Implementation.PYARROW
        ...     _backend_version = 20, 0, 0
        ...
        ...     @requires.backend_version((9000, 0, 0))
        ...     def really_complex_feature(self) -> str:
        ...         return "hello"
        >>> backend = SomeBackend()
        >>> backend.really_complex_feature()
        Traceback (most recent call last):
            ...
        NotImplementedError: `really_complex_feature` is only available in 'pyarrow>=9000.0.0', found version '20.0.0'.
    r¦   Ú_min_versionrz   Ú_hintrF  ÚhintÚminimumr‡   r=   c                C  s   |   | ¡}||_||_|S )z½Method decorator for raising below a minimum `_backend_version`.

        Arguments:
            minimum: Minimum backend version.
            hint: Optional suggested alternative.
        )Ú__new__rÂ  rÃ  )rè   rÅ  rÄ  rŽ  r   r   r‚   r  Y  s   
zrequires.backend_versionr  c                C  s   d  dd„ | D ƒ¡S )NrM  c                 s  s    | ]}|› V  qd S r‰   r   )rJ  Údr   r   r‚   rL  h  s   € z,requires._unparse_version.<locals>.<genexpr>)rQ  r  r   r   r‚   Ú_unparse_versionf  r  zrequires._unparse_versionr„   r™   rµ   c             	   C  sp   |j | jkrd S | j}|j}|  | j¡}|  |j ¡}d|› d|› d|› d|›d	}| jr4|› d| j› }t|ƒ‚)Nú`z` is only available in 'z>=z', found version rM  Ú
)r§   rÂ  Ú_wrapped_namer¯   rÈ  rÃ  rÀ  )rŠ   r„   Úmethodrý   rÅ  Úfoundr  r   r   r‚   Ú_ensure_versionj  s   zrequires._ensure_versionr  ú_Method[_ContextT, P, R]c                  s$   ˆ j ˆ_tˆ ƒd‡ ‡fd	d
„ƒ}|S )Nr„   r˜   r5  r  r  r  r‡   ru   c                   s    ˆ  | ¡ ˆ | g|¢R i |¤ŽS r‰   )rÎ  )r„   r5  r  ©r  rŠ   r   r‚   r  y  s   
z"requires.__call__.<locals>.wrapper)r„   r˜   r5  r  r  r  r‡   ru   )r}   rË  r   )rŠ   r  r  r   rÐ  r‚   r½  v  s   zrequires.__call__N)rF  )rÄ  rz   rÅ  r¦   r‡   r=   )r  r¦   r‡   rz   )r„   r™   r‡   rµ   )r  rÏ  r‡   rÏ  )r}   r~   r   r¡   r€   r  r  ÚstaticmethodrÈ  rÎ  r½  r   r   r   r‚   rÁ  ?  s   
 
rÁ  Ú	str_slicerg   ú"tuple[int | None, int | None, Any]c                 C  sH   | j d ur| | j ¡nd }| jd ur| | j¡d nd }| j}|||fS )Nr  )r¼  r€  r½  r¾  )rÒ  r   r¼  r½  r¾  r   r   r‚   Úconvert_str_slice_to_int_slice‚  s   
rÔ  Ú	tp_parentúCallable[P, R1]ú<Callable[[_Constructor[_T, P, R2]], _Constructor[_T, P, R2]]c                  s   d‡ fdd„}|S )zÍSteal the class-level docstring from parent and attach to child `__init__`.

    Returns:
        Decorated constructor.

    Notes:
        - Passes static typing (mostly)
        - Passes at runtime
    Ú
init_childú_Constructor[_T, P, R2]r‡   c                  sH   | j dkrttˆ ƒtƒrtˆ ƒ| _| S dtj › d| j›dˆ ›}t|ƒ‚)Nr±  z`@zL` is only allowed to decorate an `__init__` with a class-level doc.
Method: z	
Parent: )r}   rp  rQ  r   r¡   Úinherit_docr   rA  )rØ  r  ©rÕ  r   r‚   r!  ˜  s   

ÿþÿzinherit_doc.<locals>.decorateN)rØ  rÙ  r‡   rÙ  r   )rÕ  r!  r   rÛ  r‚   rÚ  ‹  s   rÚ  úobject | type[Any]c                C  s@   t | tƒr| nt| ƒ}|jdkr|jnd}|› d|j›  d¡S )NÚbuiltinsrF  rM  )rÿ   rQ  r~   r}   Úlstrip)rŽ  r  Úmoduler   r   r‚   r@  ¦  s   r@  r'  Úvalid_typesú	type[Any]r(  c         	      G  s¦   t | |ƒsQd dd„ |D ƒ¡}d|›dt| ƒ›}|rMd}t| ƒ}t|ƒdkr.t| ƒ› d}|› |› d	}d
t|ƒ dt|ƒ  }|› d|› |› d|› }t|ƒ‚dS )aÙ  Validate that an object is an instance of one or more specified types.

    Parameters:
        obj: The object to validate.
        *valid_types: One or more valid types that `obj` is expected to match.
        param_name: The name of the parameter being validated.
            Used to improve error message clarity.

    Raises:
        TypeError: If `obj` is not an instance of any of the provided `valid_types`.

    Examples:
        >>> from narwhals._utils import ensure_type
        >>> ensure_type(42, int, float)
        >>> ensure_type("hello", str)

        >>> ensure_type("hello", int, param_name="test")
        Traceback (most recent call last):
            ...
        TypeError: Expected 'int', got: 'str'
            test='hello'
                 ^^^^^^^
        >>> import polars as pl
        >>> import pandas as pd
        >>> df = pl.DataFrame([[1], [2], [3], [4], [5]], schema=[*"abcde"])
        >>> ensure_type(df, pd.DataFrame, param_name="df")
        Traceback (most recent call last):
            ...
        TypeError: Expected 'pandas.core.frame.DataFrame', got: 'polars.dataframe.frame.DataFrame'
            df=polars.dataframe.frame.DataFrame(...)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    z | c                 s  r/  r‰   )r@  )rJ  r  r   r   r‚   rL  Î  r1  zensure_type.<locals>.<genexpr>z	Expected z, got: z    é(   z(...)ú=r3  ú^rÊ  N)rÿ   rQ  r@  Úreprr8  rA  )	rŽ  r(  rà  Útp_namesr  Úleft_padÚvalÚassignÚ	underliner   r   r‚   r)  ¬  s   
!õr)  c                   @  s.   e Zd ZdZddd„Zdd	d
„Zddd„ZdS )Ú_DeferredIterablezLStore a callable producing an iterable to defer collection until we need it.Ú	into_iterúCallable[[], Iterable[_T]]r‡   rµ   c                C  r¯  r‰   ©Ú
_into_iter)rŠ   rì  r   r   r‚   r±  Þ  rç   z_DeferredIterable.__init__úIterator[_T]c                 c  s    |   ¡ E d H  d S r‰   rî  r   r   r   r‚   Ú__iter__á  s   €z_DeferredIterable.__iter__útuple[_T, ...]c                 C  s   |   ¡ }t|tƒr|S t|ƒS r‰   )rï  rÿ   r<  )rŠ   Úitr   r   r‚   Úto_tupleä  s   z_DeferredIterable.to_tupleN)rì  rí  r‡   rµ   )r‡   rð  )r‡   rò  )r}   r~   r   r¡   r±  rñ  rô  r   r   r   r‚   rë  Û  s
    

rë  é@   Únestedúattrgetter[Any]c                 G  s"   |rd  | g|¢R ¡n| }t|ƒS )NrM  )rQ  r   )rp  rö  r¶  r   r   r‚   Údeep_attrgetterê  s   rø  Úname_1c                 G  s   t |g|¢R Ž | ƒS )z+Perform a nested attribute lookup on `obj`.)rø  )rŽ  rù  rö  r   r   r‚   Údeep_getattrð  r  rú  )r  rz   r‡   r9   )r.  r®   r‡   r¦   )r5  r   r‡   r6  )r;  r   r‡   r   )r;  r>  r‡   r  )r3  rE  r‡   r¦   )rP  rQ  rR  rS  r‡   rT  )rP  rW  rR  rS  r‡   rX  )rP  rQ  rR  rY  r‡   rZ  )rP  rW  rR  rY  r‡   r[  )rP  rQ  rR  r\  r‡   r]  )rP  rW  rR  r\  r‡   r^  )rP  rQ  rR  r_  r‡   r`  )rP  rW  rR  r_  r‡   ra  )rP  rQ  rR  rc  r‡   rd  )rP  rW  rR  rc  r‡   re  )rP  rQ  rR  rf  r‡   rg  )rP  rW  rR  rf  r‡   rh  )rP  rQ  rR  rj  r‡   rk  )rP  rW  rR  rj  r‡   rl  )rP  r   rR  rm  r‡   rn  )rP  r   rR  r   r‡   r  )rq  rr  r‡   rµ   )r{  rj   r|  r}  r‡   rj   )rŽ  r  r‡   r†   r‰   )rŽ  rj   r”  r•  r€  r–  r‡   rj   )rŽ  rj   r‡   rj   )r¨  rr  r‡   r©  )rŽ  r   rê   r   r‡   r·  )rº  r»  rê   r   r‡   r  )rŽ  rj   r5  r  r¿  rÀ  r‡   rj   )rÃ  rG  rÄ  rb   r‡   rÅ  )rØ   rÑ  r‡   r  )rá  rG  r   râ  r‡   rz   )rê  r   rë  rì  r§  r  r‡   rí  )rõ  rö  r‡   r÷  )rŽ  r   r‡   rú  )rŽ  r   r‡   rþ  )rŽ  rö  r‡   r  )rŽ  r   r‡   r  )rŽ  r   r‡   r  )rŽ  r   r‡   r
  )rŽ  r   r‡   r  )rŽ  r   r  rS  r‡   r  )rŽ  r   r  rS  r‡   r÷  )r§  r  r™  r  r  r  r‡   r  )r  rz   r  r  r‡   r  )r#  rG  r$  r%  r‡   r&  )r+  rz   r,  rz   r‡   rz   )rë  rG  rî  rG  r‡   rH  )r   rG  r‡   rµ   )rT  rU  rV  rW  r‡   rX  )
rØ  rW   rÃ   r]   r_  rb  r`  rc  r‡   r  )rê  r   r‡   rŽ   )rê  r   ri  râ  r‡   rŽ   )ri  rŽ   r‡   rm  )rŽ  r   rp  rz   r‡   r  )rŽ  rt  r‡   ru  )rŽ  rz  r‡   r{  )rŽ  r  r‡   r€  )rŽ  rƒ  r‡   r„  )r1  r®   r‡   rˆ  )r1  r®   r‡   r‹  )r1  r®   r‡   rŽ  )rŽ  r   r‡   r  )rŽ  r   r‡   r’  )r•  rG  r–  rG  r—  rz   r‡   r˜  )rž  rL   rŸ  r±   r‡   r   )r  rs   r‡   rs   )r¦  rz   r‡   r  )r¿  rz   r»  rz   r‡   rÀ  )rÒ  rg   r   rŽ   r‡   rÓ  )rÕ  rÖ  r‡   r×  )rŽ  rÜ  r‡   rz   )rŽ  r   rà  rá  r(  rz   r‡   rµ   )rp  rz   rö  rz   r‡   r÷  )rŽ  r   rù  rz   rö  rz   r‡   r   )üÚ
__future__r   r6  rH  Úcollections.abcr   r   r   r   r   r   Údatetimer	   Úenumr
   r   Ú	functoolsr   r   r   r   Úimportlib.utilr   Úinspectr   r   Ú	itertoolsr   Úoperatorr   Úsecretsr   Útypingr   r   r   r   r   r   r   r   r   r   Únarwhals._enumr    Únarwhals._exceptionsr!   Únarwhals._typing_compatr"   r#   Únarwhals.dependenciesr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   Únarwhals.exceptionsr5   r6   r7   r8   Útypesr9   rÚ   rC  rß   rD  rÝ   ÚpaÚtyping_extensionsr:   r;   r<   r=   r>   r?   Únarwhals._compliantr@   rA   rB   rC   rD   rE   rF   Únarwhals._compliant.typingrG   rH   r¾   rJ   Únarwhals._translaterK   rL   rM   Únarwhals._typingrN   rO   rP   rQ   rR   rË   rT   rU   ro  rW   rÕ   rY   Únarwhals.typingrZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   rz   ri   r€   rj   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   ry   rƒ   r   r”   r•   r—   r˜   rš   r›   r   r£   r¥   r©   r­   r±   r™   r´   rª   r®   rë   rì   rí   rî   rï   rõ   rð   rñ   rò   ró   rô   r)  r  r  r  r:  r=  r9  r0  rV  rz  r  r“  r¡  r¦  r°  r¶  ÚsysÚversion_infor¹  r¤  rÂ  rÐ  rà  rå  rä  rô  rø  rý  r  r  r  r	  r  r  r  r  r  r"  r*  rF  rñ  rS  ra  rf  rh  rl  ro  rs  ry  r}  r  r   r‡  rŠ  rŒ  r  r‘  r”  r  r¤  r¥  r«  r¬  rº  rÁ  rÔ  rÚ  r@  r)  rë  rø  rú  r   r   r   r‚   Ú<module>   sŒ    0L $		Dÿ	L  õü	
_&þüY25I'
	ÿ)

R	C	/
