
    P/Ph5                         d Z ddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZmZmZmZmZ  G d d          Zd Zdd	d
Zd Zd Zd ZddZd Zd Zd Zd ZddZdS )a+  
Helper functions for managing the Matplotlib API.

This documentation is only relevant for Matplotlib developers, not for users.

.. warning::

    This module and its submodules are for internal use only.  Do not use them
    in your own code.  We may change the API at any time with no warning.

    N   )	
deprecatedwarn_deprecatedrename_parameterdelete_parametermake_keyword_onlydeprecate_method_overridedeprecate_privatize_attribute'suppress_matplotlib_deprecation_warningMatplotlibDeprecationWarningc                   6    e Zd ZdZddZd Zed             ZdS )classpropertya$  
    Like `property`, but also triggers on access via the class, and it is the
    *class* that's passed as argument.

    Examples
    --------
    ::

        class C:
            @classproperty
            def foo(cls):
                return cls.__name__

        assert C.foo == "C"
    Nc                 d    || _         ||t          d          || _        || _        || _        d S )Nz#classproperty only implements fget.)_fget
ValueErrorfsetfdel_doc)selffgetr   r   docs        X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/_api/__init__.py__init__zclassproperty.__init__-   s<    
t/BCCC					    c                 ,    |                      |          S Nr   )r   instanceowners      r   __get__zclassproperty.__get__6   s    zz%   r   c                     | j         S r   r   )r   s    r   r   zclassproperty.fget9   s
    zr   )NNN)__name__
__module____qualname____doc__r   r    propertyr    r   r   r   r      s\             ! ! !   X  r   r   c                l   t          d          t          | t                     r| fn| fnt          fd| D                       } fd}|                                D ]\  }}t          ||           sg t	          ||           }d|v r*|                    d           |                    d           t          d                    |t          |          dk    r)d
                    |dd                   d	z   |d         z   n|d
          |t          |                                        dS )a3  
    For each *key, value* pair in *kwargs*, check that *value* is an instance
    of one of *types*; if not, raise an appropriate TypeError.

    As a special case, a ``None`` entry in *types* is treated as NoneType.

    Examples
    --------
    >>> _api.check_isinstance((SomeClass, None), arg=arg)
    Nc              3   $   K   | ]
}|n|V  d S r   r'   ).0tp	none_types     r   	<genexpr>z#check_isinstance.<locals>.<genexpr>O   s+      CCr
99CCCCCCr   c                 V    | u rdn"| j         dk    r| j        n| j          d| j         S )NNonebuiltins.)r#   r$   )r+   r,   s    r   	type_namez#check_isinstance.<locals>.type_nameQ   s=    	//(*(C(CR__9999	;r   r/   z({!r} must be an instance of {}, not a {}r   , z or r   )type
isinstancetupleitemsmapremoveappend	TypeErrorformatlenjoin)typeskwargsr2   kvnamesr,   s         @r   check_isinstancerE   A   sl    T

I#E400 DeXX"]i\\CCCCUCCCCC 
; ; ; ; ;
  ) )1!U## 
	),c)U++,EV$$$V$$$:AA5zzA~~ IIeCRCj))F2U2Y>>+08Id1gg&&	( () ) )
	)) )r   T)_print_supported_valuesc         	          |st          d          |                                D ]O\  }}|| vrF|d| }|r.|dd                    t          t          |                      z  }t          |          PdS )ak  
    For each *key, value* pair in *kwargs*, check that *value* is in *values*;
    if not, raise an appropriate ValueError.

    Parameters
    ----------
    values : iterable
        Sequence of values to check on.
    _print_supported_values : bool, default: True
        Whether to print *values* when raising ValueError.
    **kwargs : dict
        *key, value* pairs as keyword arguments to find in *values*.

    Raises
    ------
    ValueError
        If any *value* in *kwargs* is not found in *values*.

    Examples
    --------
    >>> _api.check_in_list(["foo", "bar"], arg=arg, other_arg=other_arg)
    zNo argument to check! is not a valid value for ; supported values are r3   N)r<   r8   r?   r9   reprr   )valuesrF   rA   keyvalmsgs         r   check_in_listrO   d   s    .  1/000LLNN " "Sf;;c;;C& PO3tV;L;L1M1MOOOS//!	 " "r   c          
      D   |                                 D ]\  }}|j        }t          |          t          |           k    s't          d t	          ||           D                       rt          t          j        dd t          j                    D                                 d	                    fd| ddd         D             ddd                   }t          |           dk    r|d	z  }t          |d
t          |            d| d|j                   
dS )a  
    For each *key, value* pair in *kwargs*, check that *value* has the shape *shape*;
    if not, raise an appropriate ValueError.

    *None* in the shape is treated as a "free" size that can have any length.
    e.g. (None, 2) -> (N, 2)

    The values checked must be numpy arrays.

    Examples
    --------
    To check for (N, 2) shaped arrays

    >>> _api.check_shape((None, 2), arg=arg, other_arg=other_arg)
    c              3   0   K   | ]\  }}||k    o|d uV  d S r   r'   )r*   sts      r   r-   zcheck_shape.<locals>.<genexpr>   s3      SSDAqqAv/!4-SSSSSSr   NMLKJIHc              3       K   | ]	}d | V  
