o
    EOf                     @   s|   d dl mZmZ d dlZd dlZd dlmZ dgZe Z	ddddZ
dd	dZG d
d dZdddZdddddZdS )    )	Parameter	signatureN)import_module_deprecated)correct_modulec           
      C   s@  |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}tj|tdd |D ],}zttd|  d| |W   S  t y }	 z||d kr|	W Y d}	~	qqd}	~	ww dS )a  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``.
    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.z2` will be removed in SciPy 1.14.0, and the `scipy.z+` namespace will be removed in SciPy 2.0.0.   category
stacklevel)AttributeErrorgetattrr   warningswarnDeprecationWarning)
Zsub_packagemoduleZprivate_modulesallZ	attributer   Zcorrect_importattrmessagee r   6lib/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   callW   s   z'_deprecated.<locals>.wrap.<locals>.call)
isinstancetyper   r   RuntimeWarning	functoolswraps__doc__)r   r   r   r   )r   r   wrapP   s   
z_deprecated.<locals>.wrapr   )r   r   r'   r   r&   r   r   N   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)selfZcontentr   r   r   r   __init__f   s   
z_DeprecationHelperStr.__init__c                 C   s
   t | jS r)   )hashr*   )r,   r   r   r   __hash__j   s   
z_DeprecationHelperStr.__hash__c                 C   s$   | j |k}|rtj| jtdd |S )Nr   r	   )r*   r   r   r+   r   )r,   otherresr   r   r   __eq__m   s   

z_DeprecationHelperStr.__eq__N)__name__
__module____qualname__r%   r-   r/   r2   r   r   r   r   r(   b   s
    r(   c           
      C   s   | j  d| }|du rd| }n	d| d| d}|dur$|d| 7 }| j}d}d	}	 d| | }	|	|v rHd
}||	|t|	|< |d7 }nnq,|sX|||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   Nz`%s` is deprecated!`z` is deprecated, use `z
` instead!
r   FTZ__pyx_fuse_   )r3   Z__pyx_capi__popr(   )
r   Zroutine_namenew_namer   Zold_nameZdepdocdjZ	has_fusedZ
fused_namer   r   r   deprecate_cython_apiu   s(   !


r=   versionc                   s4    du r
d}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.
    Nz9Need to specify a version where signature will be changedc                    st   t g g  j D ]\}}|jtjkr | q|jtjkr(| qt	 fdd}|S )Nc                     s   t | t   }|dkr| i |S dd td | | | d  D }d|}tjd| d dtdd	 |tj|  d
i |S )Nr   c                 S   s   g | ]\}}| d | qS )=r   ).0nameargr   r   r   
<listcomp>   s    zi_deprecate_positional_args.<locals>._inner_deprecate_positional_args.<locals>.inner_f.<locals>.<listcomp>z, zYou are passing z^ as a positional argument. 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zipjoinr   r   r   update
parameters)r   r   
extra_argsZargs_msg)all_argsfkwonly_argssigr?   r   r   inner_f   s    

zU_deprecate_positional_args.<locals>._inner_deprecate_positional_args.<locals>.inner_f)
r   rI   itemskindr   ZPOSITIONAL_OR_KEYWORDappendZKEYWORD_ONLYr#   r$   )rL   rB   ZparamrO   r>   )rK   rL   rM   rN   r    _inner_deprecate_positional_args   s   
zD_deprecate_positional_args.<locals>._inner_deprecate_positional_args)
ValueError)funcr?   r   rS   r   r>   r   _deprecate_positional_args   s   &rV   )r   )NNr)   )inspectr   r   r#   r   	importlibr   __all__objectZ_NoValuer   r   r(   r=   rV   r   r   r   r   <module>   s    
@
@