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pckgr   /var/www/www-root/data/www/176.119.141.140/sports-predictor/venv/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_dotHalfBinomialLoss)fitscorefit_predictfit_transformpartial_fit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)   	incorrectmoduleclassescnamer.   this_incorrectwcdocmethod_namemethodparam_ignoresigresult	functionsfnamefuncmsgr   )r3   r7   r   test_docstring_parametersI   sz   









rc   c                 C   s   | t  dddgiS )NCg?r   r   )SearchCVr   r   r   _construct_searchcv_instance   s   rf   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ColumnTransformertransformerpassthroughr   r   )transformersPipelineclf)stepsFeatureUnion)transformer_list)__name__r   r	   )	Estimatorr   r   r   $_construct_compose_pipeline_instance   s   


rr   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   )rs      )r   r   r   )r   r   r   )r   rt   r   )dtype)
dictionary)nparrayfloat64)rq   rv   r   r   r   _construct_sparse_coder   s
    
rz   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(   
Attributes)HalvingRandomSearchCVRandomizedSearchCVHalvingGridSearchCVGridSearchCV)rg   rk   rn   SparseCoderFrozenEstimator      )	n_samples
n_featuresrandom_stateSelectKBestrt   )kDummyClassifier
stratified)strategyCCAPLSr   )n_components)GaussianRandomProjectionSparseRandomProjectionTSNE)
perplexityKBinsDiscretizeraveraged_inverted_cdf)quantile_methodMDS)n_initmax_iter)r      r   )r   
Vectorizer)CountVectorizerHashingVectorizer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?DictVectorizer)foobar   )r   baz)r   r   n_redundant	n_classesr   . zonly categoryc                 S   s   g | ]}|j qS r   r2   )r   attrr   r   r   r   )  s    z1test_fit_docstring_attributes.<locals>.<listcomp>zUndocumented attributes for z: )(r9   r:   r&   r)   rF   rp   rf   rr   rz   r   r   r    nextr   
set_paramsr-   
get_paramsr<   r   r   __sklearn_tags__target_tagsone_d_labelstwo_d_labelsrw   c_
input_tagsthree_d_arraynewaxisr3   rQ   desclowerr   FutureWarninghasattr_get_all_fitted_attributesset
differencerR   )r3   rq   r)   doc
attributesestXr0   skipped_attributesr   r   fit_attrfit_attr_names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errorr   Nc                 S   s$   g | ]}| d r|d s|qS )r/   )r<   r-   )r   r   r   r   r   r   H  s   $ z._get_all_fitted_attributes.<locals>.<listcomp>)list__dict__keysr=   r>   filterwarningsr   dir	__class__rL   
isinstancepropertyAttributeErrorappend)	estimatorr   r3   objr   r   r   r   2  s    

r   )5r?   rA   osr=   r   pkgutilr   numpyrw   r9   r+   sklearn.datasetsr   sklearn.experimentalr   r   sklearn.linear_modelr   sklearn.preprocessingr	   sklearn.utilsr
   -sklearn.utils._test_common.instance_generatorr   sklearn.utils._testingr   r   r   sklearn.utils.deprecationr   sklearn.utils.estimator_checksr   r   r>   simplefilterr   r   dirname__file__sklearn_pathr   r;   rD   rM   rc   rf   rr   rz   markr   parametrizer   r   r   r   r   r   <module>   sL   

	
O

	 