
    .iM!                       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
	 	 d	 	 	 	 	 	 	 	 	 dd
       Ze
	 	 dd	d	 	 	 	 	 	 	 	 	 dd       Ze
	 	 dd	d	 	 	 	 	 	 	 	 	 dd       Z	 	 ddd	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 ddZddZ	 	 	 	 	 	 d dZd!dZ	 	 	 	 d"dZd#dZd$dZ d#dZ!d%dZ"d&dZ#y)'    )annotations)
CollectionIteratorSequenceN)TYPE_CHECKINGcastoverload)MatplotlibColor)find_stack_level)is_list_like)Colormap.c                    y N 
num_colorscolormap
color_typecolors       _/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/plotting/_matplotlib/style.pyget_standard_colorsr      s         r   c                    y r   r   r   s       r   r   r   '   s     r   c                    y r   r   r   s       r   r   r   1   s     &)r   c               p    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   ;   s>    N %	F f<==r   c                    | |t        ||      S | ,|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.
    r   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   sW    N }-(jII		MMU+- &e,,*:*MMr   c              #     K   t        |t        |             }t        j                  t        j                  |       |      E d{    y7 w)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#      s7      ZV-J	 7DDDs   AAA
Ac                z    t        |       }t        j                  dd|      D cg c]
  } ||       c}S c c}w )zGet colors from colormap.r      )num)_get_cmap_instancenplinspace)r   r   cmapr5   s       r   r'   r'      s3    
 h'D!#Qz!BC#DICCCs   8c                r    t        | t              r&| }t        j                  |    } | t	        d| d      | S )z$Get instance of matplotlib colormap.z	Colormap z is not recognized)r   strmpl	colormaps
ValueError)r   r9   s     r   r6   r6      s?    (C ==*y.@ABBOr   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.   r>   _is_single_colorr   Colorr   r"   !_gen_list_of_colors_from_iterabler   s    r   r*   r*      s_     5zQ3E7;<<UE"wE"E*E1%899r   c                T    t        | t              rt        |       ryt        |       ryy)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   r@   r@      s'     %"9%"@r   c              #  T   K   | D ]  }t        |      r| t        d|        yw)zS
    Yield colors from string of several letters or from collection of colors.
    zInvalid color N)r@   r>   )r   xs     r   rB   rB      s6       3AG~aS122	3s   &(c                    t        t        |       xr2 t        |       dk(  xs t        |       dk(  xr t        d | D                    S )zACheck if color comprises a sequence of floats representing color.      c              3  H   K   | ]  }t        |t        t        f        y wr   )r   intfloat).0rG   s     r   	<genexpr>z#_is_floats_color.<locals>.<genexpr>   s     ;
1sEl+;s    ")boolr   r.   allr   s    r   rE   rE      sG    U 	<Z1_/E
a	<;U;; r   c           	     L   | dk(  rMt         j                  d   }t        j                  |t	        |t        |                  D cg c]  }|d   	 c}S | dk(  r>t        j                  j                  |      j                  |df      j                         S t        d      c c}w )z&Get colors from user input color type.defaultzaxes.prop_cycler   randomrI   z/color_type must be either 'default' or 'random')r<   rcParamsr/   r0   minr.   r7   rT   default_rngtolistr>   )r   r   
prop_cyclecs       r   r+   r+      s    Y\\"34
 %%j#j#j/2RS
 gJ
 	
 
x	yy$$Z077QHOOQQJKK
s   B!c                    t         j                  j                         }	 |j                  |        y# t        $ r Y y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_rgbar>   )r   convs     r   rD   rD     sD    , ++-D 	U   s   2 	>>)..)
r   rL   r   Colormap | Noner   r;   r   dict[str, Color]returnra   )
r   rL   r   r`   r   r;   r   zColor | Sequence[Color] | Nonerb   list[Color])
r   rL   r   r`   r   r;   r   z1dict[str, Color] | Color | Sequence[Color] | Nonerb   zdict[str, Color] | list[Color])NrS   )
r   z Color | Collection[Color] | Noner   zstr | Colormap | Noner   r;   r   rL   rb   rc   )r$   rc   r   rL   rb   Iterator[Color])r   str | Colormapr   rL   rb   rc   )r   re   rb   r   )r   Color | Collection[Color]rb   rc   )r   rf   rb   rP   )r   zCollection[Color]rb   rd   )r   r;   r   rL   rb   rc   )r   rA   rb   rP   )$
__future__r   collections.abcr   r   r   r/   typingr   r   r	   r(   r\   r<   matplotlib.colorsnumpyr7   pandas._typingr
   rA   pandas.util._exceptionsr   pandas.core.dtypes.commonr   r   r   r!   r#   r'   r6   r*   r@   rB   rE   r+   rD   r   r   r   <module>ro      s   " 
  
     3 4 2* 
 !$ 
   
 
 !$
 -0 
 *  
 
 !$)
 @C))) )
 =) $) 
) !%1>
 @D1>1>1> 1>
 =1> $1>h1N+1N $1N 	1N
 1N 1NhEDDD D:$::,3Lr   