o
    gM                     @   s   d Z ddlZddlZddlZddlZG dd deZeZ		ddddd	Zdddddddd
ddZ	dddddddd
ddZ
G dd dZdddZG dd dZe ZdddZdddZddddZejdd ZdS ) a  
Helper functions for deprecating parts of the Matplotlib API.

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

.. warning:

    This module is for internal use only.  Do not use it in your own code.
    We may change the API at any time with no warning.

    Nc                   @   s   e Zd ZdZdS )MatplotlibDeprecationWarninga  
    A class for issuing deprecation warnings for Matplotlib users.

    In light of the fact that Python builtin DeprecationWarnings are ignored
    by default as of Python 2.7 (see link below), this class was put in to
    allow for the signaling of deprecation, but via UserWarnings which are not
    ignored by default.

    https://docs.python.org/dev/whatsnew/2.7.html#the-future-for-python-2-x
    N)__name__
__module____qualname____doc__ r   r   Y/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/matplotlib/_api/deprecation.pyr      s    r    Fremovalc          	      C   s   |r	|rt dn	|rd| nd}|s0d|rdnd|rdnd  d	 |r'd
nd |r-dnd }|r4tnt}||t|||| |||d S )Nz5A pending deprecation cannot have a scheduled removalzin ztwo minor releases laterz
The %(name)s %(obj_type)sz' will be deprecated in a future versionz' was deprecated in Matplotlib %(since)sz  and will be removed %(removal)sr	   .z Use %(alternative)s instead.z %(addendum)s)funcnameobj_typesincer   alternativeaddendum)
ValueErrorPendingDeprecationWarningr   dict)	r   messager   r   pendingr   r   r   warning_clsr   r   r   _generate_deprecation_warning%   s>   

	

r   r   r   r   r   r   r   r   c          
   
   C   s4   t | |||||||d}ddlm}	 |	|td dS )a0  
    Display a standardized deprecation.

    Parameters
    ----------
    since : str
        The release at which this API became deprecated.

    message : str, optional
        Override the default deprecation message.  The ``%(since)s``,
        ``%(name)s``, ``%(alternative)s``, ``%(obj_type)s``, ``%(addendum)s``,
        and ``%(removal)s`` format specifiers will be replaced by the values
        of the respective arguments passed to this function.

    name : str, optional
        The name of the deprecated object.

    alternative : str, optional
        An alternative API that the user may use in place of the deprecated
        API.  The deprecation warning will tell the user about this alternative
        if provided.

    pending : bool, optional
        If True, uses a PendingDeprecationWarning instead of a
        DeprecationWarning.  Cannot be used together with *removal*.

    obj_type : str, optional
        The object type being deprecated.

    addendum : str, optional
        Additional text appended directly to the final message.

    removal : str, optional
        The expected removal version.  With the default (an empty string), a
        removal version is automatically computed from *since*.  Set to other
        Falsy values to not schedule a removal date.  Cannot be used together
        with *pending*.

    Examples
    --------
    Basic example::

        # To warn of the deprecation of "matplotlib.name_of_module"
        warn_deprecated('1.4.0', name='matplotlib.name_of_module',
                        obj_type='module')
    r
      )warn_external)categoryN)r   r	   r   r   )
