o
    `^hp&                     @   s   d dl mZmZ d dlZd dlZd dlmZ d dlmZ dgZ	e
 Zddddd	ZdddZG dd dZdddZdddddddZdS )    )	Parameter	signatureN)import_module)FunctionDoc_deprecatedz1.16.0)correct_moduledep_versionc                 C   sF  |durd|  d| }nd|  }||vr*t d|  d| d| d|  d| dtt||d}|durFd| d	| d
|  d| d	}	n$d|  d| d| d|  d| d|  d| d| d| d|  d| d}	tj|	tdd |D ],}zttd|  d| |W   S  t y }
 z||d kr|
W Y d}
~
qtd}
~
ww dS )aM  Helper function for deprecating modules that are public but were
    intended to be private.

    Parameters
    ----------
    sub_package : str
        Subpackage the module belongs to eg. stats
    module : str
        Public but intended private module to deprecate
    private_modules : list
        Private replacement(s) for `module`; should contain the
        content of ``all``, possibly spread over several modules.
    all : list
        ``__all__`` belonging to `module`
    attribute : str
        The attribute in `module` being accessed
    correct_module : str, optional
        Module in `sub_package` that `attribute` should be imported from.
        Default is that `attribute` should be imported from ``scipy.sub_package``.
    dep_version : str, optional
        Version in which deprecated attributes will be removed.
    Nzscipy..z`scipy.z` has no attribute `z`; furthermore, `scipy.z3` is deprecated and will be removed in SciPy 2.0.0.zPlease import `z` from the `z` namespace; the `scipy.z=` namespace is deprecated and will be removed in SciPy 2.0.0.z&` is deprecated along with the `scipy.z` namespace. `scipy.z` will be removed in SciPy z, and the `scipy.z+` namespace will be removed in SciPy 2.0.0.   category
stacklevel)AttributeErrorgetattrr   warningswarnDeprecationWarning)sub_packagemoduleprivate_modulesall	attributer   r   correct_importattrmessagee r   T/home/air/shanriGPT/back/venv/lib/python3.10/site-packages/scipy/_lib/deprecation.py_sub_module_deprecation   s`   
 r      c                    s    fdd}|S )z2Deprecate a function by emitting a warning on use.c                    sJ   t  trtjd tdd  S t  fdd} j|_|S )NzTrying to deprecate class r    r   c                     s   t jtd  | i |S )Nr   )r   r   r   )argskwargs)funmsgr   r   r   callZ   s   z'_deprecated.<locals>.wrap.<locals>.call)
isinstancetyper   r   RuntimeWarning	functoolswraps__doc__)r#   r%   r$   r   )r#   r   wrapS   s   
z_deprecated.<locals>.wrapr   )r$   r   r-   r   r,   r   r   Q   s   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	_DeprecationHelperStrz3
    Helper class used by deprecate_cython_api
    c                 C   s   || _ || _d S N)_content_message)selfcontentr   r   r   r   __init__i   s   
z_DeprecationHelperStr.__init__c                 C   s
   t | jS r/   )hashr0   )r2   r   r   r   __hash__m   s   
z_DeprecationHelperStr.__hash__c                 C   s$   | j |k}|rtj| jtdd |S )Nr    r   )r0   r   r   r1   r   )r2   otherresr   r   r   __eq__p   s   

z_DeprecationHelperStr.__eq__N)__name__
__module____qualname__r+   r4   r6   r9   r   r   r   r   r.   e   s
    r.   c           
      C   s   | j  d| }|du rd| d}n	d| d| d}|dur&|d| 7 }| j}d}d	}	 d| | }	|	|v rJd
}||	|t|	|< |d7 }nnq.|sZ|||t||< dS dS )a>  
    Deprecate an exported cdef function in a public Cython API module.

    Only functions can be deprecated; typedefs etc. cannot.

    Parameters
    ----------
    module : module
        Public Cython API module (e.g. scipy.linalg.cython_blas).
    routine_name : str
        Name of the routine to deprecate. May also be a fused-type
        routine (in which case its all specializations are deprecated).
    new_name : str
        New name to include in the deprecation warning message
    message : str
        Additional text in the deprecation warning message

    Examples
    --------
    Usually, this function would be used in the top-level of the
    module ``.pyx`` file:

    >>> from scipy._lib.deprecation import deprecate_cython_api
    >>> import scipy.linalg.cython_blas as mod
    >>> deprecate_cython_api(mod, "dgemm", "dgemm_new",
    ...                      message="Deprecated in Scipy 1.5.0")
    >>> del deprecate_cython_api, mod

    After this, Cython modules that use the deprecated function emit a
    deprecation warning when they are imported.

    r	   N`z` is deprecated!z` is deprecated, use `z
` instead!
r   FT__pyx_fuse_   )r:   __pyx_capi__popr.   )
r   routine_namenew_namer   old_namedepdocdj	has_fused
fused_namer   r   r   deprecate_cython_apix   s(   !

rK    )versiondeprecated_argscustom_messagec                   sN   du r
d}t |du rt nt fdd}| dur%|| S |S )a  Decorator for methods that issues warnings for positional arguments.

    Using the keyword-only argument syntax in pep 3102, arguments after the
    * will issue a warning when passed as a positional argument.

    Parameters
    ----------
    func : callable, default=None
        Function to check arguments on.
    version : callable, default=None
        The version when positional arguments will result in error.
    deprecated_args : set of str, optional
        Arguments to deprecate - whether passed by position or keyword.
    custom_message : str, optional
        Custom message to add to deprecation warning and documentation.
    Nz9Need to specify a version where signature will be changedc                    s  t g g  j D ]\}}|jtjkr | q|jtjkr(| qfddt	 fdd}t
