U
    Âmœd±&  ã                   @   st  d Z ddlZddlZddlZddlmZ ddlZddlZejdkrPddl	m
Z nddlZddlZddlmZmZmZmZ e e¡Zdddd	d
gZej e ¡ d¡Zej e ¡ d¡gZdZdddddddddddddddhZdd„ dD ƒZdZe  d  e!d!j"e#ee$j%d"�ƒ¡¡d#d„ ƒZ&ej'd/d%d„ƒZ(d&d'„ Z)d(d)„ Z*d*d+„ Z+G d,d-„ d-e,ƒZ-e*eƒZ.e-ƒ Z/g Z0d.d
„ Z1e1ƒ  dS )0aD  
Core functions and attributes for the matplotlib style library:

``use``
    Select style sheet to override the current matplotlib settings.
``context``
    Context manager to use a style sheet temporarily.
``available``
    List available style sheets.
``library``
    A dictionary of style names and matplotlib settings.
é    N)ÚPath)é   é
   )Ú_apiÚ
_docstringÚ_rc_params_in_fileÚrcParamsDefaultÚuseÚcontextÚ	availableÚlibraryÚreload_libraryZstylelibZmplstyleÚinteractiveÚbackendzwebagg.portzwebagg.addresszwebagg.port_retrieszwebagg.open_in_browserZbackend_fallbackZtoolbarÚtimezonezfigure.max_open_warningzfigure.raise_windowzsavefig.directoryztk.window_focuszdocstring.hardcopyz
date.epochc                 C   s   i | ]}||  d d¡“qS )Úseabornzseaborn-v0_8)Úreplace)Ú.0Ús© r   úN/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/matplotlib/style/core.pyÚ
<dictcomp>/   s   ÿ r   )r   zseaborn-brightzseaborn-colorblindzseaborn-darkzseaborn-darkgridzseaborn-dark-palettezseaborn-deepzseaborn-mutedzseaborn-notebookzseaborn-paperzseaborn-pastelzseaborn-posterzseaborn-talkzseaborn-tickszseaborn-whitezseaborn-whitegridzûThe seaborn styles shipped by Matplotlib are deprecated since %(since)s, as they no longer correspond to the styles shipped by seaborn. However, they will remain available as 'seaborn-v0_8-<style>'. Alternatively, directly use the seaborn API instead.Ú
z- {})Úkeyc                 C   s´  t | ttfƒst| dƒr | g}n| }dddœ}|D �]z} t | tƒ�r| | | ¡} | tkrntjdtd� t|  } | dkršt 	¡ � dd„ t
D ƒ} W 5 Q R X n|| tkr¬t|  } njd	| k�r|  d	¡\}}}z$t |¡|› d	t› � }t|ƒ} W n* tttfk
�r } zW 5 d
}~X Y nX t | ttfƒ�rhzt| ƒ} W n4 tk
�rf } zt| ›d�ƒ|‚W 5 d
}~X Y nX i }	| D ]0}
|
tk�r’t d|
›d�¡ n| |
 |	|
< �qptj |	¡ q2d
S )aß  
    Use Matplotlib style settings from a style specification.

    The style name of 'default' is reserved for reverting back to
    the default style settings.

    .. note::

       This updates the `.rcParams` with the settings from the style.
       `.rcParams` not defined in the style are kept.

    Parameters
    ----------
    style : str, dict, Path or list

        A style specification. Valid options are:

        str
            - One of the style names in `.style.available` (a builtin style or
              a style installed in the user library path).

            - A dotted name of the form "package.style_name"; in that case,
              "package" should be an importable Python package name, e.g. at
              ``/path/to/package/__init__.py``; the loaded style file is
              ``/path/to/package/style_name.mplstyle``.  (Style files in
              subpackages are likewise supported.)

            - The path or URL to a style file, which gets loaded by
              `.rc_params_from_file`.

        dict
            A mapping of key/value pairs for `matplotlib.rcParams`.

        Path
            The path to a style file, which gets loaded by
            `.rc_params_from_file`.

        list
            A list of style specifiers (str, Path or dict), which are applied
            from first to last in the list.

    Notes
    -----
    The following `.rcParams` are not related to style and will be ignored if
    found in a style specification:

    %s
    ÚkeysÚdefaultZclassic)Zmpl20Zmpl15ú3.6©Úmessagec                 S   s   i | ]}|t kr|t| “qS r   )ÚSTYLE_BLACKLISTr   )r   Úkr   r   r   r   ’   s    ÿ zuse.<locals>.<dictcomp>Ú.NzŒ is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)zStyle includes a parameter, z9, that is not related to style.  Ignoring this parameter.)Ú
