§
    ‡ÛgË4  ã                   óÄ   — 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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        úN/granary/edev/quantum/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__5   s   € Ø�zŠz˜%Ñ Ô Ð r   c                 ó   — | j         S r   r   )r   s    r   r   zclassproperty.fget8   s
   € àŒzÐr   )NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r    Úpropertyr   © r   r   r   r      s\   € € € € € ðð ð ð ð ð ð!ð !ð !ð ðð ñ „Xðð ð r   r   c                 óp  ‡— | }t          d¦  «        Št          |t           ¦  «        r|fn|€‰fnt          ˆfd„|D ¦   «         ¦  «        }ˆfd„}|                     ¦   «         D ]Ñ\  }}t          ||¦  «        s¼g t	          ||¦  «        ¢}d|v r*|                     d¦  «         |                     d¦  «         t          d                     |t          |¦  «        dk    r)d 
                    |dd…         ¦  «        d	z   |d         z   n|d
          |t          |¦  «        ¦  «        ¦  «        ¦  «        ‚ŒÒdS )a5  
    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>P   s+   øè è € ÐCÐC°r  
�9�9°Ð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_nameR   s=   ø€ Ø 	˜/˜/��Ø(*¬¸Ò(CÐ(C�R”_�_ØœÐ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ÚkwargsÚtypesr2   ÚkÚvÚnamesr,   s          @r   Úcheck_isinstancerF   A   sq  ø€ ð €EÝ�T‘
”
€IÝ# E­4Ñ0Ô0ð DˆeˆXˆXØ"˜]ˆiˆ\ˆ\ÝÐCÐCÐCÐC¸UÐCÑCÔCÑCÔCð 
ð;ð ;ð ;ð ;ð ;ð
 —’‘”ð )ð )‰ˆˆ1Ý˜!˜UÑ#Ô#ð 
	)Ø,•c˜) UÑ+Ô+Ð,ˆEØ˜ˆˆØ—’˜VÑ$Ô$Ð$Ø—’˜VÑ$Ô$Ð$ÝØ:×AÒAØå˜5‘z”z A’~�~ð —I’I˜e C R CœjÑ)Ô)¨FÑ2°U¸2´YÑ>Ð>Ø+0°¬8Ø�I�d 1™gœgÑ&Ô&ñ	(ô (ñ)ô )ð )ð
	)ð)ð )r   T)Ú_print_supported_valuesc          	      óô   — |st          d¦  «        ‚| }|                     ¦   «         D ]O\  }}||vrF|›d|› �}|r.|dd                     t          t          |¦  «        ¦  «        › �z  }t          |¦  «        ‚ŒPdS )aC  
    For each *key, value* pair in *kwargs*, check that *value* is in *_values*.

    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!z is not a valid value for z; supported values are r3   N)r<   r8   r?   r9   Úreprr   )Ú_valuesrG   rA   ÚvaluesÚkeyÚvalÚmsgs          r   Úcheck_in_listrO   e   s¦   € ð, ð 1ÝÐ/Ñ0Ô0Ð0Ø€FØ—L’L‘N”Nð "ð "‰ˆˆSØ�fÐÐØÐ;Ð;°cÐ;Ð;ˆCØ&ð PØÐO°·²½3½tÀVÑ;LÔ;LÑ1MÔ1MÐOÐOÑO�Ý˜S‘/”/Ð!ð	 ð"ð "r   c                 ó"  ‡— | }|                      ¦   «         D ]ö\  }}|j        }t          |¦  «        t          |¦  «        k    s't          d„ t	          ||¦  «        D ¦   «         ¦  «        r£t          t          j        dd„ t          j        ¦   «         D ¦   «         ¦  «        ¦  «        Šd 	                    ˆfd„|D ¦   «         ¦  «        }t          |¦  «        dk    r|dz  }t          |›dt          |¦  «        › d	|› d
