
    
3jC                     "   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJ	r	J
r
JrJrJrJrJrJrJr   " S S5      r\" 5       r " S S\5      r " S	 S
5      r " S S5      rS rS rS rS r\4S jrS rSS jrS r S r!S r"S r#SS jr$g)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                       \ rS rSrS rSrg)_Unset    c                     g)Nz<UNSET> selfs    R/home/wildlama/miniconda3/lib/python3.13/site-packages/matplotlib/_api/__init__.py__repr___Unset.__repr__!   s        r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r       s    r   r   c                       \ rS rSrSrSrg)UnsupportedError&   z
Raised on inherited methods if the child class does not support the functionality
of the base class.

See `.unsupported_method` for details.
r   N)r   r   r   r   __doc__r   r   r   r   r   r   &   s    r   r   c                   ,    \ rS rSrSrSS.S jrS rSrg)unsupported_method/   a  
Descriptor that creates a method raising `.UnsupportedError`.

Historically, we have quite a few cases of inheritance hierarchies that do not
fully respect the Liskov Substitution Principle, e.g. Axes and Artist. Some of
the methods of a base class may not be implemented in the child class. In that case,
we override the method in the child class to raise `.UnsupportedError`.

Use in a class body to mark inherited methods as unsupported::

    class Axes3D(Axes):
        twinx = _api.unsupported_method()

Calling ``Axes3D().twinx()`` will raise
"UnsupportedError: Axes3D does not support 'twinx'."

Parameters
----------
append_message : str
    Optional additional text to be appended to the error message.
