o
    i                     @   s  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dZdd Zd	d
 Zd&ddZd'dee defddZejde dd Zejde dd Zedkrd dlZd dlZejddZejddd e Ze ej!Z"ej!#dZ$e%e$dkre &de$d  re$d! Z'ndZ'e(ee"d" e'e"d"< e"d" ree"ej!d#Z)e*e) e+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                  c   s    t  } t }| | D ]@\}}|drqg }t|D ]}|dr#qt||}t|ds2t|tr7|| q|d  t	|t
dD ]}||fV  qCqd S )N___call__)key)r   r   
startswithdirgetattrhasattr
isinstancepropertyappendsortedstr)Z
estimatorsZdisplaysnameKlassmethods
method_objmethod r   l/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/sklearn/tests/test_docstrings.pyget_all_methods   s&   




r   c                  c   s8    t  } | D ]\}}d|jvr|j d|j V  qd S )Nzutils.fixes.)r   
__module____name__)Z	functionsr	   funcr   r   r   get_all_functions_names%   s   
r!   c                 c   sh    | D ].\}}|dv rq|dv r#|dur#|dur#t ||}t|tr#q|dur,|dv r,q||fV  qdS )za
    Ignore some errors based on the method type.

    These rules are specific for scikit-learn.)ZRT02ZGL01ZGL02)ZPR02ZGL08N)ZEX01ZSA01ZES01)r   r   r   )errorsr   r   codemessager   r   r   r   filter_errors-   s   


r%   r   returnc                 C   s   |du rt |drd}n
|du rtdt|dur;t||}ztt|}W n ty2   d}Y nw |jd | }nd}|}ddt| d || | d	 d
ddd | d D g }|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                 s   s     | ]\}}d  ||V  qdS )z	 - {}: {}N)format).0r#   r$   r   r   r   	<genexpr>   s    
zrepr_errors.<locals>.<genexpr>r"   )	r   
ValueErrorNotImplementedErrorr   r   r   	TypeErrorr   join)resr   r   objZobj_signatureobj_namemsgr   r   r   repr_errorsZ   s8   



r7   function_namec                 C   sH   t | }tt|d dd|d< |d r"t|d|  d}t|dS )z)Check function docstrings using numpydoc.r"   functionr   zTested function: N)numpydoc_validationvalidatelistr%   r7   r/   )r8   requestr3   r6   r   r   r   test_function_docstring   s   
r?   zKlass, methodc                 C   sp   | j }|| jg}|d ur|| d|}t|}tt|d || d|d< |d r6t|| |}t	|d S )Nr   r"   )r   )
r   r   r   r2   r;   r<   r=   r%   r7   r/   )r   r   r>   Zbase_import_pathimport_pathr3   r6   r   r   r   test_docstring   s   



rA   __main__z!Validate docstring with numpydoc.)descriptionr@   zImport path to validate)helpr      z(?:[A-Z][a-z]*)+r"   r:      z#All docstring checks passed for {}!)N)NN)-reinspectr   typingr   ZpytestZsklearn.experimentalr   r   Zsklearn.utils.discoveryr   r   r   Zimportorskipr;   r   r!   r%   r   r7   markZparametrizer?   rA   r   argparsesysArgumentParserparseradd_argument
parse_argsargsr<   r@   r3   splitZimport_path_sectionslenmatchr   r=   r6   printexitr,   r   r   r   r   <module>   sF    

-7