dS )DNr'   )r*   is     r   r-   zcheck_shape.<locals>.<genexpr>   s(      44QQ444444r   r3   c                 P    g | ]"}|t          |          nt                    #S r   )strnext)r*   n
dim_labelss     r   
<listcomp>zcheck_shape.<locals>.<listcomp>   s?     $: $: $:() /0mCFFFjAQAQ $: $: $:r   Nr4   r   ,z	 must be zD with shape (z), but your input has shape )r8   shaper>   anyzipiter	itertoolschaincountr?   r   )r_   rA   rB   rC   
data_shape
text_shaper\   s         @r   check_shaperh      sj       1W

OOs5zz))SSC
E<R<RSSSSS *io44)/"3"34446 6 7 7J  $: $: $: $:-244R4[$: $: $::>$B$$@ A AJ5zzQc!
 6 6U 6 6: 6 6,-G6 6   * r   c                "   t          |          dk    rt          d          |                                \  \  }}	 | |         S # t          $ r? t          |d| dd                    t          t          |                                dw xY w)z
    *kwargs* must consist of a single *key, value* pair.  If *key* is in
    *mapping*, return ``mapping[value]``; else, raise an appropriate
    ValueError.

    Examples
    --------
    >>> _api.check_getitem({"foo": "bar"}, arg=arg)
    r   z-check_getitem takes a single keyword argumentrH   rI   r3   N)r>   r   r8   KeyErrorr?   r9   rJ   )mappingrA   rB   rC   s       r   check_getitemrl      s     6{{aHIIIllnnGFQ:qz : : : / /a / /yyT7++,,/ /0 059	::s   A A	Bc                       j         dk    sJ d t                                                     D                           t          j         fd            }|S )a
  
    Helper decorator for implementing module-level ``__getattr__`` as a class.

    This decorator must be used at the module toplevel as follows::

        @caching_module_getattr
        class __getattr__:  # The class *must* be named ``__getattr__``.
            @property  # Only properties are taken into account.
            def name(self): ...

    The ``__getattr__`` class will be replaced by a ``__getattr__``
    function such that trying to access ``name`` on the module will
    resolve the corresponding property (which may be decorated e.g. with
    ``_api.deprecated`` for deprecating module globals).  The properties are
    all implicitly cached.  Moreover, a suitable AttributeError is generated
    and raised if no property with the given name exists.
    __getattr__c                 D    i | ]\  }}t          |t                    ||S r'   )r6   r&   )r*   nameprops      r   
<dictcomp>z*caching_module_getattr.<locals>.<dictcomp>   s<     , , ,JD$4**,T4 , , ,r   c                 v    | v r|                                         S t          dj        d|           )Nzmodule z has no attribute )r    AttributeErrorr#   )rp   clsr   propss    r   rn   z+caching_module_getattr.<locals>.__getattr__   sN    5==;&&x000BcnBB$BBD D 	Dr   )r"   varsr8   	functoolscache)ru   rn   r   rv   s   ` @@r   caching_module_getattrrz      s    & <=((((, ,$s))//*;*; , , ,EsuuH_D D D D D D _D r   c                    t          j        t          |           S fd}|                                 D ]u\  }}d}dD ]W}||z   t	                    v rAd}|D ]<} |||z             }||z   |_        d||z    d|_        t          ||z   |           =X|st          d|          vd	 }	t          d
i           }
 |	|
           |	|           z  }|rt          d|           i |
| _        S )aT  
    Class decorator for defining property aliases.

    Use as ::

        @_api.define_aliases({"property": ["alias", ...], ...})
        class C: ...

    For each property, if the corresponding ``get_property`` is defined in the
    class so far, an alias named ``get_alias`` will be defined; the same will
    be done for setters.  If neither the getter nor the setter exists, an
    exception will be raised.

    The alias map is stored as the ``_alias_map`` attribute on the class and
    can be used by `.normalize_kwargs` (which assumes that higher priority
    aliases come last).
    Nc                 d     t          j        t                                fd            }|S )Nc                 0     t          |           |i |S r   )getattr)r   argsrA   rp   s      r   methodz2define_aliases.<locals>.make_alias.<locals>.method   s"    &74&&7777r   )rx   wrapsr~   )rp   r   ru   s   ` r   
make_aliasz"define_aliases.<locals>.make_alias   sA    	d++	,	,	8 	8 	8 	8 
-	,	8r   F)get_set_TzAlias for `z`.z%Neither getter nor setter exists for c                 F    h | d |                                  D             S )Nc              3   $   K   | ]}|D ]}|V  d S r   r'   )r*   aliasesaliass      r   r-   zBdefine_aliases.<locals>.get_aliased_and_aliases.<locals>.<genexpr>
  s/      KK7KK%eKKKKKKKr   )rK   )ds    r   get_aliased_and_aliasesz/define_aliases.<locals>.get_aliased_and_aliases	  s)    LLKK188::KKKLLr   