r   r   r   r   r   r   r   r   warningr   r   r   r   warn_deprecatedA   s   1r   c          	         s    ||||||f fdd	}|S )a7	  
    Decorator to mark a function, a class, or a property as deprecated.

    When deprecating a classmethod, a staticmethod, or a property, the
    ``@deprecated`` decorator should go *under* ``@classmethod`` and
    ``@staticmethod`` (i.e., `deprecated` should directly decorate the
    underlying callable), but *over* ``@property``.

    When deprecating a class ``C`` intended to be used as a base class in a
    multiple inheritance hierarchy, ``C`` *must* define an ``__init__`` method
    (if ``C`` instead inherited its ``__init__`` from its own base class, then
    ``@deprecated`` would mess up ``__init__`` inheritance when installing its
    own (deprecation-emitting) ``C.__init__``).

    Parameters
    ----------
    since : str
        The release at which this API became deprecated.

    message : str, optional
        Override the default deprecation message.  The ``%(since)s``,
        ``%(name)s``, ``%(alternative)s``, ``%(obj_type)s``, ``%(addendum)s``,
        and ``%(removal)s`` format specifiers will be replaced by the values
        of the respective arguments passed to this function.

    name : str, optional
        The name used in the deprecation message; if not provided, the name
        is automatically determined from the deprecated object.

    alternative : str, optional
        An alternative API that the user may use in place of the deprecated
        API.  The deprecation warning will tell the user about this alternative
        if provided.

    pending : bool, optional
        If True, uses a PendingDeprecationWarning instead of a
        DeprecationWarning.  Cannot be used together with *removal*.

    obj_type : str, optional
        The object type being deprecated; by default, 'class' if decorating
        a class, 'attribute' if decorating a property, 'function' otherwise.

    addendum : str, optional
        Additional text appended directly to the final message.

    removal : str, optional
        The expected removal version.  With the default (an empty string), a
        removal version is automatically computed from *since*.  Set to other
        Falsy values to not schedule a removal date.  Cannot be used together
        with *pending*.

    Examples
    --------
    Basic example::

        @deprecated('1.4.0')
        def the_function_to_deprecate():
            pass
    c              	      sH  ddl m ttr#	d u rd	jpjj}fdd}n@ttfrMd	d p3jjj}G fdddt  fd	d}n	d u rSd
	pYjj}fdd}	
fddfdd}	t	
|p|dd}d}
d| d|
|vr|
nd d d  }|s|d7 }||	|S )Nr   )classpropertyclassc                    s4   z| _ W n	 ty   Y nw t j|  _ S N)r   AttributeError	functoolswraps__init__wrappernew_doc)objr   r   finalize   s   
z/deprecated.<locals>.deprecate.<locals>.finalize	attributec                       sH   e Zd Z fddZ fddZ fddZfddZ  ZS )	z;deprecated.<locals>.deprecate.<locals>._deprecated_propertyc                    s.   |d us|d urt | r  t ||S r"   )
isinstancesuper__get__)selfinstanceowner)	__class__r    emit_warningr   r   r/      s
   zCdeprecated.<locals>.deprecate.<locals>._deprecated_property.__get__c                    s   |d ur  t  ||S r"   )r.   __set__)r0   r1   valuer3   r4   r   r   r5      s   zCdeprecated.<locals>.deprecate.<locals>._deprecated_property.__set__c                    s   |d ur  t  |S r"   )r.   
__delete__)r0   r1   r7   r   r   r8      s   zFdeprecated.<locals>.deprecate.<locals>._deprecated_property.__delete__c                    s    dkr| d S d S )Nz<lambda>r   )r0   r2   set_namer   r   r   __set_name__   s   zHdeprecated.<locals>.deprecate.<locals>._deprecated_property.__set_name__)r   r   r   r/   r5   r8   r;   __classcell__r   )r    r4   r   )r3   r   _deprecated_property   s
    r=   c                    s    j jj|dS )N)fgetfsetfdeldoc)r>   r?   r@   )_r)   )r=   r*   r   r   r+      s   functionc                    s   t  | } || _| S r"   )r$   r%   r   r'   )r   r   r   r+      s   c                
      s   t  d d S )Nr   )r   r   )r   r   r   r   r   r   r   r   r   r   r4      s
   
z3deprecated.<locals>.deprecate.<locals>.emit_warningc                     s      | i |S r"   r   argskwargs)r4   r   r   r   r(      s   z.deprecated.<locals>.deprecate.<locals>.wrapperr	   
z
Notes
-----z[*Deprecated*] z
.. deprecated:: z
   z\ )matplotlib._apir    r-   typer&   r   r   propertyr>   inspectcleandocstrip)r*   r   r   r   r   r   r   old_docr+   r(   notes_headerr)   r   r   )r=   r   r   r    r4   r   r   r   r*   r   r   r   	deprecate   sF   