|}t }d d| d d}re|d	 d
 d7 }|7 }|d  |g7  < t|ddd }t||_|S )Nc                    s@    | }|rd| d d}| 7 }tj|tdd d S d S )Nz
Arguments zV are deprecated, whether passed by position or keyword. They will be removed in SciPy . r
   r   )intersectionr   r   r   )r"   rQ   r   rO   rN   rM   r   r   warn_deprecated_args   s   
zb_deprecate_positional_args.<locals>._inner_deprecate_positional_args.<locals>.warn_deprecated_argsc                     s   t | t   }|dkr| | i |S td |  }d|}tjd| d dtdd |tj|  | di |S )	Nr   z, z)You are passing as positional arguments: zE. Please change your invocation to use keyword arguments. From SciPy z@, passing these as positional arguments will result in an error.r    )r   r   )	lensetjoinr   r   r   updatezip
parameters)r!   r"   
extra_argskwonly_extra_argsargs_msg)all_argsrN   fkwonly_argssigrM   rS   r   r   inner_f   s    

zU_deprecate_positional_args.<locals>._inner_deprecate_positional_args.<locals>.inner_fz
.. deprecated:: z
    Use of argument(s) ``z6`` by position is deprecated; beginning in 
    SciPy z, these will be keyword-only. zArgument(s) ``zX`` are deprecated, whether passed by position or keyword; they will be removed in SciPy rP   zExtended Summaryr>   r@   )r   rY   itemskindr   POSITIONAL_OR_KEYWORDappendKEYWORD_ONLYr)   r*   r   rU   strsplitr+   )r^   nameparamra   docr[   
admonitionrR   )r]   r^   r_   r`   rS   r    _inner_deprecate_positional_args   s<   
	


zD_deprecate_positional_args.<locals>._inner_deprecate_positional_args)
ValueErrorrU   )funcrM   rN   rO   r$   rm   r   rR   r   _deprecate_positional_args   s   ?rp   )r    )NNr/   )inspectr   r   r)   r   	importlibr   scipy._lib._docscraper   __all__object_NoValuer   r   r.   rK   rp   r   r   r   r   <module>   s    
B
@