isinstanceÚstrr   ÚhasattrÚgetÚ_DEPRECATED_SEABORN_STYLESr   Úwarn_deprecatedÚ_DEPRECATED_SEABORN_MSGZ'suppress_matplotlib_deprecation_warningr   r   Ú
rpartitionÚimportlib_resourcesÚfilesÚSTYLE_EXTENSIONr   ÚModuleNotFoundErrorÚOSErrorÚ	TypeErrorÚIOErrorr   Zwarn_externalÚmplZrcParamsÚupdate)ÚstyleÚstylesZstyle_aliasÚpkgÚ_ÚnameÚpathÚexcÚerrÚfilteredr    r   r   r   r	   K   sR    4




ÿÿý

ÿFc              	   c   s2   t  ¡ �  |rt  ¡  t| ƒ dV  W 5 Q R X dS )aû  
    Context manager for using style settings temporarily.

    Parameters
    ----------
    style : str, dict, Path or list
        A style specification. Valid options are:

        str
            - One of the style names in `.style.available` (a builtin style or
              a style installed in the user library path).

            - A dotted name of the form "package.style_name"; in that case,
              "package" should be an importable Python package name, e.g. at
              ``/path/to/package/__init__.py``; the loaded style file is
              ``/path/to/package/style_name.mplstyle``.  (Style files in
              subpackages are likewise supported.)

            - The path or URL to a style file, which gets loaded by
              `.rc_params_from_file`.
        dict
            A mapping of key/value pairs for `matplotlib.rcParams`.

        Path
            The path to a style file, which gets loaded by
            `.rc_params_from_file`.

        list
            A list of style specifiers (str, Path or dict), which are applied
            from first to last in the list.

    after_reset : bool
        If True, apply style after resetting settings to their defaults;
        otherwise, apply style on top of the current settings.
    N)r1   Z
rc_contextZ
rcdefaultsr	   )r3   Zafter_resetr   r   r   r
   ·   s
    %
c                 C   s*   t tjjtƒD ]}t|ƒ}t| |ƒ q| S )z0Update style library with user-defined rc files.)ÚmapÚosr8   Ú
expanduserÚUSER_LIBRARY_PATHSÚread_style_directoryÚupdate_nested_dict)r   Zstylelib_pathr4   r   r   r   Úupdate_user_libraryã   s    rB   c              
   C   sd   t ƒ }t| ƒ dt› �¡D ]D}tjdd��}t|ƒ||j< W 5 Q R X |D ]}t 	d||j
¡ qHq|S )z3Return dictionary of styles defined in *style_dir*.z*.T)Úrecordz	In %s: %s)Údictr   Úglobr,   ÚwarningsÚcatch_warningsr   ÚstemÚ_logÚwarningr   )Z	style_dirr4   r8   ZwarnsÚwr   r   r   r@   ë   s    r@   c                 C   s(   |  ¡ D ]\}}|  |i ¡ |¡ q| S )a  
    Update nested dict (only level of nesting) with new values.

    Unlike `dict.update`, this assumes that the values of the parent dict are
    dicts (or dict-like), so you shouldn't replace the nested dict if it
    already exists. Instead you should update the sub-dict.
    )ÚitemsÚ
setdefaultr2   )Z	main_dictZnew_dictr7   Zrc_dictr   r   r   rA   ö   s    	rA   c                   @   s   e Zd Zdd„ ZdS )Ú_StyleLibraryc                 C   s*   |t krtjdtd� t | }t | |¡S )Nr   r   )r&   r   r'   r(   rD   Ú__getitem__)Úselfr   r   r   r   rO     s    z_StyleLibrary.__getitem__N)Ú__name__Ú
__module__Ú__qualname__rO   r   r   r   r   rN     s   rN   c                   C   s.   t  ¡  t  ttƒ¡ tt  ¡ ƒtdd…< dS )zReload the style library.N)r   Úclearr2   rB   Ú_base_libraryÚsortedr   r   r   r   r   r   r     s    )F)2Ú__doc__Ú
contextlibÚloggingr=   Úpathlibr   ÚsysrF   Úversion_infoÚimportlib.resourcesÚ	resourcesr*   Z
matplotlibr1   r   r   r   r   Ú	getLoggerrQ   rI   Ú__all__r8   ÚjoinZget_data_pathZBASE_LIBRARY_PATHZget_configdirr?   r,   r   r&   r(   ZSubstitutionr<   ÚformatrV   r#   Úlowerr	   Úcontextmanagerr
   rB   r@   rA   rD   rN   rU   r   r   r   r   r   r   r   Ú<module>   sh   

          ûþÿÿ
i+