o
    i-                     @   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 d dlZd dl	Z	d dl
Z
d dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZmZ d dlmZ d dlmZm Z  e! # e"de# ej$%e
j&gZ'e(dd ede'dD Z)W d   n1 sw   Y  g dZ*g dZ+dd Z,dd Z-dd Z.dd Z/e	j01de	j02de dd Z3d d! Z4dS )"    N)	signature)walk_packages)make_classification)enable_halving_search_cvenable_iterative_imputerLogisticRegression)FunctionTransformer)all_estimators)_construct_instances)_get_func_namecheck_docstring_parametersignore_warnings)_is_deprecated)_enforce_estimator_tags_X_enforce_estimator_tags_yignorec                    s*   g | ] t  fd ddD s d qS )c                 3   s    | ]	}| d  v V  qdS )   N ).0substrZpckgr   v/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/sklearn/tests/test_docstring_parameters.py	<genexpr>/   s    
z<listcomp>.<genexpr>)z._z.tests.zsklearn.externalsr   )any)r   r   r   r   
<listcomp>,   s    r   zsklearn.)prefixpath)z%sklearn.utils.deprecation.load_mlcompzsklearn.pipeline.make_pipelinezsklearn.pipeline.make_unionz%sklearn.utils.extmath.safe_sparse_dotZHalfBinomialLoss)fitZscoreZfit_predictZfit_transformZpartial_fitZpredictc               
      sP  t jddd ddlm}  g }tD ]  drq dkrqtjdd	 t	 }W d    n1 s5w   Y  t
|t
j}d
d |D }|D ]\}}g }|tv sY|drZqJt
|r`qJtjdd	}| |}W d    n1 svw   Y  t|rtd| |d f t|jrqJ|t|j|7 }|jD ]0}	t||	}
t|
rqd }|	tv rt|
}d|jv r|jd jd u rdg}t|
|d}||7 }q||7 }qJt
|t
j} fdd|D }|D ]/\}}|drq|dkr drqt|tfddtD st|s|t|7 }qqd |}t|dkr&t!d| d S )Nnumpydocz+numpydoc is required to test the docstrings)reasonr   	docscrapez	.conftestzsklearn.utils.fixesT)recordc                 S   s    g | ]}|d  j dr|qS )r   sklearn)
__module__
startswith)r   clsr   r   r   r   `   s     z-test_docstring_parameters.<locals>.<listcomp>_z"Error for __init__ of %s in %s:
%sy)r   c                    s   g | ]}|d  j  kr|qS )r   )r%   )r   fnnamer   r   r      s    configurationsetupc                 3   s    | ]}| v V  qd S )Nr   )r   d)name_r   r   r      s    z,test_docstring_parameters.<locals>.<genexpr>
zDocstring Error:
)"pytestimportorskipr   r"   PUBLIC_MODULESendswithwarningscatch_warnings	importlibimport_moduleinspect
getmembersisclass_DOCSTRING_IGNORESr&   
isabstractClassDoclenRuntimeErrorr   __new__r   __init__methodsgetattr_METHODS_IGNORE_NONE_Yr   
parametersdefault
isfunctionr   r   joinAssertionError)r"   Z	incorrectmoduleclassescnamer'   Zthis_incorrectwZcdocmethod_namemethodZparam_ignoresigresultZ	functionsfnamefuncmsgr   )r,   r0   r   test_docstring_parametersI   sz   









rW   c                 C   s   | t  dddgiS )NCg?r   r   )ZSearchCVr   r   r   _construct_searchcv_instance   s   rY   c                 C   s\   | j dkr| ddddgfgdS | j dkr| dt fgd	S | j d
kr,| dt fgdS d S )NColumnTransformerZtransformerZpassthroughr   r   )ZtransformersPipelineZclf)ZstepsFeatureUnion)Ztransformer_list)__name__r   r	   )	Estimatorr   r   r   $_construct_compose_pipeline_instance   s   


