
    t]e                         d Z ddlmZmZ ddlmZ ddlZddlmZ  eej	                  Z
e
 ed          k     r G d d          Zd	 ZdS dd
lmZ dS )ziThis is a copy of sklearn/utils/_available_if.py. It can be removed when
we support scikit-learn >= 1.1.
    )update_wrapperwraps)
MethodTypeN)parse_versionz1.1c                        e Zd ZdZd ZddZdS )_AvailableIfDescriptora  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                 P    || _         || _        || _        t          | |           d S N)fncheckattribute_namer   )selfr   r   r   s       <lib/python3.11/site-packages/imblearn/utils/_available_if.py__init__z_AvailableIfDescriptor.__init__   s0    DGDJ"0D 4$$$$$    Nc                      t          d|j        d j                  |-                     |          st	           j        |          }n t           j                   fd            }|S )NzThis z has no attribute c                  X                         | d                   s j        | i |S )Nr   )r   r   )argskwargsattr_errr   s     r   outz+_AvailableIfDescriptor.__get__.<locals>.out1   s7    ::d1g.. '&"47D3F333r   )AttributeError__name__r   r   r   r   r   )r   objownerr   r   s   `   @r   __get__z_AvailableIfDescriptor.__get__#   s    %SSSD<OSS H  zz# #"N #..
 tw4 4 4 4 4  4
 Jr   r
   )r   
__module____qualname____doc__r   r    r   r   r   r      sA        	 		% 	% 	%	 	 	 	 	 	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                 2    t          | | j                  S )N)r   )r   r   )r   r   s    r   <lambda>zavailable_if.<locals>.<lambda>`   s    0U2;WWW r   r    )r   s   `r   available_ifr$   9   s    N XWWWWr   )r$   )r   	functoolsr   r   typesr   sklearnsklearn.utilsr   __version__sklearn_versionr   r$   sklearn.utils.metaestimatorsr    r   r   <module>r,      s    
 , + + + + + + +        ' ' ' ' ' '- 344]]5))))' ' ' ' ' ' ' 'R'X 'X 'X 'X 'XT :9999999r   