_alias_mapz2Parent class already defines conflicting aliases: )rx   partialdefine_aliasesr8   rw   r"   r%   setattrr   r~   NotImplementedErrorr   )alias_dru   r   rq   r   existsprefixr   r   r   preexisting_aliasesconflictings    `          r   r   r      s   $ { 999     ! B Bg& 	9 	9F}S		))$ 9 9E'Z66F&,unFO%D6D=%D%D%DFNC%8888 	B@@@B B B	BM M M "#|R88**+>??,,W556K P!NNNP P 	P7+7w7CNJr   c                     t          |           D ]6\  }}	  ||i |c S # t          $ r |t          |           dz
  k    r Y 3w xY wdS )a  
    Select and call the function that accepts ``*args, **kwargs``.

    *funcs* is a list of functions which should not raise any exception (other
    than `TypeError` if the arguments passed do not match their signature).

    `select_matching_signature` tries to call each of the functions in *funcs*
    with ``*args, **kwargs`` (in the order in which they are given).  Calls
    that fail with a `TypeError` are silently skipped.  As soon as a call
    succeeds, `select_matching_signature` returns its return value.  If no
    function accepts ``*args, **kwargs``, then the `TypeError` raised by the
    last failing call is re-raised.

    Callers should normally make sure that any ``*args, **kwargs`` can only
    bind a single *func* (to avoid any ambiguity), although this is not checked
    by `select_matching_signature`.

    Notes
    -----
    `select_matching_signature` is intended to help implementing
    signature-overloaded functions.  In general, such functions should be
    avoided, except for back-compatibility concerns.  A typical use pattern is
    ::

        def my_func(*args, **kwargs):
            params = select_matching_signature(
                [lambda old1, old2: locals(), lambda new: locals()],
                *args, **kwargs)
            if "old1" in params:
                warn_deprecated(...)
                old1, old2 = params.values()  # note that locals() is ordered.
            else:
                new, = params.values()
            # do things with params

    which allows *my_func* to be called either with two parameters (*old1* and
    *old2*) or a single one (*new*).  Note that the new signature is given
    last, so that callers get a `TypeError` corresponding to the new signature
    if the arguments they passed in do not match any signature.
    r   N)	enumerater<   r>   )funcsr   rA   rW   funcs        r   select_matching_signaturer     s    X U##  4	4(((((( 	 	 	CJJN"" #"	 s    !AAc                 2    t          |  d| d| d          S )zEGenerate a TypeError to be raised by function calls with wrong arity.z	() takes z positional arguments but z were given)r<   )rp   takesgivens      r   nargs_errorr   K  s>     + +u + ++ + + , , ,r   c                     t          |t                    st          t          |                    }t	          |  d| d          S )aL  
    Generate a TypeError to be raised by function calls with wrong kwarg.

    Parameters
    ----------
    name : str
        The name of the calling function.
    kw : str or Iterable[str]
        Either the invalid keyword argument name, or an iterable yielding
        invalid keyword arguments (e.g., a ``kwargs`` dict).
    z'() got an unexpected keyword argument '')r6   rY   rZ   rb   r<   )rp   kws     r   kwarg_errorr   Q  sF     b# $r((^^JJRJJJKKKr   c              #   j   K   | V  |                                  D ]}t          |          E d{V  dS )z8Yield *cls* and direct and indirect subclasses of *cls*.N)__subclasses__recursive_subclasses)ru   subclss     r   r   r   b  sW      
III$$&& 0 0'//////////0 0r   c                    i }t           j        dd         dk    rLt          j        t                    j        d         }t          |dz            t          |dz            f|d<   npt          j                    }t          j	        d          D ]G}|||d<    n=t          j        d	|j                            d
d                    s||d<    n|j        }H~t          j        | |fi | dS )a4  
    `warnings.warn` wrapper that sets *stacklevel* to "outside Matplotlib".

    The original emitter of the warning can be obtained by patching this
    function back to `warnings.warn`, i.e. ``_api.warn_external =
    warnings.warn`` (or ``functools.partial(warnings.warn, stacklevel=2)``,
    etc.).
    N   )      
matplotlibmpl_toolkitsskip_file_prefixesr   
stacklevelz-\A(matplotlib|mpl_toolkits)(\Z|\.(?!tests\.))r"    )sysversion_infopathlibPath__file__parentsrY   	_getframerc   re   rematch	f_globalsgetf_backwarningswarn)messagecategoryrA   basedirframer   s         r   warn_externalr   i  s    F
w&&,x((03(+Gl,B(C(C(+Gn,D(E(E(G#$$ #/!,, 
	! 
	!J}'1|$8L!O//
B??A A  (2|$LEEM'8..v.....r   r   )r%   rx   rc   r   r   r   r   deprecationr   r   r   r   r   r	   r
   r   r   r   rE   rO   rh   rl   rz   r   r   r   r   r   r   r'   r   r   <module>r      s  
 
          				 



 " " " " " " " " " " " " " " " " " " " " " "       J )  )  )F 9= " " " " "B     F: : :*     F4 4 4 4n1 1 1h, , ,L L L"0 0 0/ / / / / /r   