zdeprecated.<locals>.deprecater   )	r   r   r   r   r   r   r   r   rQ   r   rP   r   
deprecatedy   s   >XrR   c                   @   s    e Zd ZdZdd Zdd ZdS )deprecate_privatize_attributea  
    Helper to deprecate public access to an attribute.

    This helper should only be used at class scope, as follows::

        class Foo:
            attr = _deprecate_privatize_attribute(*args, **kwargs)

    where *all* parameters are forwarded to `deprecated`.  This form makes
    ``attr`` a property which forwards access to ``self._attr`` (same name but
    with a leading underscore), with a deprecation warning.  Note that the
    attribute name is derived from *the name this helper is assigned to*.
    c                 O   s   t |i || _d S r"   )rR   
deprecator)r0   rE   rF   r   r   r   r&   !  s   z&deprecate_privatize_attribute.__init__c                    s&   t | | jt fdd d d S )Nc                    s   t | d  S )NrB   )getattrr0   r:   r   r   <lambda>&  s    z<deprecate_privatize_attribute.__set_name__.<locals>.<lambda>r:   )setattrrT   rJ   )r0   r2   r   r   r:   r   r;   $  s   
z*deprecate_privatize_attribute.__set_name__N)r   r   r   r   r&   r;   r   r   r   r   rS     s    rS   c                    s    du rt tS t }|jvs"J dd j d|jv s3J dd j dt   fdd}|S )a  
    Decorator indicating that parameter *old* of *func* is renamed to *new*.

    The actual implementation of *func* should use *new*, not *old*.  If *old*
    is passed to *func*, a DeprecationWarning is emitted, and its value is
    used, even if *new* is also passed by keyword (this is to simplify pyplot
    wrapper functions, which always pass *new* explicitly to the Axes method).
    If *new* is also passed but positionally, a TypeError will be raised by the
    underlying function during argument binding.

    Examples
    --------
    ::

        @_api.rename_parameter("3.1", "bad_name", "good_name")
        def func(good_name): ...
    NMatplotlib internal error: z cannot be a parameter for () must be a parameter for c                     sL   |v rt dd j dd d	d ||<  | i |S )NzThe z parameter of z() has been renamed z since Matplotlib z7; support for the old name will be dropped %(removal)s.r   )r   r   poprD   r   newoldr   r   r   r(   G  s   z!rename_parameter.<locals>.wrapper)r$   partialrename_parameterrK   	signature