|j        › d�¦  «        ‚Œ÷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   ó(   K  — | ]\  }}||d fvV — Œd S r   r'   )r*   ÚtÚss      r   r-   zcheck_shape.<locals>.<genexpr>š   sC   è è € ð 7
ð 7
á�A�qð ˜!˜T˜Ð"ð7
ð 7
ð 7
ð 7
ð 7
ð 7
r   ÚMNLIJKLHc              3   ó    K  — | ]	}d |› �V — Œ
dS )ÚDNr'   )r*   Úis     r   r-   zcheck_shape.<locals>.<genexpr>    s(   è è € Ð4Ð4˜Q��Q��Ð4Ð4Ð4Ð4Ð4Ð4r   r3   c              3   óX   •K  — | ]$}|�t          |¦  «        nt          ‰¦  «        V — Œ%d S r   )ÚstrÚnext)r*   ÚnÚ
dim_labelss     €r   r-   zcheck_shape.<locals>.<genexpr>¡   sS   øè è € ð $;ð $;ð )*ð () }õ %(¨¡F¤F Få)-¨jÑ)9Ô)9ð$;ð $;ð $;ð $;ð $;ð $;r   r   ú,z	 must be zD with shape (z). Your input has shape r1   N)r8   Úshaper>   ÚanyÚzipÚiterÚ	itertoolsÚchainÚcountr?   r   )Ú_shaperA   Útarget_shaperC   rD   Ú
data_shapeÚ
text_shaper\   s          @r   Úcheck_shaperi   †   st  ø€ ð  €LØ—’‘”ð ð ‰ˆˆ1Ø”Wˆ
åˆ|ÑÔ¥ J¡¤Ò/Ð/µ3ð 7
ð 7
å ¨jÑ9Ô9ð7
ñ 7
ô 7
ñ 4
ô 4
Ð/õ �iœoØØ4Ð4¥)¤/Ñ"3Ô"3Ð4Ñ4Ô4ñ6ô 6ñ 7ô 7ˆJð Ÿšð $;ð $;ð $;ð $;ð .:ð$;ñ $;ô $;ñ <ô <ˆJõ �<Ñ Ô  AÒ%Ð%Ø˜cÑ!�
åØð 3ð 3¥ \Ñ!2Ô!2ð 3ð 3Ø)ð3ð 3à()¬ð3ð 3ð 3ñô ð ð 0ðð r   c                 ó@  — | }t          |¦  «        dk    rt          d¦  «        ‚|                     ¦   «         \  \  }}	 ||         S # t          $ rL t          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 argumentz9{!r} is not a valid value for {}; supported values are {}r3   N)r>   r   r8   ÚKeyErrorr=   r?   r9   rI   )Ú_mappingrA   ÚmappingrC   rD   s        r   Úcheck_getitemrn   ¯   s«   € ð €GÝ
ˆ6�{„{�aÒÐÝÐHÑIÔIÐIØ�lŠl‰nŒn�G�F€QˆðDØ�qŒzÐøÝð Dð Dð DÝØGßŠV�A�q˜$Ÿ)š)¥C­¨gÑ$6Ô$6Ñ7Ô7Ñ8Ô8ñ:ô :à?Cð	DðDøøøs   ¿A ÁABc                 óÒ   ‡ ‡‡— ‰ j         dk    sJ ‚d„ t          ‰ ¦  «                             ¦   «         D ¦   «         Š ‰ ¦   «         Št          j        d¦  «        ˆ ˆˆ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<   € ð ,ð ,ð ,™J˜D $Ý˜4¥Ñ*Ô*ð,ˆT�4ð ,ð ,ð ,r   Nc                 óv   •— | ‰v r‰|                                ‰¦  «        S t          d‰j        ›d| ›�¦  «        ‚)Nzmodule z has no attribute )r    ÚAttributeErrorr#   )rr   Úclsr   Úpropss    €€€r   rp   z+caching_module_getattr.<locals>.__getattr__Þ   sN   ø€ à�5ˆ=ˆ=Ø˜”;×&Ò& xÑ0Ô0Ð0ÝØB�c”nÐBÐB¸$ÐBÐBñDô Dð 	Dr   )r"   Úvarsr8   Ú	functoolsÚ	lru_cache)rw   rp   r   rx   s   ` @@r   Úcaching_module_getattrr|   Å   sš   øøø€ ð& Œ<˜=Ò(Ð(Ð(Ð(ð,ð ,­$¨s©)¬)¯/ª/Ñ*;Ô*;ð ,ñ ,ô ,€Eàˆs‰uŒu€HåÔ˜ÑÔðDð Dð Dð Dð Dð Dñ ÔðDð Ðr   c                 ó0  ‡— ‰€t          j        t          | ¦  «        S ˆfd„}|                      ¦   «         D ]”\  }}d}dD ]f}||z   t	          ‰¦  «        v rPd}|D ]K} |||z   ¦  «        }||z   |_        d                     ||z   ¦  «        |_        t          ‰||z   |¦  «         ŒLŒg|s"t          d                     |¦  «        ¦  «        ‚Œ•d„ }	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   rr   s      €r   Úmethodz2define_aliases.<locals>.make_alias.<locals>.methodþ   s"   ø€ à&•7˜4 Ñ&Ô&¨Ð7°Ð7Ð7Ð7r   )rz   Úwrapsr€   )rr   r‚   rw   s   ` €r   Ú
make_aliasz"define_aliases.<locals>.make_aliasý   sA   øø€ Ý	Œ�  dÑ+Ô+Ñ	,Ô	,ð	8ð 	8ð 	8ð 	8ñ 
-Ô	,ð	8àˆr   F)Úget_Úset_TzAlias for `{}`.z)Neither getter nor setter exists for {!r}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ÐK¨1¯8ª8©:¬:ÐKÑKÔKÐLÐLr   Ú
_alias_mapz2Parent class already defines conflicting aliases: )rz   ÚpartialÚdefine_aliasesr8   ry   r"   r=   r%   Úsetattrr   r€   ÚNotImplementedErrorr�   )Úalias_drw   r„   rs   r‰   ÚexistsÚprefixrŠ   r‚   rŒ   Úpreexisting_aliasesÚconflictings    `          r   r�   r�   è   s¢  ø€ ð$ €{ÝÔ ¥°Ñ9Ô9Ð9ðð ð ð ð ð !Ÿš™œð Jð J‰ˆˆgØˆØ&ð 	9ð 	9ˆFØ˜‰}¥ S¡	¤	Ð)Ð)Ø�Ø$ð 9ð 9�EØ'˜Z¨°©Ñ6Ô6�FØ&,¨u¡n�F”OØ%6×%=Ò%=¸fÀt¹mÑ%LÔ%L�F”NÝ˜C ¨%¡°Ñ8Ô8Ð8Ð8øØð 	JÝØ;×BÒBÀ4ÑHÔHñJô Jð Jð	JðMð Mð Mõ " # |°RÑ8Ô8ÐØ*Ð*Ð+>Ñ?Ô?Ø,Ð,¨WÑ5Ô5ñ6€Kàð På!ØNÀÐNÐNñPô Pð 	Pà7Ð+Ð7¨wÐ7€C„NØ€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˜‘J”J ‘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<   )rr   ÚtakesÚgivens      r   Únargs_errorrŸ   S  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   ra   r<   )rr   Úkws     r   Úkwarg_errorr£   Y  sF   € õ �b�#ÑÔð Ý•$�r‘(”(‰^Œ^ˆÝ˜ÐJÐJÀRÐ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)rw   Úsubclss     r   r¦   r¦   j  sW   è è € à
€I€I€IØ×$Ò$Ñ&Ô&ð 0ð 0ˆÝ'¨Ñ/Ô/Ð/Ð/Ð/Ð/Ð/Ð/Ð/Ð/ð0ð 0r   c                 óü   — t          j        ¦   «         }t          j        d¦  «        D ]=}|€ n8t	          j        d|j                             dd¦  «        ¦  «        s n|j        }Œ>t          j
        | ||¦  «         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.).
    r   Nz-\A(matplotlib|mpl_toolkits)(\Z|\.(?!tests\.))r"   Ú )ÚsysÚ	_getframerb   rd   ÚreÚmatchÚ	f_globalsÚgetÚf_backÚwarningsÚwarn)ÚmessageÚcategoryÚframeÚ
stacklevels       r   Úwarn_externalr·   q  sˆ   € õ ŒM‰OŒO€EÝ”o aÑ(Ô(ð ð ˆ
Øˆ=àˆEÝŒxÐHàœ×+Ò+¨J¸Ñ;Ô;ñ=ô =ð 	ð ˆEØ”ˆˆÝ„M�'˜8 ZÑ0Ô0Ð0Ð0Ð0r   r   )r%   rz   rb   r¬   rª   r±   Údeprecationr   r   r   r   r   r	   r
   r   r   r   rF   rO   ri   rn   r|   r�   r›   rŸ   r£   r¦   r·   r'   r   r   ú<module>r¹      s¯  ðð
ð 
ð Ð Ð Ð Ø Ð Ð Ð Ø 	€	€	€	Ø 
€
€
€
Ø €€€ð"ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ð "ðð ð ð ð ñ ô ð ðL!)ð !)ð !)ðH 7;ð "ð "ð "ð "ð "ðB&ð &ð &ðRDð Dð Dð, ð  ð  ðF4ð 4ð 4ð 4ðn1ð 1ð 1ðh,ð ,ð ,ðLð Lð Lð"0ð 0ð 0ð1ð 1ð 1ð 1ð 1ð 1r   