a
    vDf                     @  s   d Z ddlmZ ddlZddlmZ ddlmZ edZ	edZ
edZed	Zed
ZedZedZedZedZedZedZedZedZedZedZedZedZedZd#ddZdd Zd$ddZdd Zd%d d!Zd&d"dZ dS )'z4
Dispatch in dask.dataframe.

Also see extension.py
    )annotationsN)is_dask_collection)Dispatchmake_meta_dispatchmake_meta_objmeta_nonemptymeta_lib_from_arrayhash_object_dispatchgroup_split_dispatchget_parallel_typeZCategoricalDtypeconcattolistis_categorical_dtypeunion_categoricalsZgrouperpartd_encode_dispatchpyarrow_schema_dispatchfrom_pyarrow_table_dispatchto_pyarrow_table_dispatchto_pandas_dispatchouterFTc                 K  sF   t | dkr| d S tt| d }|| f|||||d|S dS )a  Concatenate, handling some edge cases:

    - Unions categoricals between partitions
    - Ignores empty partitions

    Parameters
    ----------
    dfs : list of DataFrame, Series, or Index
    axis : int or str, optional
    join : str, optional
    uniform : bool, optional
        Whether to treat ``dfs[0]`` as representative of ``dfs[1:]``. Set to
        True if all arguments have the same columns and dtypes (but not
        necessarily categories). Default is False.
    ignore_index : bool, optional
        Whether to allow index values to be ignored/dropped during
        concatenation. Default is False.
    ignore_order : bool, optional
        Whether to ignore the order when doing the union of categoricals.
        Default is False.
       r   )axisjoinuniformfilter_warningignore_indexN)lenconcat_dispatchdispatchtype)dfsr   r   r   r   r   kwargsfunc r#   d/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/dask/dataframe/dispatch.pyr   "   s    c                 C  s"   t | d| } tt| }|| S )NZdtype)getattris_categorical_dtype_dispatchr   r   objr"   r#   r#   r$   r   O   s    c                 C  s   t t| }|||dS )N)
categoriesordered)categorical_dtype_dispatchr   r   )metar)   r*   r"   r#   r#   r$   categorical_dtypeU   s    r-   c                 C  s   t t| }|| S )N)tolist_dispatchr   r   r'   r#   r#   r$   r   Z   s    c                 C  s   t | tjtjtjfs.t| dr.t| r.| jS zt| |dW S  t	y   |durpt
t|}|| |d Y S t
tj}|| |d Y S Y n0 dS )a  
    This method creates meta-data based on the type of ``x``,
    and ``parent_meta`` if supplied.

    Parameters
    ----------
    x : Object of any type.
        Object to construct meta-data from.
    index :  Index, optional
        Any index to use in the metadata. This is a pass-through
        parameter to dispatches registered.
    parent_meta : Object, default None
        If ``x`` is of arbitrary types and thus Dask cannot determine
        which back-end to be used to generate the meta-data for this
        object type, in which case ``parent_meta`` will be used to
        determine which back-end to select and dispatch to. To use
        utilize this parameter ``make_meta_obj`` has be dispatched.
        If ``parent_meta`` is ``None``, a pandas DataFrame is used for
        ``parent_meta`` that chooses pandas as the backend.

    Returns
    -------
    A valid meta-data
    _meta)indexN)
isinstancepdZSeriesZ	DataFrameIndexhasattrr   r/   r   	TypeErrorr   r   r   )xr0   Zparent_metar"   r#   r#   r$   	make_meta_   s     r7   c                 C  s    t t| d }|| ||dS )Nr   )sort_categoriesignore_order)union_categoricals_dispatchr   r   )Zto_unionr8   r9   r"   r#   r#   r$   r      s    )r   r   FTF)NF)NN)FF)!__doc__
__future__r   Zpandasr2   Zdaskr   Z
dask.utilsr   r   r   r   r   r	   r
   r   r+   r   r.   r&   r:   Zgrouper_dispatchr   r   r   r   r   r   r   r-   r   r7   r   r#   r#   r#   r$   <module>   sB        
-

+