o
    tBh                     @   s"  d dl Zd dlZd dlZd dlZd dlmZ d dlmZ G dd dZG dd dZ	ej
dd	d
 ZG dd dZG dd deZG dd deZG dd dZG dd dZG dd dZej
ddd ZG dd dZdd Zdd Zdd  Zej
dd!d" Zd#d$ Zd%d& ZdS )'    N)if_delegate_has_method)available_ifc                   @   s   e Zd Zdd ZdS )Prefixc                 C      d S N selfr   r   ~/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/sklearn/utils/tests/test_metaestimators.pyfunc      zPrefix.funcN)__name__
__module____qualname__r   r   r   r   r
   r      s    r   c                   @   s(   e Zd ZdZe Zedddd ZdS )MockMetaEstimatorzThis is a mock meta estimatora_prefixdelegatec                 C   s   dS )!This is a mock delegated functionNr   r   r   r   r
   r      s   zMockMetaEstimator.funcN)r   r   r   __doc__r   r   r   r   r   r   r   r
   r      s
    r   z,ignore:if_delegate_has_method was deprecatedc                   C   F   dt tjd jv sJ dt tjjv sJ dt t jjv s!J d S )Nr   r   )strr   __dict__r   r   r   r   r   r
   test_delegated_docstring   s
   

r   c                   @   s,   e Zd ZdZd	ddZedddd ZdS )
MetaEstzA mock meta estimatorNc                 C      || _ || _d S r   sub_estbetter_sub_est)r	   r   r   r   r   r
   __init__'      
zMetaEst.__init__r   r   c                 C   r   r   r   r   r   r   r
   predict+      zMetaEst.predictr   )r   r   r   r   r   r   r!   r   r   r   r
   r   $   s
    
r   c                   @   s"   e Zd ZdZedddd ZdS )MetaEstTestTuplez:A mock meta estimator to test passing a tuple of delegatesr   r   c                 C   r   r   r   r   r   r   r
   r!   3   r"   zMetaEstTestTuple.predictNr   r   r   r   r   r!   r   r   r   r
   r#   0   s    r#   c                   @   s&   e Zd ZdZeddgddd ZdS )MetaEstTestListz9A mock meta estimator to test passing a list of delegatesr   r   r   c                 C   r   r   r   r   r   r   r
   r!   ;   r"   zMetaEstTestList.predictNr$   r   r   r   r
   r%   8   s    r%   c                   @   s   e Zd ZdZdd ZdS )
HasPredictz(A mock sub-estimator with predict methodc                 C   r   r   r   r   r   r   r
   r!   C   r   zHasPredict.predictN)r   r   r   r   r!   r   r   r   r
   r&   @   s    r&   c                   @   s   e Zd ZdZdS )HasNoPredictz+A mock sub-estimator with no predict methodN)r   r   r   r   r   r   r   r
   r'   G   s    r'   c                   @   s    e Zd ZdZejdejdZdS )HasPredictAsNDArrayz3A mock sub-estimator where predict is a NumPy array)
      )dtypeN)r   r   r   r   nponesint64r!   r   r   r   r
   r(   M   s    r(   c                   C   s   t tt ds
J t tt drJ t tt t dr J t tt t ds,J t tt t dr8J t tt t drDJ t tt t dsPJ d S )Nr!   )hasattrr   r&   r'   r#   r%   r   r   r   r
   test_if_delegate_has_methodS   s   r0   c                   @   s.   e Zd ZdZdddZedd dd	 Zd
S )AvailableParameterEstimatorzGThis estimator's `available` parameter toggles the presence of a methodT   c                 C   r   r   	availablereturn_value)r	   r4   r5   r   r   r
   r   a   r    z$AvailableParameterEstimator.__init__c                 C      | j S r   r4   estr   r   r
   <lambda>e   s    z$AvailableParameterEstimator.<lambda>c                 C   r6   )$This is a mock available_if function)r5   r   r   r   r
   available_funce   s   z*AvailableParameterEstimator.available_funcN)Tr2   )r   r   r   r   r   r   r<   r   r   r   r
   r1   ^   s
    

r1   c                   C   r   )Nr;   r<   )r   r1   r   r   r<   r   r   r   r
   test_available_if_docstringk   s   


r=   c                   C   s(   t t dsJ t tdddrJ d S )Nr<   Fr7   )r/   r1   r   r   r   r
   test_available_ifw   s   r>   c                  C   sX   t  } t |  t dd} tjtdd t |  W d    d S 1 s%w   Y  d S )NFr7   zDThis 'AvailableParameterEstimator' has no attribute 'available_func'match)r1   r<   pytestraisesAttributeErrorr8   r   r   r
    test_available_if_unbound_method|   s   

"rD   c                  C   s   t t } t| dsJ dS )zCheck that we can check for an attribute that is a NumPy array.

    This is a non-regression test for:
    https://github.com/scikit-learn/scikit-learn/issues/21144
    r!   N)r   r(   r/   )	estimatorr   r   r
   'test_if_delegate_has_method_numpy_array   s   
rF   c                  C   s   t   t dt tdd} W d   n1 sw   Y  tjtdd ttt	 d W d   dS 1 s:w   Y  dS )z7Check the deprecation warning of if_delegate_has_methoderrorr!   r   Nz%if_delegate_has_method was deprecatedr?   )
warningscatch_warningssimplefilterFutureWarningr   rA   warnsr/   r   r&   )_r   r   r
   &test_if_delegate_has_method_deprecated   s   
"rN   c                  C   s8   d} t d| d}t|j}t|}| | ksJ dS )zYCheck that available_if methods can be pickled.

    Non-regression test for #21344.
    r)   Tr3   N)r1   pickledumpsr<   loads)r5   r9   pickled_bytesunpickled_funcr   r   r
   (test_available_if_methods_can_be_pickled   s
   
rT   )numpyr,   rA   rH   rO   sklearn.utils.metaestimatorsr   r   r   r   markfilterwarningsr   r   r#   r%   r&   r'   r(   r0   r1   r=   r>   rD   rF   rN   rT   r   r   r   r
   <module>   s4    







