
    Q3ji                        d dl Z d dlmZ d dlmZ d dlZd dlm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,                  j/                  d e             d        Zej,                  j2                  ej,                  j/                  d e             d               Zedk(  rd dlZd dlZ ej<                  d      ZejA                  dd       ejC                         Z"ejG                  e"jH                        Z%e"jH                  jM                  d      Z' e(e'      dk\  r e jR                  de'd         re'd   Z*ndZ* e+ ee%d   e*            e%d<   e%d   r/ ee%e"jH                        Z, e-e,        ej\                  d       y e-d j_                  e"jH                               yy)#    N)	signature)Optional)_BaseCallback)enable_halving_search_cvenable_iterative_imputer)all_displaysall_estimatorsall_functionsznumpydoc.validatec               #     K   t               } t               }| |z   D ]  \  }}|j                  d      rg }t        |      D ]c  }|j                  d      rt	        |t
              r|dv r*t        ||      }t        |d      st	        |t              sS|j                  |       e |j                  d        t        |t              D ]  }||f 
  y w)N_)setupteardownon_fit_task_beginon_fit_task_end__call__)key)r	   r   
startswithdir
isinstancer   getattrhasattrpropertyappendsortedstr)
estimatorsdisplaysnameKlassmethods
method_objmethods          J/DATA/.local/lib/python3.12/site-packages/sklearn/tests/test_docstrings.pyget_all_methodsr$      s     !J~H!H,e??3JDs#
 %/D = 5  -Jz:.*Z2Rt$! " 	tW#.F- /1 -s   BCACc               #      K   t               } | D ]1  \  }}d|j                  vs|j                   d|j                    3 y w)Nzutils.fixes.)r
   
__module____name__)	functionsr   funcs      r#   get_all_functions_namesr+   2   sA     I4/__%Qt}}o66 s
   !A Ac              #      K   | D ]<  \  }}|dv r|dv r!||t        ||      }t        |t              r0||dv r7||f > yw)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_errorsr8   :   sp     
  g ++ ##(9f>P /J*h/ $*B"BGmK  s   AAr"   returnc                 l   |"t        |d      rd}n|t        d      t        |4t        ||      }	 t	        t        |            }|j                  dz   |z   }nd}|}ddj                  t	        | d         ||z   | d   d	d
j                  d | d   D              g      z   }|S # t        $ r d}Y jw xY w)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.
    __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   F   K   | ]  \  }}d j                  ||        yw)z	 - {}: {}N)format).0r6   r7   s      r#   	<genexpr>zrepr_errors.<locals>.<genexpr>   s%      GTmdG""41}s   !r5   )	r   
ValueErrorNotImplementedErrorr   r   r   	TypeErrorr(   join)resr   r"   objobj_signatureobj_namemsgs          r#   repr_errorsrM   g   s    " ~5*%F]OPP%%eV$		#/M >>C'&0
6;;F}$II GJ8} 	

 
C J/  	7 	s   B% %B32B3function_namec                     t         j                  |       }t        t        |d   d            |d<   |d   rt	        |d|        }t        |      y)z)Check function docstrings using numpydoc.r5   functionr"   zTested function: N)numpydoc_validationvalidatelistr8   rM   rD   )rN   requestrH   rL   s       r#   test_function_docstringrV      sW     
&
&}
5Cs8}ZHICM
8}#(9-&IJo     zKlass, methodc                    | j                   }|| j                  g}||j                  |       dj                  |      }t        j                  |      }t        t        |d   ||             |d<   |d   rt        || |      }t        |      y )Nr&   r5   )r   )
r'   r(   r   rG   rR   rS   rT   r8   rM   rD   )r   r"   rU   base_import_pathimport_pathrH   rL   s          r#   test_docstringr[      s     ''#U^^4K6"((;'K

&
&{
3Cs8}fEJKCM
8}#uf-o rW   __main__z!Validate docstring with numpydoc.)descriptionrZ   zImport path to validate)helpr&      z(?:[A-Z][a-z]*)+r5   rQ      z#All docstring checks passed for {}!)N)NN)0reinspectr   typingr   pytestsklearn.callback._baser   sklearn.experimentalr   r   sklearn.utils.discoveryr   r	   r
   importorskiprR   r$   r+   r8   r   rM   markparametrizerV   no_check_spmatrixr[   r(   argparsesysArgumentParserparseradd_argument
parse_argsargsrS   rZ   rH   splitimport_path_sectionslenmatchr"   rT   rL   printexitrA    rW   r#   <module>r|      s   	    0 P O)f))*=>  >7*Z4# 4# 4n *A*CD	 E	 /*;< = $ z$X$$1TUF
,EFD

&
&t'7'7
8C++11#6
  A%("((1"5+ &b)s8}f=>CM
8}#d&6&67c
3::4;K;KLM? rW   