
    sgB                     L    d dl Z d dlZd dlmZ dgZ G d d      Zd Zd Zd Zy)    N)	signature
deprecatedc                   0    e Zd ZdZddZd Zd Zd Zd Zy)	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                     || _         y )N)extra)selfr   s     L/var/www/html/venv/lib/python3.12/site-packages/sklearn/utils/deprecation.py__init__zdeprecated.__init__&   s	    
    c                     t        |t              r| j                  |      S t        |t              r| j	                  |      S | j                  |      S )zPCall method

        Parameters
        ----------
        obj : object
        )
isinstancetype_decorate_classproperty_decorate_property_decorate_fun)r   objs     r	   __call__zdeprecated.__call__)   sM     c4 '',,X& **3//%%c**r   c                     d|j                   z  | j                  rd| j                  z  z  |j                  t        |      }fd}||_        d|_         |_        ||_        |S )NzClass %s is deprecated; %sc                     t        j                  t               t        j                  u rt        j	                  |       S  | g|i |S N)category)warningswarnFutureWarningobject__new__)clsargskwargsmsgnews      r	   wrappedz+deprecated._decorate_class.<locals>.wrappedF   sA    MM#6fnn$~~c**s,T,V,,r   r   )__name__r   r   r   deprecated_original__signature__)r   r   sigr$   r"   r#   s       @@r	   r   zdeprecated._decorate_class>   sh    &5::6DJJ&&Ckkn	- $&)#
r   c                     dj                   z  | j                  rd| j                  z  z  t        j                        fd       }|_        |S )zDecorate function funzFunction %s is deprecatedr   c                  J    t        j                  t                | i |S r   )r   r   r   )r    r!   funr"   s     r	   r$   z)deprecated._decorate_fun.<locals>.wrapped]   s!    MM#6'''r   )r%   r   	functoolswraps__wrapped__)r   r+   r$   r"   s    ` @r	   r   zdeprecated._decorate_funV   sW     *CLL8::6DJJ&&C			( 
	( "r   c                     | j                   t        t        j                  j                        fd              }|S )Nc                  ^    t        j                  t                j                  | i |S r   )r   r   r   fget)r    r!   r"   props     r	   r$   z.deprecated._decorate_property.<locals>.wrappedk   s)     MM#6499d-f--r   )r   r   r,   r-   r1   )r   r2   r$   r"   s    ` @r	   r   zdeprecated._decorate_propertyh   s:    jj			#	. 
$ 
	. r   N) )	r%   
__module____qualname____doc__r
   r   r   r   r    r   r	   r   r      s     4+*0$	r   c           
          t        | dg       }|g }ddj                  |D cg c])  }t        |j                  t              s|j                  + c}      v }|S c c}w )z>Helper to check if func is wrapped by our deprecated decorator__closure__r   r3   )getattrjoinr   cell_contentsstr)funcclosurescis_deprecateds       r	   _is_deprecatedrB   t   s]    t]B/H BGG"*OQj#.NO% M  	Ps   A
A
c                 ~    | |t        d      | |t        d      |t        j                  dt               |S | S )zKHelper to deprecate the `Xt` argument in favor of `X` in inverse_transform.z%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   )XXts     r	   "_deprecate_Xt_in_inverse_transformrG      sO    }?@@yRZBCC	~I	
 	Hr   c                 h    | dk7  r)t        j                  dt               |t        d      | S |y|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.zb'force_all_finite' and 'ensure_all_finite' cannot be used together. Pass `ensure_all_finite` only.T)r   r   r   
ValueError)force_all_finiteensure_all_finites     r	   _deprecate_force_all_finiterL      sO    <'	
 (1 
   r   )	r,   r   inspectr   __all__r   rB   rG   rL   r7   r   r	   <module>rO      s3      .f fR(r   