
    PiM!                    `   d dl mZ d dlmZmZmZ d dlZd dlmZm	Z	m
Z
 d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ erd dlmZ e
	 	 d1d2d            Ze
	 	 d1d	dd3d            Ze
	 	 d1d	dd4d            Z	 	 d5ddd4dZd6dZd7d"Zd8d$Zd9d&Zd:d(Zd;d*Zd<d,Z d;d-Z!d=d.Z"d>d0Z#dS )?    )annotations)
CollectionIteratorSequenceN)TYPE_CHECKINGcastoverload)MatplotlibColor)find_stack_level)is_list_like)Colormap.
num_colorsintcolormapColormap | None
color_typestrcolordict[str, Color]returnc                   d S N r   r   r   r   s       u/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/plotting/_matplotlib/style.pyget_standard_colorsr      s	     s    r   Color | Sequence[Color] | Nonelist[Color]c                   d S r   r   r   s       r   r   r   '   s	     #r   1dict[str, Color] | Color | Sequence[Color] | Nonedict[str, Color] | list[Color]c                   d S r   r   r   s       r   r   r   1   s	     &)Sr   defaultc                   t          |t                    r|S t          ||||           }t          t	          ||                     S )a  
    Get standard colors based on `colormap`, `color_type` or `color` inputs.

    Parameters
    ----------
    num_colors : int
        Minimum number of colors to be returned.
        Ignored if `color` is a dictionary.
    colormap : :py:class:`matplotlib.colors.Colormap`, optional
        Matplotlib colormap.
        When provided, the resulting colors will be derived from the colormap.
    color_type : {"default", "random"}, optional
        Type of colors to derive. Used if provided `color` and `colormap` are None.
        Ignored if either `color` or `colormap` are not None.
    color : dict or str or sequence, optional
        Color(s) to be used for deriving sequence of colors.
        Can be either be a dictionary, or a single color (single color string,
        or sequence of floats representing a single color),
        or a sequence of colors.

    Returns
    -------
    dict or list
        Standard colors. Can either be a mapping if `color` was a dictionary,
        or a list of colors with a length of `num_colors` or more.

    Warns
    -----
    UserWarning
        If both `colormap` and `color` are provided.
        Parameter `color` will override.
    r   r   r   r   r   )
isinstancedict_derive_colorslist_cycle_colors)r   r   r   r   colorss        r   r   r   ;   sY    N % 	  F f<<<===r    Color | Collection[Color] | Nonestr | Colormap | Nonec                    | |t          ||          S | 3|"t          j        dt                                 t	          |           S t          ||          S )aa  
    Derive colors from either `colormap`, `color_type` or `color` inputs.

    Get a list of colors either from `colormap`, or from `color`,
    or from `color_type` (if both `colormap` and `color` are None).

    Parameters
    ----------
    color : str or sequence, optional
        Color(s) to be used for deriving sequence of colors.
        Can be either be a single color (single color string, or sequence of floats
        representing a single color), or a sequence of colors.
    colormap : :py:class:`matplotlib.colors.Colormap`, optional
        Matplotlib colormap.
        When provided, the resulting colors will be derived from the colormap.
    color_type : {"default", "random"}, optional
        Type of colors to derive. Used if provided `color` and `colormap` are None.
        Ignored if either `color` or `colormap`` are not None.
    num_colors : int
        Number of colors to be extracted.

    Returns
    -------
    list
        List of colors extracted.

    Warns
    -----
    UserWarning
        If both `colormap` and `color` are provided.
        Parameter `color` will override.
    Nr(   zC'color' and 'colormap' cannot be used simultaneously. Using 'color')
stacklevel)_get_colors_from_colormapwarningswarnr   _get_colors_from_color_get_colors_from_color_typer'   s       r   r+   r+   o   sv    N }-(jIIII		MU+--    &e,,,*:*MMMMr   r.   Iterator[Color]c              #     K   t          |t          |                     }t          j        t          j        |           |          E d{V  dS )zCycle colors until achieving max of `num_colors` or length of `colors`.

    Extra colors will be ignored by matplotlib if there are more colors
    than needed and nothing needs to be done here.
    N)maxlen	itertoolsislicecycle)r.   r   
max_colorss      r   r-   r-      sR       ZV--J	 7 7DDDDDDDDDDDr   str | Colormapc                h    t          |           fdt          j        dd|          D             S )zGet colors from colormap.c                &    g | ]} |          S r   r   ).0numcmaps     r   
<listcomp>z-_get_colors_from_colormap.<locals>.<listcomp>   s!    CCC#DDIICCCr   r      )rD   )_get_cmap_instancenplinspace)r   r   rE   s     @r   r3   r3      s=    
 h''DCCCCQz!B!B!BCCCCr   r   c                    t          | t                    r)| }t          j        |          } | t	          d| d          | S )z$Get instance of matplotlib colormap.Nz	Colormap z is not recognized)r)   r   mpl	colormaps
