a
    a`                     @   s<   d dl Z d dlZdgZd	ddZG dd dZd
ddZdS )    N_deprecated   c                    s    fdd}|S )z2Deprecate a function by emitting a warning on use.c                    sH   t  tr$tjd tdd  S t  fdd}|_|S )NzTrying to deprecate class {!r}r   category
stacklevelc                     s   t jtd  | i |S )Nr   )warningswarnDeprecationWarning)argskwargs)funmsgr    f/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/scipy/_lib/deprecation.pycall   s    z'_deprecated.<locals>.wrap.<locals>.call)	
isinstancetyper   r   formatRuntimeWarning	functoolswraps__doc__)r   r   r   r   )r   r   wrap	   s    
z_deprecated.<locals>.wrapr   )r   r   r   r   r   r   r      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contentmessager   r   r   __init__   s    z_DeprecationHelperStr.__init__c                 C   s
   t | jS r   )hashr   )r   r   r   r   __hash__#   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__&   s    

z_DeprecationHelperStr.__eq__N)__name__
__module____qualname__r   r!   r#   r&   r   r   r   r   r      s   r   c           
      C   s   d | j|}|du r d| }nd||f }|dur@|d| 7 }| j}d}d}d ||}	|	|v rd	}||	|t|	|< |d
7 }qNqqN|s|||t||< 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.

    z{}.{}Nz`%s` is deprecated!z%`%s` is deprecated, use `%s` instead!
r   Fz__pyx_fuse_{}{}T   )r   r'   Z__pyx_capi__popr   )
moduleZroutine_namenew_namer    Zold_nameZdepdocdjZ	has_fusedZ
fused_namer   r   r   deprecate_cython_api.   s&    !

r1   )r   )NN)r   r   __all__r   r   r1   r   r   r   r   <module>   s
   
