
    {Kg9                     :    d dl mZmZ d dlmZ  G d d      Zd Zy)    )update_wrapperwraps)
MethodTypec                   $    e Zd ZdZd Zd ZddZy)_AvailableIfDescriptorav  Implements a conditional property using the descriptor protocol.

    Using this class to create a decorator will raise an ``AttributeError``
    if check(self) returns a falsey value. Note that if check raises an error
    this will also result in hasattr returning false.

    See https://docs.python.org/3/howto/descriptor.html for an explanation of
    descriptors.
    c                 F    || _         || _        || _        t        | |       y N)fncheckattribute_namer   )selfr
   r   r   s       _/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/sklearn/utils/_available_if.py__init__z_AvailableIfDescriptor.__init__   s$    
, 	tR     c                     dt        |j                         dt        | j                         }	 | j                  |      }|st        |      y # t        $ r}t        |      |d }~ww xY w)NzThis z has no attribute )repr__name__r   r   	ExceptionAttributeError)r   objownerattr_err_msgcheck_resultes         r   _checkz_AvailableIfDescriptor._check   st    D());DATAT<U;VW 		6::c?L  ..   	6 .A5	6s   A 	A)A$$A)Nc                      |+ j                  |       t         j                  |      }|S t         j                         fd       }|S )Nr   c                  T    j                  | d           j                  | i |S )Nr   r   )r   r
   )argskwargsr   r   s     r   outz+_AvailableIfDescriptor.__get__.<locals>.out.   s-    DG51tww///r   )r   r   r
   r   )r   r   r   r!   s   ` ` r   __get__z_AvailableIfDescriptor.__get__$   sT    ? KK5K)TWWc*C 
 477^0 0 
r   r	   )r   
__module____qualname____doc__r   r   r"    r   r   r   r      s    !
/r   r   c                       fdS )a  An attribute that is available only if check returns a truthy value.

    Parameters
    ----------
    check : callable
        When passed the object with the decorated method, this should return
        a truthy value if the attribute is available, and either return False
        or raise an AttributeError if not available.

    Returns
    -------
    callable
        Callable makes the decorated method available if `check` returns
        a truthy value, otherwise the decorated method is unavailable.

    Examples
    --------
    >>> from sklearn.utils.metaestimators import available_if
    >>> class HelloIfEven:
    ...    def __init__(self, x):
    ...        self.x = x
    ...
    ...    def _x_is_even(self):
    ...        return self.x % 2 == 0
    ...
    ...    @available_if(_x_is_even)
    ...    def say_hello(self):
    ...        print("Hello")
    ...
    >>> obj = HelloIfEven(1)
    >>> hasattr(obj, "say_hello")
    False
    >>> obj.x = 2
    >>> hasattr(obj, "say_hello")
    True
    >>> obj.say_hello()
    Hello
    c                 4    t        | | j                        S )N)r   )r   r   )r
   r   s    r   <lambda>zavailable_if.<locals>.<lambda>]   s    ,Rr{{Sr   r&   )r   s   `r   available_ifr*   6   s    N TSr   N)	functoolsr   r   typesr   r   r*   r&   r   r   <module>r-      s    + . .b'Tr   