ValueError)r   rE   s     r   rH   rH      sK    (C   C=*AAAABBBOr   Color | Collection[Color]c                   t          |           dk    rt          d|            t          |           rt          t          |           } | gS t          t
          t                   |           } t          t          |                     S )z!Get colors from user input color.r   zInvalid color argument: )r;   rN   _is_single_colorr   Colorr   r,   !_gen_list_of_colors_from_iterabler   s    r   r6   r6      s{     5zzQ;E;;<<< UE""wE"E**E1%88999r   boolc                t    t          | t                    rt          |           rdS t          |           rdS dS )a0  Check if `color` is a single color, not a sequence of colors.

    Single color is of these kinds:
        - Named color "red", "C0", "firebrick"
        - Alias "g"
        - Sequence of floats, such as (0.1, 0.2, 0.3) or (0.1, 0.2, 0.3, 0.4).

    See Also
    --------
    _is_single_string_color
    TF)r)   r   _is_single_string_color_is_floats_colorr   s    r   rQ   rQ      sE     % "9%"@"@ t t5r   Collection[Color]c              #  ^   K   | D ]'}t          |          r|V  t          d|           dS )zS
    Yield colors from string of several letters or from collection of colors.
    zInvalid color N)rQ   rN   )r   xs     r   rS   rS      sS        3 3A 	3GGGG1a11222	3 3r   c                    t          t          |           o>t          |           dk    pt          |           dk    ot          d | D                                 S )zACheck if color comprises a sequence of floats representing color.      c              3  N   K   | ] }t          |t          t          f          V  !d S r   )r)   r   float)rC   rZ   s     r   	<genexpr>z#_is_floats_color.<locals>.<genexpr>   s0      ;;
1sEl++;;;;;;r   )rT   r   r;   allr   s    r   rW   rW      s_    U 	<ZZ1_/E

a	<;;U;;;;;  r   c           
     \   | dk    rLt           j        d         }d t          j        |t	          |t          |                              D             S | dk    rFt          j                            |                              |df          	                                S t          d          )z&Get colors from user input color type.r%   zaxes.prop_cyclec                    g | ]
}|d          S r   r   )rC   cs     r   rF   z/_get_colors_from_color_type.<locals>.<listcomp>   s,     
 
 
 gJ
 
 
r   randomr\   z/color_type must be either 'default' or 'random')rL   rcParamsr<   r=   minr;   rI   re   default_rngtolistrN   )r   r   
prop_cycles      r   r7   r7      s    Y\"34

 
%j#j#j//2R2RSS
 
 
 	
 
x		y$$Z0077QHHOOQQQJKKKr   rR   c                    t           j                                        }	 |                    |            dS # t          $ r Y dS w xY w)a  Check if `color` is a single string color.

    Examples of single string colors:
        - 'r'
        - 'g'
        - 'red'
        - 'green'
        - 'C3'
        - 'firebrick'

    Parameters
    ----------
    color : Color
        Color string or sequence of floats.

    Returns
    -------
    bool
        True if `color` looks like a valid color.
        False otherwise.
    TF)
matplotlibr.   ColorConverterto_rgbarN   )r   convs     r   rV   rV     s\    , ++--D 	U t    uus   7 
AA)..)
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#   )Nr%   )
r   r/   r   r0   r   r   r   r   r   r    )r.   r    r   r   r   r8   )r   r@   r   r   r   r    )r   r@   r   r   )r   rO   r   r    )r   rO   r   rT   )r   rX   r   r8   )r   r   r   r   r   r    )r   rR   r   rT   )$
__future__r   collections.abcr   r   r   r<   typingr   r   r	   r4   rl   rL   matplotlib.colorsnumpyrI   pandas._typingr
   rR   pandas.util._exceptionsr   pandas.core.dtypes.commonr   r   r   r+   r-   r3   rH   r6   rQ   rS   rW   r7   rV   r   r   r   <module>rx      s   " " " " " "         
             
              3 3 3 3 3 3 4 4 4 4 4 4 2 2 2 2 2 2 +****** 
 !$    
 
 !$
 -0     
 
 !$)
 @C) ) ) ) ) 
) !%1>
 @D1> 1> 1> 1> 1> 1>h1N 1N 1N 1NhE E E ED D D D   : : : :   ,3 3 3 3   L L L L     r   