a
    �ù»jê  ã                   @   sL   d dl Z d dlZd dlmZ dgZG dd„ dƒZdd„ Zdd„ Zd	d
„ ZdS )é    N)Ú	signatureÚ
deprecatedc                   @   s:   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )r   a¥  Decorator to mark a function or class as deprecated.

    Issue a warning when the function is called/the class is instantiated and
    adds a warning to the docstring.

    The optional extra argument will be appended to the deprecation message
    and the docstring. Note: to use this with the default value for extra, put
    in an empty of parentheses:

    Examples
    --------
    >>> from sklearn.utils import deprecated
    >>> deprecated()
    <sklearn.utils.deprecation.deprecated object at ...>
    >>> @deprecated()
    ... def some_function(): pass

    Parameters
    ----------
    extra : str, default=''
          To be added to the deprecation messages.
    Ú c                 C   s
   || _ d S )N)Úextra)Úselfr   © r   ú?E:\soccer\ml_env\Lib\site-packages\sklearn/utils/deprecation.pyÚ__init__&   s    zdeprecated.__init__c                 C   s6   t |tƒr|  |¡S t |tƒr(|  |¡S |  |¡S dS )zPCall method

        Parameters
        ----------
        obj : object
        N)Ú
isinstanceÚtypeÚ_decorate_classÚpropertyÚ_decorate_propertyÚ_decorate_fun)r   Úobjr   r   r   Ú__call__)   s
    



zdeprecated.__call__c                    sV   d|j  ‰ | jrˆ d| j 7 ‰ |j‰t|ƒ}‡ ‡fdd„}||_d|_ ˆ|_||_|S )NzClass %s is deprecatedú; %sc                    s8   t jˆ td� ˆtju r"t | ¡S ˆ| g|¢R i |¤ŽS ©N)Úcategory)ÚwarningsÚwarnÚFutureWarningÚobjectÚ__new__)ÚclsÚargsÚkwargs©ÚmsgÚnewr   r   ÚwrappedF   s    

z+deprecated._decorate_class.<locals>.wrappedr   )Ú__name__r   r   r   Zdeprecated_originalÚ__signature__)r   r   Úsigr    r   r   r   r   >   s    
zdeprecated._decorate_classc                    s@   dˆ j  ‰| jrˆd| j 7 ‰t ˆ ¡‡ ‡fdd„ƒ}ˆ |_|S )zDecorate function funzFunction %s is deprecatedr   c                     s   t jˆtd� ˆ | i |¤ŽS r   )r   r   r   ©r   r   ©Úfunr   r   r   r    ]   s    z)deprecated._decorate_fun.<locals>.wrapped)r!   r   Ú	functoolsÚwrapsÚ__wrapped__)r   r&   r    r   r%   r   r   V   s    
zdeprecated._decorate_func                    s(   | j ‰ tt ˆj¡‡ ‡fdd„ƒƒ}|S )Nc                     s   t jˆ td� ˆj| i |¤ŽS r   )r   r   r   Úfgetr$   ©r   Úpropr   r   r    k   s    z.deprecated._decorate_property.<locals>.wrapped)r   r   r'   r(   r*   )r   r,   r    r   r+   r   r   h   s
    
zdeprecated._decorate_propertyN)r   )	r!   Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   r   r   r   r      s   
c                 C   s4   t | dg ƒ}|du rg }dd dd„ |D ƒ¡v }|S )z>Helper to check if func is wrapped by our deprecated decoratorÚ__closure__Nr   r   c                 S   s   g | ]}t |jtƒr|j‘qS r   )r
   Úcell_contentsÚstr)Ú.0Úcr   r   r   Ú
<listcomp>z   ó    z"_is_deprecated.<locals>.<listcomp>)ÚgetattrÚjoin)ÚfuncZclosuresZis_deprecatedr   r   r   Ú_is_deprecatedt   s    ÿr:   c                 C   sL   | dur|durt dƒ‚| du r0|du r0t dƒ‚|durHt dt¡ |S | S )zKHelper to deprecate the `Xt` argument in favor of `X` in inverse_transform.Nz%Cannot use both X and Xt. Use X only.z(Missing required positional argument: X.z;Xt was renamed X in version 1.5 and will be removed in 1.7.)Ú	TypeErrorr   r   r   )ÚXZXtr   r   r   Ú"_deprecate_Xt_in_inverse_transform€   s    þr=   c                 C   s8   | dkr(t  dt¡ |dur$tdƒ‚| S |du r4dS |S )zCHelper to deprecate force_all_finite in favor of ensure_all_finite.r   zX'force_all_finite' was renamed to 'ensure_all_finite' in 1.6 and will be removed in 1.8.Nzb'force_all_finite' and 'ensure_all_finite' cannot be used together. Pass `ensure_all_finite` only.T)r   r   r   Ú
ValueError)Zforce_all_finiteZensure_all_finiter   r   r   Ú_deprecate_force_all_finite”   s    ýÿr?   )	r'   r   Úinspectr   Ú__all__r   r:   r=   r?   r   r   r   r   Ú<module>   s   i