o
    tBhJ/                     @   s  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	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 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 d dlmZ d dlZe  ede ej Z!e"dd ede!dD Z#W d   n1 sw   Y  g dZ$g dZ%ej&'dej&'dej&j(e
dddd Z)eeddd Z*d d! Z+d"d# Z,d$d% Z-ej&.d&e d'd( Z/d)d* Z0dS )+    N)walk_packages)	signature)IS_PYPY)check_docstring_parameters)_get_func_name)ignore_warnings)all_estimators)_enforce_estimator_tags_y)_enforce_estimator_tags_x)_construct_instance)_is_deprecated)make_classificationLogisticRegression)FunctionTransformerignorec                 C   s,   g | ]}d |d v sd|d v s|d qS )z._   z.tests. ).0pckgr   r   ~/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/sklearn/tests/test_docstring_parameters.py
<listcomp>&   s
    r   sklearn.)prefixpath)z%sklearn.utils.deprecation.load_mlcompzsklearn.pipeline.make_pipelinezsklearn.pipeline.make_unionz%sklearn.utils.extmath.safe_sparse_dotzsklearn.utils._joblib)fitscorefit_predictfit_transformpartial_fitpredictzignore::FutureWarningzignore::DeprecationWarningztest segfaults on PyPyreasonc               
      sf  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|dd }	t|	rqJ|	d ur|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 ]1\}}|drq|dkr drqt|tfddtD st|s|t|7 }qqd|}t|dkr1t d| d S )Nnumpydocz+numpydoc is required to test the docstringsr!   r   	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__init__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   	<genexpr>   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RuntimeErrorgetattrr   r   r,   methods_METHODS_IGNORE_NONE_Yr   
parametersdefault
isfunctionr   anyjoinAssertionError)r%   	incorrectmoduleclassescnamer*   this_incorrectwcdoccls_initmethod_namemethodparam_ignoresigresult	functionsfnamefuncmsgr   )r0   r4   r   test_docstring_parametersC   s~   








ra   categoryc               	   C   sx   t tjddD ]2\} }}trd|v sd|v rqt|}zt|}W n	 ty,   Y qw d|vs9J dd| fqd S )Nr   )r   _svmlight_format_ioz feature_extraction._hashing_fast	z""%s" has tabs, please remove them zor add it to the ignore list)	r   r'   __path__r   r=   r>   r?   	getsourceIOError)importermodnameispkgmodsourcer   r   r   	test_tabs   s    

rn   c                 C   s   | t  dddgiS )NCg?r   r   )SearchCVr   r   r   _construct_searchcv_instance   s   rq   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   


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   r   r   )dtype)
dictionary)nparrayfloat64)r|   r   r   r   r   _construct_sparse_coder   s
    
r   zname, Estimatorc              	   C   s  t d ddlm} ||}|d }|jdv rt|}n|jdv r(t|}n|jdkr2t|}nt	|}|jdkrB|j
d	d
 n)|jdkrN|j
dd n|jdksY|jdr`|j
dd n|jdv rk|j
d	d |jdv rv|j
dd |jdkr|j
ddd |jdkr|j
dd |jdkr|j
dd |jd k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||}d,| d- v r|| nd.| d- v r|tj||f  n||| |D ]9}	|	j|v rqd/|	j }
d0|
v rqttd1 t||	js-J W d    n	1 s8w   Y  qt|}d2d3 |D }t||}t||}|rftd4|j d5| d S )6Nr#   r   r$   
Attributes)HalvingRandomSearchCVRandomizedSearchCVHalvingGridSearchCVGridSearchCV)rr   rv   ry   SparseCoderSelectKBestr   )kDummyClassifier
stratified)strategyCCAPLSr   )n_components)GaussianRandomProjectionSparseRandomProjection)OrthogonalMatchingPursuitOrthogonalMatchingPursuitCVLarsLarsCV	LassoLarsLassoLarsCVLassoLarsICF)	normalizeTSNEg      i@random)learning_rateinitSequentialFeatureSelectorauto)n_features_to_selectFastICAzunit-variance)whitenMiniBatchDictionaryLearning   )
batch_size
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   )	n_samples
n_featuresn_redundant	n_classesrandom_state1dlabelsX_types2dlabels zonly rb   c                 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: )r7   r8   r#   r%   rD   r{   rq   r}   r   r   
set_paramsr)   r:   r   r	   r
   	_get_tagsr   r   c_r0   rN   desclowerr   FutureWarninghasattr_get_all_fitted_attributesset
differencerO   )r0   r|   r%   doc
attributesestskipped_attributesXr-   r   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errorrb   Nc                 S   s$   g | ]}| d r|d s|qS )r+   )r:   r)   )r   r   r   r   r   r   \  s   $ z._get_all_fitted_attributes.<locals>.<listcomp>)list__dict__keysr;   r<   filterwarningsr   dir	__class__rG   
isinstancepropertyAttributeErrorappend)	estimatorr   r0   objr   r   r   r   F  s    

r   )1r?   r;   r=   pkgutilr   r   numpyr   r'   sklearn.utilsr   sklearn.utils._testingr   r   r   r   sklearn.utils.estimator_checksr	   r
   r   sklearn.utils.deprecationr   sklearn.datasetsr   sklearn.linear_modelr   sklearn.preprocessingr   r7   r<   simplefilterr   rf   sklearn_pathr   r9   rB   rI   markr   skipifra   rn   rq   r}   r   parametrizer   r   r   r   r   r   <module>   sX   

	

P

	
 