Nappend_messagec                    Xl         g Nr$   )r   r%   s     r   __init__unsupported_method.__init__E   s    ,r   c                    ^ UR                    SU S3mU R                  (       a  TSU R                  -   -  mU4S jnX#l         UR                   SU 3Ul        UR                  Ul        [	        XU5        g )Nz does not support 'z'. c                    > [        T5      er'   )r   )r   argskwargsmessages      r   method/unsupported_method.__set_name__.<locals>.methodM   s    "7++r   .)r   r%   r   r   setattr)r   ownernamer0   r/   s       @r   __set_name__unsupported_method.__set_name__H   sw    ^^$$7vR@sT0000G	, !&!3!3 4AdV<!,,V$r   )r   r   r   r   r    r(   r6   r   r   r   r   r"   r"   /   s    * *. -%r   r"   c                   8    \ rS rSrSrSS jrS r\S 5       rSr	g)	classpropertyV   z
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                 V    Xl         Uc  Ub  [        S5      eX l        X0l        X@l        g )Nz#classproperty only implements fget.)_fget
ValueErrorfsetfdel_doc)r   fgetr>   r?   docs        r   r(   classproperty.__init__g   s-    
t/BCC			r   c                 $    U R                  U5      $ r'   r<   )r   instancer4   s      r   __get__classproperty.__get__p   s    zz%  r   c                     U R                   $ r'   rE   r   s    r   rA   classproperty.fgets   s    zzr   )r@   r<   r?   r>   )NNN)
r   r   r   r   r    r(   rG   propertyrA   r   r   r   r   r9   r9   V   s%     !  r   r9   c                  ^ [        S5      m[        U [         5      (       a  U 4OU c  T4O[        U4S jU  5       5      n U4S jnUR                  5        H  u  p4[        X@5      (       a  M  / [	        X 5      QnSU;   a"  UR                  S5        UR                  S5        [        SR                  U[        U5      S:  a  SR                  USS 5      S	-   US   -   OUS
   U" [        U5      5      5      5      e   g)a  
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   0   >#    U  H  oc  TOUv   M     g 7fr'   r   ).0tp	none_types     r   	<genexpr>#check_isinstance.<locals>.<genexpr>   s     CUr
92Us   c                    > U TL a  S$ U R                   S:X  a  U R                  $ U R                    SU R                   3$ )NNonebuiltinsr2   )r   r   )rO   rP   s    r   	type_name#check_isinstance.<locals>.type_name   sD    	/ 	;(*(CR__	;a'89	;r   rT   z({!r} must be an instance of {}, not a {}r   , z or r   )type
isinstancetupleitemsmapremoveappend	TypeErrorformatlenjoin)typesr.   rV   kvnamesrP   s         @r   check_isinstanceri   {   s     T
I#E400eX"]i\CUCC 
;
 !##,c)+,EV$V$:AA5zA~ IIeCRj)F2U2Y>+08d1g&	() ) r   c                 j   [        U5      S:  ax  [        S U/UQ 5       5      (       a^  [        R                  " XSS9n[        U5      =S:X  a    SnOWS:X  a  SUS   < S	3nOG S
SR	                  [        [        U5      5       S	3nO"SSR	                  [        [        U5      5       3nU< SU  SU 3$ )a  
Generate an error message that a potential setting is not an acceptable value.

If the acceptable values are all strings, and sufficiently large, then add just a
few suggestions to the end of the message. Otherwise list the supported values.

Parameters
----------
name : str
    The name of the setting, keyword argument, etc. to generate the message for.
potential
    The potential value from the user that is not a valid choice.
values : iterable
    Sequence of values to check on.
   c              3   B   #    U  H  n[        U[        5      v   M     g 7fr'   )r[   str)rN   rg   s     r   rQ   ,list_suggestion_error_msg.<locals>.<genexpr>   s     P;Oaz!S11;Os   g      ?)cutoffr    r   z Did you mean: ?z Did you mean one of: rX   z Supported values are z is not a valid value for r2   )rc   alldifflibget_close_matchesrd   r^   repr)r5   	potentialvaluesbest
suggestions        r   list_suggestion_error_msgrz      s      6{Q3PI;O;OPPP((3G$i
.tAwk;
5diiD$6P5QQRS
-diiD&8I.J-KL
]4TF!J<HHr   c                    U(       d  [        S5      eUR                  5        H&  u  p# X0;   nU(       a  M  [        [        X#U 5      5      e   g! [         a    Sn N/f = f)a4  
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.

    Note: All values must support == comparisons.
    This means in particular the entries must not be numpy arrays.
**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!FN)ra   r]   r=   rz   )rw   r.   keyvalexistss        r   check_in_listr      sc    0 /00LLN
	]F v6sHII #  	 F	s   AAAc          
      D   UR                  5        GH  u  p#UR                  n[        U5      [        U 5      :w  d"  [        S [	        X@5       5       5      (       d  ML  [        [        R                  " SS [        R                  " 5        5       5      5      nSR                  U SSS2    Vs/ s H  nUb  [        U5      O
[        U5      PM     snSSS2   5      n[        U 5      S:X  a  US-  n[        U< S	[        U 5       S
U SUR                   35      e   gs  snf )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   D   #    U  H  u  pX:g  =(       a    US Lv   M     g 7fr'   r   )rN   sts      r   rQ   check_shape.<locals>.<genexpr>   s"     S<RDAqv/!4-/<Rs    NMLKJIHc              3   ,   #    U  H
  nS U 3v   M     g7f)DNr   )rN   is     r   rQ   r      s     4"3Q1QC"3s   rX   NrY   r   ,z	 must be zD with shape (z), but your input has shape )r]   shaperc   anyzipiter	itertoolschaincountrd   rm   nextr=   )r   r.   rf   rg   
data_shape
dim_labelsn
text_shapes           r   check_shaper      s     WW

Os5z)SC
<RSSSioo4)//"346 7J -24R4[$:-8 /0mCFjAQ$Q-8$::>B$$@ AJ5zQc!
%yUN:, G,,-GG96  $:s   ,#D
c          	          [        U5      S:w  a  [        S5      eUR                  5       u  u  p4 X   $ ! [         a"    U" [	        X4U R                  5       5      5      Sef = f)a  
*kwargs* must consist of a single *key, value* pair.  If *key* is in
*mapping*, return ``mapping[value]``; else, raise an appropriate
ValueError.

Parameters
----------
_error_cls :
    Class of error to raise.

Examples
--------
>>> _api.getitem_checked({"foo": "bar"}, arg=arg)
r   z/getitem_checked takes a single keyword argumentN)rc   r=   r]   KeyErrorrz   keys)mapping
_error_clsr.   rf   rg   s        r   getitem_checkedr   	  se     6{aJKKllnGFQTz T21HItSTs	   4 ,A c                 
  ^ ^^ T R                   S:X  d   e[        T 5      R                  5        VVs0 s H  u  p[        U[        5      (       d  M  X_M      snnmT " 5       m[
        R                  U UU4S j5       nU$ s  snnf )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                 r   > U T;   a  TU    R                  T5      $ [        STR                  < SU < 35      e)Nzmodule z has no attribute )rG   AttributeErrorr   )r5   clsrF   propss    r   r   +caching_module_getattr.<locals>.__getattr__:  sD    5=;&&x00cnn''9$BD 	Dr   )r   varsr]   r[   rK   	functoolscache)r   r5   propr   rF   r   s   `   @@r   caching_module_getattrr   !  s{    & <<=(((*.s)//*; ,*;JD4* TZ*; ,EuH__D D ,s   A?A?c                 N  ^ Tc  [         R                  " [        U 5      $ U4S jnU R                  5        Hs  u  p4SnS HP  nXc-   [	        T5      ;   d  M  SnU H2  nU" Xc-   5      nXg-   Ul        SXc-    S3Ul        [        TXg-   U5        M4     MR     U(       a  Mf  [        SU< 35      e   U R                  5        VVVs0 s H  u  p4U  H  owU_M     M     n	nnnS n
[        TS	0 5      nU
" U5      U
" U	5      -  nU(       a  [        S
U 35      e0 UEU	ETl        T$ s  snnnf )a!  
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_to_prop`` attribute under the format
``{"alias": "property", ...}` on the class, and can be used by
`.normalize_kwargs`.
c                 \   >^  [         R                  " [        TT 5      5      U 4S j5       nU$ )Nc                 (   > [        U T5      " U0 UD6$ r'   )getattr)r   r-   r.   r5   s      r   r0   2define_aliases.<locals>.make_alias.<locals>.methodZ  s    4&777r   )r   wrapsr   )r5   r0   r   s   ` r   
make_alias"define_aliases.<locals>.make_aliasY  s*    	d+	,	8 
-	8r   F)get_set_TzAlias for `z`.z%Neither getter nor setter exists for c                 F    1 U R                  5       kU R                  5       k$ r'   )r   rw   )ds    r   get_aliased_and_aliases/define_aliases.<locals>.get_aliased_and_aliasesp  s    ''AHHJ''r   _alias_to_propz2Parent class already defines conflicting aliases: )r   partialdefine_aliasesr]   r   r   r    r3   r=   r   NotImplementedErrorr   )alias_dr   r   r   aliasesr~   prefixaliasr0   alias_to_propr   preexisting_aliasesconflictings    `           r   r   r   D  sR   $ {  99 !&F}S	)$E'6F&,nFO'26=/%DFNC8	 % ' v7x@B B ) *1O)8gUtg  O( "#'7<*+>?,];<K!@NP 	PA/A=ACJOs   D c                     [        U 5       H  u  p4 U" U0 UD6s  $    g! [         a    U[        U 5      S-
  :X  a  e  M3  f = f)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)	enumeratera   rc   )funcsr-   r.   r   funcs        r   select_matching_signaturer   ~  sT    X U#	((( $  	CJN" #	s   A A c                 *    [        U  SU SU S35      $ )zEGenerate a TypeError to be raised by function calls with wrong arity.z	() takes z positional arguments but z were given)ra   )r5   takesgivens      r   nargs_errorr     s(    vYug-Gwk+ , ,r   c                 v    [        U[        5      (       d  [        [        U5      5      n[	        U  SU S35      $ )a(  
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 '')r[   rm   r   r   ra   )r5   kws     r   kwarg_errorr     s7     b#$r(^vDRDJKKr   c              #   l   #    U v   U R                  5        H  n[        U5       Sh  vN   M     g N	7f)z8Yield *cls* and direct and indirect subclasses of *cls*.N)__subclasses__recursive_subclasses)r   subclss     r   r   r     s.     
I$$&'/// '/s   &42
4c                    0 n[         R                  SS S:  aG  [        R                  " [        5      R
                  S   n[        US-  5      [        US-  5      4US'   O[         R                  " 5       n[        R                  " S5       HT  nUc  XRS'     OL[        R                  " S	UR                  R                  S
S5      5      (       d  XRS'     OUR                  nMV     A[        R                   " X40 UD6  g)a  
`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   rp   )sysversion_infopathlibPath__file__parentsrm   	_getframer   r   rematch	f_globalsgetf_backwarningswarn)r/   categoryr.   basedirframer   s         r   warn_externalr     s     F
w&,,x(003(+Gl,B(C(+Gn,D(E(G#$ #//!,J}'1|$88L!OO//
B?A A (2|$LLE - MM'.v.r   r'   )%r    rs   r   r   r   r   r   r   deprecationr   r   r   r   r   r	   r
   r   r   r   UNSETRuntimeErrorr   r"   r9   ri   rz   r   r   r=   r   r   r   r   r   r   r   r   r   r   r   <module>r      s   
     	 
 " " "  	| $% $%N J )FI<'JT F ,6 T0 F7t1h,L"0/r   