parametersr   r%   )r   r`   r_   r   rc   r(   r   r^   r   rb   )  s    
rb   c                   @   s   e Zd Zdd ZdS )_deprecated_parameter_classc                 C      dS )Nz<deprecated parameter>r   rV   r   r   r   __repr__Z  s   z$_deprecated_parameter_class.__repr__N)r   r   r   rg   r   r   r   r   re   Y  s    re   c              
      s   du rt jtfi S ttdd j D djv rPj j}|tj	j
u |tj	ju sOsOjfddj D d _nd sbJ dd	j d
dd t  f	dd}|S )aI  
    Decorator indicating that parameter *name* of *func* is being deprecated.

    The actual implementation of *func* should keep the *name* parameter in its
    signature, or accept a ``**kwargs`` argument (through which *name* would be
    passed).

    Parameters that come after the deprecated parameter effectively become
    keyword-only (as they cannot be passed positionally without triggering the
    DeprecationWarning on the deprecated parameter), and should be marked as
    such after the deprecation period has passed and the deprecated parameter
    is removed.

    Parameters other than *since*, *name*, and *func* are keyword-only and
    forwarded to `.warn_deprecated`.

    Examples
    --------
    ::

        @_api.delete_parameter("3.1", "unused")
        def func(used_arg, other_arg, unused, more_args): ...
    Nc                 s   s$    | ]}|j tjjkr|jV  qd S r"   )kindrK   	ParameterVAR_KEYWORDr   .0paramr   r   r   	<genexpr>  s    z#delete_parameter.<locals>.<genexpr>c                    s&   g | ]}|j  kr|jtd n|qS ))default)r   replace_deprecated_parameterrk   r:   r   r   
<listcomp>  s    
z$delete_parameter.<locals>.<listcomp>rd   FrY   r[   rZ   r   c                     s   j | i |j}r|rtdj dd nEr/|r/tdj dd n2tfdd||i fD radd}tftd	j d
 rZ d | n|d | i |S )Nz#Additional positional arguments to zS() are deprecated since %(since)s and support for them will be removed %(removal)s.r\   z Additional keyword arguments to c                 3   s$    | ]} |v o|  t kV  qd S r"   )rq   )rl   dr:   r   r   rn     s    z4delete_parameter.<locals>.wrapper.<locals>.<genexpr>zIf any parameter follows z5, they should be passed as keyword, not positionally.parameter of rZ    )r   r   r   )bind	argumentsgetr   r   anyrepr)
inner_argsinner_kwargsrx   deprecation_addendum	r   r   
is_varargsis_varkwargsrF   kwargs_namer   rc   r   r   r   r(     s:   
z!delete_parameter.<locals>.wrapper)r$   ra   delete_parameterrK   rc   nextrd   valuesrh   ri   VAR_POSITIONALrj   rp   __signature__r   r]   r%   )r   r   r   rF   rh   r(   r   r   r   r   a  s2   

r   c                    s   du rt tS ttjjtjj jv r%j j	ks1J ddj
 dg j}fdd||d D j fddj D d_t fd	d
}|S )z
    Decorator indicating that passing parameter *name* (or any of the following
    ones) positionally to *func* is being deprecated.
    NrY   z/ must be a positional-or-keyword parameter for rZ   c                    s    g | ]}j | j kr|qS r   )rd   rh   )rl   r   )POKrc   r   r   rr     s    z%make_keyword_only.<locals>.<listcomp>c                    s&   g | ]}|j v r|j d n|qS ))rh   )r   rp   rk   )KWOkwonlyr   r   rr     s    rs   c                     sF   g  j j}t| |krtdd j dd  | i |S )NzPassing the %(name)s %(obj_type)s positionally is deprecated since Matplotlib %(since)s; the parameter will become keyword-only %(removal)s.ru   rZ   )r   r   r   )r   rd   indexlenr   r   )rE   rF   idx)r   r   r   r   r   r(     s   z"make_keyword_only.<locals>.wrapper)r$   ra   make_keyword_onlyrK   rc   ri   POSITIONAL_OR_KEYWORDKEYWORD_ONLYrd   rh   r   r   rp   r   r   r%   )r   r   r   namesr(   r   )r   r   r   r   r   rc   r   r   r     s&   


"r   )allow_emptyc          	      K   s   dd }dd }| j }t||}t|t|rt|tr| n| |}||krI|r;tt|dddd|jj|jjfvrItd
i |dd	| |S dS )a  
    Return ``obj.method`` with a deprecation if it was overridden, else None.

    Parameters
    ----------
    method
        An unbound method, i.e. an expression of the form
        ``Class.method_name``.  Remember that within the body of a method, one
        can always use ``__class__`` to refer to the class that is currently
        being defined.
    obj
        Either an object of the class where *method* is defined, or a subclass
        of that class.
    allow_empty : bool, default: False
        Whether to allow overrides by "empty" methods without emitting a
        warning.
    **kwargs
        Additional parameters passed to `warn_deprecated` to generate the
        deprecation warning; must at least include the "since" key.
    c                   S   s   d S r"   r   r   r   r   r   empty      z(deprecate_method_override.<locals>.emptyc                   S   rf   )rA   Nr   r   r   r   r   empty_with_docstring  r   z7deprecate_method_override.<locals>.empty_with_docstring__code__Nco_codemethod)r   r   r   )r   rU   r-   rI   r/   r   r   r   )	r   r*   r   rF   r   r   r   bound_child
bound_baser   r   r   deprecate_method_override  s.   
r   c                   c   sB    t   t dt d V  W d    d S 1 sw   Y  d S )Nignore)warningscatch_warningssimplefilterr   r   r   r   r   'suppress_matplotlib_deprecation_warning  s
   
"r   )r	   r	   r	   Fr	   r	   r"   )r   
contextlibr$   rK   r   UserWarningr   mplDeprecationr   r   rR   rS   rb   re   rq   r   r   r   contextmanagerr   r   r   r   r   <module>   s8    8 
0

S(*