U
    Gvf                     @  s   d dl mZ d dlmZ d dlmZmZ zd dlmZ W n  ek
rX   d dl	mZ Y nX d dl
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d ZeG dd deZdS )    )annotations)	dataclass)ClassVarcast)LiteralN)	DataFrame)Scale)GroupBy)Stat)_version_predates)Zinverted_cdfZaveraged_inverted_cdfZclosest_observationZinterpolated_inverted_cdfZhazenZweibulllinearZmedian_unbiasedZnormal_unbiasedlowerZhigherZmidpointZnearestc                   @  s^   e Zd ZU dZdZded< dZded< dZd	ed
< ddddddZddddddddZ	dS )PercaY  
    Replace observations with percentile values.

    Parameters
    ----------
    k : list of numbers or int
        If a list of numbers, this gives the percentiles (in [0, 100]) to compute.
        If an integer, compute `k` evenly-spaced percentiles between 0 and 100.
        For example, `k=5` computes the 0, 25, 50, 75, and 100th percentiles.
    method : str
        Method for interpolating percentiles between observed datapoints.
        See :func:`numpy.percentile` for valid options and more information.

    Examples
    --------
    .. include:: ../docstrings/objects.Perc.rst

       zint | list[float]kr   strmethodTzClassVar[bool]group_by_orientr   )datavarreturnc                 C  s   t | jtr ttdd| jn| j}tt| j}|| 	 }t
tdrZtj|||d}ntj|| 	 ||d}t||d|iS )Nr   d   z1.22)interpolation)r   
percentile)
isinstancer   intlistnpZlinspacer   _MethodKindr   Zdropnar   r   r   )selfr   r   r   r   valuesres r"   8/tmp/pip-unpacked-wheel-ir0tye89/seaborn/_stats/order.py_percentile>   s    &
zPerc._percentiler	   zdict[str, Scale])r   groupbyorientscalesr   c                 C  s   ddd| }| || j|S )Nyx)r)   r(   )applyr$   )r   r   r%   r&   r'   r   r"   r"   r#   __call__I   s    zPerc.__call__N)
__name__
__module____qualname____doc__r   __annotations__r   r   r$   r+   r"   r"   r"   r#   r   %   s   
r   )
__future__r   Zdataclassesr   typingr   r   r   ImportErrorZtyping_extensionsZnumpyr   Zpandasr   Zseaborn._core.scalesr   Zseaborn._core.groupbyr	   Zseaborn._stats.baser
   Zseaborn.utilsr   r   r   r"   r"   r"   r#   <module>   s"   