
    0Ph                        d dl Z d dlmZ d dlmZ d dlZd dlmZmZ d dl	m
Z
mZmZ  ej        d          Zd Zd Zd d	Zd!d
ee         defdZej                            d e                      d             Zej                            d e                      d             Zedk    r#d dlZd dlZ ej        d          Ze                    dd           e                                Ze                     ej!                  Z"ej!        #                    d          Z$ e%e$          dk    r  e j&        de$d                   r	e$d         Z'ndZ' e( ee"d         e'                    e"d<   e"d         r/ ee"ej!                  Z) e*e)            ej+        d           dS  e*d,                    ej!                             dS dS )"    N)	signature)Optional)enable_halving_search_cvenable_iterative_imputer)all_displaysall_estimatorsall_functionsznumpydoc.validatec               #     K   t                      } t                      }| |z   D ]\  }}|                    d          rg }t          |          D ]b}|                    d          rt	          ||          }t          |d          st          |t                    r|                    |           c|                    d            t          |t                    D ]}||fV  	d S )N___call__)key)r   r   
startswithdirgetattrhasattr
isinstancepropertyappendsortedstr)
estimatorsdisplaysnameKlassmethods
method_objmethods          ]/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/tests/test_docstrings.pyget_all_methodsr      s     !!J~~H!H,    e??3 	JJ 	% 	%Ds##  --Jz:.. %*Z2R2R %t$$$tW#... 	  	 F-	        c               #   n   K   t                      } | D ]!\  }}d|j        vr|j         d|j         V  "d S )Nzutils.fixes.)r	   
__module____name__)	functionsr   funcs      r   get_all_functions_namesr'   %   sX      I 7 74//_66t}666667 7r    c              #      K   | D ]E\  }}|dv r
|dv r*|(|&t          ||          }t          |t                    r8||dv r?||fV  FdS )za
    Ignore some errors based on the method type.

    These rules are specific for scikit-learn.)RT02GL01GL02)PR02GL08N)EX01SA01ES01)r   r   r   )errorsr   r   codemessager   s         r   filter_errorsr4   -   s      
   % %g +++ ###(9f>P //J*h//  $*B"B"BGmK% %r    r   returnc                    |+t          |d          rd}n|t          d          t          |Nt          ||          }	 t	          t          |                    }n# t          $ r d}Y nw xY w|j        dz   |z   }nd}|}dd                    t	          | d                   ||z   | d	         d
d                    d | d         D                       g          z   }|S )a~  Pretty print original docstring and the obtained errors

    Parameters
    ----------
    res : dict
        result of numpydoc.validate.validate
    Klass : {Estimator, Display, None}
        estimator object or None
    method : str
        if estimator is not None, either the method name or None.

    Returns
    -------
    str
       String representation of the error.
    N__init__z0At least one of Klass, method should be providedzM
Parsing of the method signature failed, possibly because this is a property.r"    z

file	docstringz# Errors
c              3   H   K   | ]\  }}d                      ||          V  dS )z	 - {}: {}N)format).0r2   r3   s      r   	<genexpr>zrepr_errors.<locals>.<genexpr>   sG        6CdG""411     r    r1   )	r   
ValueErrorNotImplementedErrorr   r   r   	TypeErrorr$   join)resr   r   objobj_signatureobj_namemsgs          r   repr_errorsrI   Z   s,   " ~5*%% 	&FF]OPPP%%eV$$		#//MM 	 	 	7 MM	 >C'&0
6;;F}$II  GJ8}    	

 
 
C Js   A A-,A-function_namec                     t                               |           }t          t          |d         d                    |d<   |d         r#t	          |d|            }t          |          dS )z)Check function docstrings using numpydoc.r1   functionr   zTested function: N)numpydoc_validationvalidatelistr4   rI   r@   )rJ   requestrD   rH   s       r   test_function_docstringrR      sv     
&
&}
5
5Cs8}ZHHHIICM
8} #&I-&I&IJJJoo r    zKlass, methodc                 R   | j         }|| j        g}||                    |           d                    |          }t                              |          }t          t          |d         ||                     |d<   |d         r t          || |          }t          |          d S )Nr"   r1   )r   )
r#   r$   r   rC   rN   rO   rP   r4   rI   r@   )r   r   rQ   base_import_pathimport_pathrD   rH   s          r   test_docstringrV      s    '#U^4K6"""((;''K

&
&{
3
3Cs8}fEJJJKKCM
8} #uf--oo r    __main__z!Validate docstring with numpydoc.)descriptionrU   zImport path to validate)helpr"      z(?:[A-Z][a-z]*)+r1   rM      z#All docstring checks passed for {}!)N)NN)-reinspectr   typingr   pytestsklearn.experimentalr   r   sklearn.utils.discoveryr   r   r	   importorskiprN   r   r'   r4   r   rI   markparametrizerR   rV   r$   argparsesysArgumentParserparseradd_argument
parse_argsargsrO   rU   rD   splitimport_path_sectionslenmatchr   rP   rH   printexitr=    r    r   <module>ru      s   				                     P O O O O O O O O O)f)*=>>      (7 7 7* * * *Z4 4# 4# 4 4 4 4n *A*A*C*CDD	 	 ED	 //*;*;<<  =<$ zOOOJJJ$X$1TUUUF
,EFFFD

&
&t'7
8
8C+11#66
 s  A%%("(1"5+ +% &b)Ds8}f==>>CM
8} Nk#d&6777c


3::4;KLLMMMMM? r    