o
    g                     @   s   d 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 dZdd Zd	d
ddZdd Zdd Zd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                   @   s.   e Zd ZdZd	ddZdd Zed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                 C   s4   || _ |d us|d urtd|| _|| _|| _d S )Nz#classproperty only implements fget.)_fget
ValueErrorfsetfdel_doc)selffgetr   r   doc r   V/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/matplotlib/_api/__init__.py__init__+   s   
zclassproperty.__init__c                 C   s
   |  |S Nr   )r   instanceownerr   r   r   __get__4   s   
zclassproperty.__get__c                 C   s   | j S r   r   )r   r   r   r   r   7   s   zclassproperty.fget)NNN)__name__
__module____qualname____doc__r   r   propertyr   r   r   r   r   r      s    
	r   c              
      s   | }t d t|t r|fn|du r fn
t fdd|D } fdd}| D ]B\}}t||slg t||}d|v rH|d |d td|t	|dkrad	
|dd
 d |d
  n|d |t |q*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   s     | ]}|d u r
 n|V  qd S r   r   ).0tp	none_typer   r   	<genexpr>O   s    z#check_isinstance.<locals>.<genexpr>c                    s.   |  u rdS | j dkr| jS | j  d| j S )NNonebuiltins.)r   r   )r#   r$   r   r   	type_nameQ   s
   z#check_isinstance.<locals>.type_namer'   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typesr*   kvnamesr   r$   r   check_isinstance@   s0   



r>   T)_print_supported_valuesc                K   s\   | }|  D ]%\}}||vr+|r"t|d| ddtt| t|d| qd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 is not a valid value for z; supported values are r+   N)r0   r   r7   r1   repr)_valuesr?   r9   valueskeyvalr   r   r   check_in_listd   s   rE   c              
      s   | }|  D ]I\}}|j}t|t|ks!tdd t||D rOttddd t D  d	 fdd|D }t
|dt| d| d	|j d
q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                 s   s     | ]\}}||d fvV  qd S r   r   )r"   tsr   r   r   r&      s
    

zcheck_shape.<locals>.<genexpr>MNLIJKLHc                 s   s    | ]}d | V  qdS )DNr   )r"   ir   r   r   r&      s    r+   c                 3   s(    | ]}|d urt |nt V  qd S r   )strnext)r"   n
dim_labelsr   r   r&      s    
z	 must be zD with shape (z). Your input has shape r)   N)r0   shaper6   anyzipiter	itertoolschaincountr7   r   )_shaper9   target_shaper;   r<   
data_shape
text_shaper   rN   r   check_shape   s,   r[   c                 K   s`   | }t |dkrtd| \\}}z|| W S  ty/   td||dtt|d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 {}r+   N)r6   r   r0   KeyErrorr5   r7   r1   r@   )_mappingr9   mappingr;   r<   r   r   r   check_getitem   s   

r_   c                 C   sV   t  }tdD ]}|du r ntd|jdds n|j}q	t	
| || 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	_getframerT   rV   rematch	f_globalsgetf_backwarningswarn)messagecategoryframe
stacklevelr   r   r   warn_external   s   	rn   r   )r    rT   rc   ra   rh   deprecationr   r   r   r   r   r   r	   r
   r   r   r>   rE   r[   r_   rn   r   r   r   r   <module>   s    ,&$!'