r_   c                 C   s8   t jg dg dg dg dg dgt jd}| |dS )N)r   r   r   )r`      )r   r   r   )r   r   r   )r   ra   r   )Zdtype)
dictionary)nparrayZfloat64)r^   rb   r   r   r   _construct_sparse_coder   s
    
re   z-ignore::sklearn.exceptions.ConvergenceWarningzname, Estimatorc              	   C   sD  t d ddlm} ||}|d }|jdv rt|}n2|jdv r(t|}n(|jdkr2t|}n|jdkrJt	d	d
dd\}}|t
 ||}ntt|}|jdkr\|jdd nM|jdkrh|jdd nA|jdkss|jdrz|jdd n/|jdv r|jdd n#|jdkr|jdd n|jdkr|jdd n|jdkr|jdd d| v r|jdd |jdkr|jd d d!| v r|jdd" i }|jd#r|jd$v rg d%}n|jd&krddd'd(dd)g}d }nt	d	d(dddd*\}}t||}t||}| jjr|| n+| jjr$|tj||f  n| jjr7||tjd+f | n||| |D ]9}	|	j|v rIq?d,|	j  }
d-|
v rXq?t!t"d. t#||	jsgJ W d    n	1 srw   Y  q?t$|}d/d0 |D }t%|&|}t%|&|}|rt'd1|j d2| d S )3Nr   r   r!   Z
Attributes)ZHalvingRandomSearchCVZRandomizedSearchCVZHalvingGridSearchCVZGridSearchCV)rZ   r[   r\   ZSparseCoderZFrozenEstimator      )	n_samples
n_featuresrandom_stateZSelectKBestra   )kZDummyClassifierZ
stratified)ZstrategyZCCAZPLSr   )Zn_components)ZGaussianRandomProjectionZSparseRandomProjectionZTSNE)Z
perplexityZKBinsDiscretizerZaveraged_inverted_cdf)Zquantile_methodZMDS)Zn_initmax_iter)rl      rj   )rj   Z
Vectorizer)ZCountVectorizerZHashingVectorizerZTfidfVectorizer)zThis is the first document.z%This document is the second document.zAnd this is the third one.zIs this the first document?ZDictVectorizer)foobar   )rn   Zbaz)rh   ri   Zn_redundantZ	n_classesrj   . zonly categoryc                 S   s   g | ]}|j qS r   r+   )r   attrr   r   r   r   )  s    z1test_fit_docstring_attributes.<locals>.<listcomp>zUndocumented attributes for z: )(r2   r3   r   r"   r?   r]   rY   r_   re   r   r   r   nextr   Z
set_paramsr&   
get_paramsr5   r   r   Z__sklearn_tags__Ztarget_tagsZone_d_labelsZtwo_d_labelsrc   Zc_Z
input_tagsZthree_d_arrayZnewaxisr,   rJ   desclowerr   FutureWarninghasattr_get_all_fitted_attributesset
differencerK   )r,   r^   r"   doc
attributesZestXr)   Zskipped_attributesrt   rw   fit_attrZfit_attr_namesZundocumented_attrsr   r   r   test_fit_docstring_attributes   s   






















r   c                 C   s   t | j }t ; tjdtd t| jD ]&}t	| j|}t
|ts&qzt	| | W n ttfy8   Y qw || qW d   n1 sIw   Y  dd |D S )zBGet all the fitted attributes of an estimator including propertieserrorrr   Nc                 S   s$   g | ]}| d r|d s|qS )r(   )r5   r&   )r   rk   r   r   r   r   H  s   $ z._get_all_fitted_attributes.<locals>.<listcomp>)list__dict__keysr6   r7   filterwarningsry   dir	__class__rE   
isinstancepropertyAttributeErrorappend)Z	estimatorr   r,   objr   r   r   r{   2  s    

r{   )5r8   r:   osr6   r   pkgutilr   numpyrc   r2   r$   Zsklearn.datasetsr   Zsklearn.experimentalr   r   Zsklearn.linear_modelr   Zsklearn.preprocessingr	   Zsklearn.utilsr
   Z-sklearn.utils._test_common.instance_generatorr   Zsklearn.utils._testingr   r   r   Zsklearn.utils.deprecationr   Zsklearn.utils.estimator_checksr   r   r7   simplefilterry   r   dirname__file__Zsklearn_pathr|   r4   r=   rF   rW   rY   r_   re   markr   Zparametrizer   r{   r   r   r   r   <module>   sL   

	
O

	 