o
    ?Hhn                     @   s  d dl Z 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
mZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZm Z m!Z!m"Z"m#Z# d dl$m%Z% d	d
 Z&ej'(de dd Z)dd Z*dd Z+dd Z,dd Z-dd Z.dd Z/dd Z0G dd dZ1G dd dZ2G d d! d!Z3ed"d# Z4d$d% Z5d&d' Z6d(d) Z7ed*d+ Z8eej'(d,e5e6gd-gd.gd/d0fe5e6gd1d2gd3d4fgd5d6 Z9eej'(d7ej:e5e6gd8d-gid9d9d:d;ej:e5e6gd<d=id9d9d>d;ej:e5e6e7gd8d-gid?d9d@d;ej:e5e6e7gd8d.gidAd9dBd;ej:e6e7gd8dCgidDd9dEd;ej:e5e6gd=d.gd/d9dFdGd;gdHdI Z;dJdK Z<dLdM Z=dNdO Z>edPdQ Z?edRdS Z@G dTdU dUZAddWdXZBdYdZ ZCej'jDed[d\d]d^ ZEej'(d_d`eFfdaeGfdbejHfdcejIfgeJdddege!eJdfdgge dhdidj fdkdldj fdmdndj fdoeKfej'(dpejLejMfejNejMfejOejPfejQejPfgdqdr ZRdsdt ZSdudv ZTdwdx ZUej'jVe#e"dykdzd\ej'(d{dedggej'(d|ejLejNejOejQgd}d~ ZWdd ZXdd ZYej'jDedd\dd ZZej'(d{dddfej:deej'jVe#e"dyk dzd\dej:dgej'jVe#e"dyk dzd\dgdd Z[dd Z\ej'(de dd Z]ej'(de dd Z^dS )    N)sparse)LinearDiscriminantAnalysis)DecisionTreeClassifier)
TempMemmap_convert_container_delete_folder_get_warnings_filters_info_listassert_allcloseassert_allclose_dense_sparseassert_docstring_consistency'assert_run_python_script_without_outputcheck_docstring_parameterscreate_memmap_backed_dataignore_warningsraisesset_random_stateskip_if_no_numpydocturn_warnings_into_errors)
deprecated)_IS_WASMCSC_CONTAINERSCSR_CONTAINERSparse_version
sp_version)available_ifc                  C   s2   t  } t }t| d t|d |jdksJ d S )N   )r   r   r   random_state)ldatree r   `/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/sklearn/utils/tests/test_testing.pytest_set_random_state'   s
   

r!   csr_containerc              	   C   s  t ddd}d}| |}||fD ]%}tjt|d t||d  W d    n1 s.w   Y  t|| qtjtdd t|| W d    n1 sPw   Y  tj	t 
ddd	 }| t 
d
}tjtdd t|| W d    d S 1 sw   Y  d S )N	   r   zNot equal to tolerance match   zCan only compare two sparse   r   )offsets)   r'   zArrays are not equal)nparangereshapepytestr   AssertionErrorr
   
ValueErrorr   diagsonestocsr)r"   xmsgyXABr   r   r    !test_assert_allclose_dense_sparse0   s    "r9   c                     s  dd dd  t   t d t ttd W d    n1 s&w   Y  tt ttd  W d    n1 sBw   Y  t } t td  W d    n1 s]w   Y  t	| dksjJ t
| d jtstJ t
| d	 jts~J t } t td  W d    n1 sw   Y  t	| d	ksJ t
| d jtsJ t   t d tttfd W d    n1 sw   Y  t fd
d}tttfd fdd}ttdfdd}ttdfdd}ttd fdd}ttd fdd}t   t d |  |  |  W d    n	1 s,w   Y  tt |  W d    n	1 sEw   Y  tt |  W d    n	1 s^w   Y  tt |  W d    n	1 sww   Y  fdd} fdd}fdd}	fdd}
 fdd} fd d!}t   t d |  |  |	  W d    n	1 sw   Y  tt |
  W d    n	1 sw   Y  tt |  W d    n	1 sw   Y  tt |  W d    n	1 s	w   Y  t}d"}tjt|d# t|}|  W d    n	1 s.w   Y  tjt|d# t|d$d% }W d    d S 1 sOw   Y  d S )&Nc                   S   s   t dt d S Nzdeprecation warningwarningswarnDeprecationWarningr   r   r   r    _warning_functionG   s   z.test_ignore_warning.<locals>._warning_functionc                   S   s   t dt t d d S r:   r;   r   r   r   r    _multiple_warning_functionJ   s   z7test_ignore_warning.<locals>._multiple_warning_functionerrorcategoryr&   r   r)   c                      s        d S Nr   r   r@   r?   r   r    decorator_no_warningi   s   
z1test_ignore_warning.<locals>.decorator_no_warningc                      
      d S rD   r   r   r@   r   r    decorator_no_warning_multiplen      
z:test_ignore_warning.<locals>.decorator_no_warning_multiplec                      rG   rD   r   r   r?   r   r     decorator_no_deprecation_warningr   rJ   z=test_ignore_warning.<locals>.decorator_no_deprecation_warningc                      rG   rD   r   r   rK   r   r    decorator_no_user_warningv   rJ   z6test_ignore_warning.<locals>.decorator_no_user_warningc                      rG   rD   r   r   rH   r   r    )decorator_no_deprecation_multiple_warningz   rJ   zFtest_ignore_warning.<locals>.decorator_no_deprecation_multiple_warningc                      rG   rD   r   r   rH   r   r    "decorator_no_user_multiple_warning~   rJ   z?test_ignore_warning.<locals>.decorator_no_user_multiple_warningc                      s2   t      W d    d S 1 sw   Y  d S rD   )r   r   rK   r   r    context_manager_no_warning   s   "z7test_ignore_warning.<locals>.context_manager_no_warningc                      s:   t ttfd    W d    d S 1 sw   Y  d S NrB   )r   r>   UserWarningr   rH   r   r    #context_manager_no_warning_multiple   s   "z@test_ignore_warning.<locals>.context_manager_no_warning_multiplec                      6   t td    W d    d S 1 sw   Y  d S rQ   r   r>   r   rK   r   r    &context_manager_no_deprecation_warning      "zCtest_ignore_warning.<locals>.context_manager_no_deprecation_warningc                      rT   rQ   r   rR   r   rK   r   r    context_manager_no_user_warning   rW   z<test_ignore_warning.<locals>.context_manager_no_user_warningc                      rT   rQ   rU   r   rH   r   r    /context_manager_no_deprecation_multiple_warning   rW   zLtest_ignore_warning.<locals>.context_manager_no_deprecation_multiple_warningc                      rT   rQ   rX   r   rH   r   r    (context_manager_no_user_multiple_warning   rW   zEtest_ignore_warning.<locals>.context_manager_no_user_multiple_warningzA'obj' should be a callable.+you should use 'category=UserWarning'r$   c                   S      d S rD   r   r   r   r   r    test   s   z!test_ignore_warning.<locals>.test)r<   catch_warningssimplefilterr   r>   r-   warnsrR   FutureWarninglen
isinstancemessager   r/   )recordrF   rI   rL   rM   rN   rO   rP   rS   rV   rY   rZ   r[   warning_classr%   silence_warnings_funcr]   r   rE   r    test_ignore_warningD   s   









$rh   c                 C      | | }|S zFunction f

    Parameters
    ----------
    a : int
        Parameter a
    b : float
        Parameter b

    Returns
    -------
    c : list
        Parameter c
    r   abcr   r   r    f_ok      ro   c                 C   ri   )zFunction f

    Parameters
    ----------
    a : int
        Parameter a
    b : float
        Parameter b

    Results
    -------
    c : list
        Parameter c
    r   rk   r   r   r    f_bad_sections   rp   rq   c                 C   s   ||  }|S rj   r   )rm   rl   rn   r   r   r    f_bad_order   rp   rr   c                 C   ri   )zFunction f

    Parameters
    ----------
    a : int
        Parameter a
    b : int
        Parameter b
    c : int
        Parameter c

    Returns
    -------
    d : list
        Parameter c
    r   )rl   rm   dr   r   r    f_too_many_param_docstring  s   rt   c                 C   ri   )zFunction f

    Parameters
    ----------
    a : int
        Parameter a

    Returns
    -------
    c : list
        Parameter c
    r   rk   r   r   r    	f_missing  s   ru   c                 C   s   | | | | S )zFunction f

    Parameters
    ----------
    a: int
        Parameter a
    b:
        Parameter b
    c :
        This is parsed correctly in numpydoc 1.2
    d:int
        Parameter d
    e
        No typespec is allowed without colon
    r   )rl   rm   rn   rs   er   r   r    f_check_param_definition(  s   rw   c                   @      e Zd Zdd Zdd ZdS )Klassc                 C   r\   rD   r   selfr6   r5   r   r   r    ru   <     zKlass.f_missingc                 C      dS )zFunction f

        Parameter
        ---------
        a : int
            Parameter a
        b : float
            Parameter b

        Results
        -------
        c : list
            Parameter c
        Nr   rz   r   r   r    rq   ?  s   zKlass.f_bad_sectionsN)__name__
__module____qualname__ru   rq   r   r   r   r    ry   ;      ry   c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )MockEstc                 C   r}   )MockEstimatorNr   r{   r   r   r    __init__R      zMockEst.__init__c                 C      |S rD   r   rz   r   r   r    fitU  r|   zMockEst.fitc                 C   r   rD   r   r{   r6   r   r   r    predictX  r|   zMockEst.predictc                 C   r   rD   r   r   r   r   r    predict_proba[  r|   zMockEst.predict_probac                 C   r}   )N      ?r   r   r   r   r    score^  r|   zMockEst.scoreN)r~   r   r   r   r   r   r   r   r   r   r   r    r   Q  s    r   c                   @   sh   e Zd Zdd Zedd dd Zedd edd	d
 Zedd dd Zeddd Z	dS )MockMetaEstimatorc                 C   s
   || _ dS )zMetaEstimator to check if doctest on delegated methods work.

        Parameters
        ---------
        delegate : estimator
            Delegated estimator.
        Ndelegate)r{   r   r   r   r    r   c  s   
zMockMetaEstimator.__init__c                 C      t | jdS )Nr   hasattrr   r   r   r   r    <lambda>m      zMockMetaEstimator.<lambda>c                 C   s   | j |S )zThis is available only if delegate has predict.

        Parameters
        ----------
        y : ndarray
            Parameter y
        )r   r   r   r   r   r    r   m  s   	zMockMetaEstimator.predictc                 C   r   )Nr   r   r   r   r   r    r   x  r   z%Testing a deprecated delegated methodc                 C   r}   )zThis is available only if delegate has score.

        Parameters
        ---------
        y : ndarray
            Parameter y
        Nr   r   r   r   r    r   x  r   zMockMetaEstimator.scorec                 C   r   )Nr   r   r   r   r   r    r     r   c                 C   r   )zThis is available only if delegate has predict_proba.

        Parameters
        ---------
        X : ndarray
            Parameter X
        r   r   r   r   r    r     s   	zMockMetaEstimator.predict_probaz-Testing deprecated function with wrong paramsc                 C   r}   )z,Incorrect docstring but should not be testedNr   rz   r   r   r    r     r   zMockMetaEstimator.fitN)
r~   r   r   r   r   r   r   r   r   r   r   r   r   r    r   b  s    





	

r   c                  C   s  t t} | g ks
J t tdgd} | g ksJ t tdgd} | g ks$J tjtdd t t W d    n1 s:w   Y  tjtdd t tj W d    n1 sVw   Y  t t} t	t
 d}|jj}| g dksqJ g dg d	g d
g ddd| d ddddddgdd| d d dddgdd| d dddgdd| d ddddgg}t|ttttj|j|j|j|jgD ]\}}t |} || ksJ d|| f qd S )Nrm   )ignorezUnknown section Resultsr$   zUnknown section Parameterr   )zxsklearn.utils.tests.test_testing.f_check_param_definition There was no space between the param name and colon ('a: int')ztsklearn.utils.tests.test_testing.f_check_param_definition There was no space between the param name and colon ('b:')zwsklearn.utils.tests.test_testing.f_check_param_definition There was no space between the param name and colon ('d:int'))z9In function: sklearn.utils.tests.test_testing.f_bad_orderznThere's a parameter name mismatch in function docstring w.r.t. function signature, at index 0 diff: 'b' != 'a'
Full diff:z- ['b', 'a']z+ ['a', 'b'])zHIn function: sklearn.utils.tests.test_testing.f_too_many_param_docstringz_Parameters in function docstring have more items w.r.t. function signature, first extra item: cr   - ['a', 'b']z+ ['a', 'b', 'c']z?          +++++)z7In function: sklearn.utils.tests.test_testing.f_missingzaParameters in function docstring have less items w.r.t. function signature, first missing item: br   r   z+ ['a'])z=In function: sklearn.utils.tests.test_testing.Klass.f_missingaParameters in function docstring have less items w.r.t. function signature, first missing item: Xr   - ['X', 'y']+ []zIn function: z!sklearn.utils.tests.test_testing.z.predictznThere's a parameter name mismatch in function docstring w.r.t. function signature, at index 0 diff: 'X' != 'y'r   z- ['X']z?   ^z+ ['y'].r   z&potentially wrong underline length... zParameters z--------- in z.scorez.fitr   r   r   z
"%s"
 not in 
"%s")r   ro   ru   r-   r   RuntimeErrorrq   ry   rw   r   r   	__class__r~   ziprr   rt   r   r   r   r   )	incorrect	mock_metamock_meta_namemessagesr4   fr   r   r    test_check_docstring_parameters  s   




	
Sr   c                 C   r}   )zFunction one.

    Parameters
    ----------
    a : int,   float
        Parameter a.
        Second    line.

    b : str
        Parameter b.

    Returns
    -------
    c : int
       Returning

    d : int
       Returning
    Nr   rl   rm   r   r   r    f_one  s   r   c                 C   r}   )a  Function two.

    Parameters
    ----------
    a :   int, float
        Parameter a.
          Second line.

    b : str
        Parameter bb.

    e : int
        Extra parameter.

    Returns
    -------
    c : int
       Returning

    d : int
       Returning
    Nr   r   r   r   r    f_two-  s   r   c                 C   r}   )zFunction two.

    Parameters
    ----------
    a :   int, float
        Parameter a.

    b : str
        Parameter B!

    e :
        Extra parameter.

    Returns
    -------
    c : int
       Returning.

    d : int
       Returning
    Nr   r   r   r   r    f_threeG  s   r   c                   C   s@   t jtdd tdtg W d   dS 1 sw   Y  dS )z1Check error raised when `objects` incorrect type.zAll 'objects' must be one ofr$   stringN)r-   r   	TypeErrorr   r   r   r   r   r    -test_assert_docstring_consistency_object_type`  s   "r   zobjects, kwargs, errorrl   rm   )include_paramsexclude_paramszThe 'exclude_params' argumentFrn   )include_returnsexclude_returnszThe 'exclude_returns' argumentc                 C   sD   t jt|d t| fi | W d   dS 1 sw   Y  dS )z?Check `assert_docstring_consistency` argument checking correct.r$   N)r-   r   r   r   )objectskwargsrA   r   r   r    ,test_assert_docstring_consistency_arg_checksg  s   "r   zobjects, kwargs, error, warnr    
whitespace)idr   Tincl_allzNThe description of Parameter 'a' is inconsistent between \['f_one',\n'f_two'\]z	2-1 groupzYThe description of Parameter 'b' is inconsistent between \['f_one'\] and\n\['f_two'\] andz1-1-1 grouprv   zPThe type specification of Parameter 'e' is inconsistent between\n\['f_two'\] andz
empty typez,Checking was skipped for Parameters: \['e'\]z	skip warnc                 C   s   |r$t jt|d t| fi | W d   dS 1 sw   Y  dS |rHt jt|d t| fi | W d   dS 1 sAw   Y  dS t| fi | dS )z;Check `assert_docstring_consistency` gives correct results.r$   N)r-   r   r.   r   r`   rR   )r   r   rA   r=   r   r   r    !test_assert_docstring_consistency}  s   1""r   c                 C   r}   )zFunction four.

    Parameters
    ----------

    labels : array-like, default=None
        The set of labels to include when `average != 'binary'`, and their
        order if `average is None`. Labels present in the data can be excluded.
    Nr   labelsr   r   r    f_four     
r   c                 C   r}   )a  Function five.

    Parameters
    ----------

    labels : array-like, default=None
        The set of labels to include when `average != 'binary'`, and their
        order if `average is None`. This is an extra line. Labels present in the
        data can be excluded.
    Nr   r   r   r   r    f_five  s   r   c                 C   r}   )zFunction six.

    Parameters
    ----------

    labels : array-like, default=None
        The group of labels to add when `average != 'binary'`, and the
        order if `average is None`. Labels present on them datas can be excluded.
    Nr   r   r   r   r    f_six  r   r   c                  C   sJ   d} t jt| d ttttgdd W d   dS 1 sw   Y  dS )z8Check `assert_docstring_consistency` difference message.a  The description of Parameter 'labels' is inconsistent between
\['f_four'\] and \['f_five'\] and \['f_six'\]:

\*\*\* \['f_four'\]
--- \['f_five'\]
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\*\*\* 10,25 \*\*\*\*

--- 10,30 ----

  'binary'`, and their order if `average is None`.
\+ This is an extra line.
  Labels present in the data can be excluded.

\*\*\* \['f_four'\]
--- \['f_six'\]
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\*\*\* 1,25 \*\*\*\*

  The
! set
  of labels to
! include
  when `average != 'binary'`, and
! their
  order if `average is None`. Labels present
! in the data
  can be excluded.
--- 1,25 ----

  The
! group
  of labels to
! add
  when `average != 'binary'`, and
! the
  order if `average is None`. Labels present
! on them datas
  can be excluded.r$   T)r   N)r-   r   r.   r   r   r   r   )r4   r   r   r    +test_assert_docstring_consistency_error_msg  s   *"r   c                  C   s   d} t tttgdd|  d d}t tttgdd| d d}d}tjt|d t tttgdd| d W d	   d	S 1 sHw   Y  d	S )
zACheck `assert_docstring_consistency` `descr_regex_pattern` works.zThe (set|group) of labels to (include|add) when `average \!\= 'binary'`, and (their|the) order if `average is None`\.[\s\w]*\.* Labels present (on|in) (them|the) datas? can be excluded\.T )r   descr_regex_patternz(labels|average|binary)z#The set of labels to include when.+zCThe description of Parameter 'labels' in \['f_six'\] does not matchr$   N)	r   r   r   r   joinsplitr-   r   r.   )
regex_fullregex_wordsregex_errorr4   r   r   r    5test_assert_docstring_consistency_descr_regex_pattern  s,   "r   c                   @   rx   )RegistrationCounterc                 C   s
   d| _ d S )Nr   )nb_callsr   r   r   r    r   8  s   
zRegistrationCounter.__init__c                 C   s    |  j d7  _ |jtu sJ d S )Nr)   )r   funcr   )r{   to_register_funcr   r   r    __call__;  s   zRegistrationCounter.__call__N)r~   r   r   r   r   r   r   r   r    r   7  r   r   rc                 C   s:   t |tjsJ |dk}|jj|u sJ tj| | d S )Nr   )rc   r*   memmapflags	writeabletestingassert_array_equal)input_array	mmap_data	mmap_moder   r   r   r    check_memmap@  s   r   c                 C   s   t  }| td| td}t|}t|| tj	|j
}W d    n1 s*w   Y  tjdkr<tj|r<J |jdksCJ d}t||d}t|||d tj	|j
}W d    n1 sdw   Y  tjdkrvtj|rvJ |jdks}J d S )Nregisterr   ntr)   r+r   r&   )r   setattratexitr*   r1   r   r   ospathdirnamefilenamenameexistsr   )monkeypatchregistration_counterr   datatemp_folderr   r   r   r    test_tempmemmapG  s$   




r   zmemmap not fully supported)reasonc           
      C   s  t  }| td| td}t|}t|| |jdksJ t|dd\}}t|| |tj	
|jks7J |jdks>J d}t||d}t||| |jdksSJ ||d |d g}t|}t||D ]	\}}t|| qe|jd	ksvJ t|d
g\}}	t|| |	d
ksJ d S )Nr   r   r)   T)return_folderr&   r   r      znot-an-array)r   r   r   r*   r1   r   r   r   r   r   r   r   r   )
r   r   r   r   folderr   
input_listmmap_data_listoutput_dataotherr   r   r    test_create_memmap_backed_data\  s,   



r   z constructor_name, container_typelisttuplearrayr   
sparse_csrsparse_csr_array
sparse_cscsparse_csc_array	dataframec                   C      t djS Npandas)r-   importorskip	DataFramer   r   r   r    r     r   r   seriesc                   C   r   r   )r-   r   Seriesr   r   r   r    r     r   indexc                   C   r   r   )r-   r   Indexr   r   r   r    r     r   slicezdtype, superdtypec                 C   s   | dv r| }ddg}t || |d}t||sJ | dv r+tt|d |s)J dS t|dr9|j|ks7J dS t|drG|jd |ksIJ dS dS )	z\Check that we convert the container to the right type of array with the
    right data type.)r   polarsr   polars_seriesr   r   r)   dtype)r   r   r   r  dtypesN)r   rc   r*   
issubdtypetyper   r  r  )constructor_namecontainer_typer  
superdtype	containercontainer_convertedr   r   r    test_convert_container{  s"   "

r  c                  C   s:   t d tdggddgdgd} | jjd dksJ d S )Nr   r3   r   r7   categorical_feature_namesr   rC   )r-   r   r   r  iloc)dfr   r   r    (test_convert_container_categories_pandas  s
   
r  c                  C   s<   t d} tdggddgdgd}|jd |  ksJ d S )Nr  r3   r7   r  )r-   r   r   schemaCategorical)plr  r   r   r    (test_convert_container_categories_polars  s   
r  c                  C   s@   t d} tdggddgdgd}t|jd j| ju sJ d S )Npyarrowr3   r7   r  r   )r-   r   r   r	  r  DictionaryType)par  r   r   r    )test_convert_container_categories_pyarrow  s   
r  z1.8z-sparse arrays are available as of scipy 1.8.0r
  r  c                 C   sP   ddg}t jtdt d t|| |d W d   dS 1 s!w   Y  dS )zCheck that if we convert to sparse array but sparse array are not supported
    (scipy<1.8.0), we should raise an explicit error.r   r)   z&only available with scipy>=1.8.0, got r$   r  N)r-   r   r/   r   r   )r
  r  r  r   r   r    7test_convert_container_raise_when_sparray_not_available  s   	"r  c               	   C   s  t t t 1 sw   Y  t tdd} td1 sw   Y  | js(J t tddgd} td1 s8w   Y  | jsBJ tj tdd t t} td1 sVw   Y  W d    n1 sew   Y  | jroJ tj tdd t tdd} t 1 sw   Y  W d    n1 sw   Y  | jrJ tj tdd t tdd} td1 sw   Y  W d    n1 sw   Y  | jrJ tj td	d t td
d} td1 sw   Y  W d    n1 sw   Y  | jrJ tj tdd t td
dd} td1 sw   Y  W d    n	1 s#w   Y  | jr.J tj tdd t t} W d    n	1 sFw   Y  W d    n	1 sVw   Y  | jraJ t td
dd} W d    n	1 stw   Y  | jrJ t ttf t 1 sw   Y  t ttf t 1 sw   Y  t t( t ttf W d    n1 sw   Y  W d    d S W d    d S 1 sw   Y  d S )Nzhow are your$   zhello how are youznot this onezthis will be raisedzthe failure message)err_msgzthis is ignoredz,should contain one of the following patternshellozBad message)r%   r  zDid not raiseT)r%   may_pass)r   r   raised_and_matchedr-   r/   r.   )cmr   r   r    test_raises  s   








 $r#  c                   C   s  t tjdgtjdd tt t tjdgtjdd W d    n1 s(w   Y  t tjdgtjdd tt t tjdgtjdd W d    n1 sUw   Y  tt t tjdgtjdd W d    n1 svw   Y  t tjdgtjddd	d
 d S )Ng㈵ ?r  r   gX ?gc^  ?g55  ?gh㈵>g        gh㈵>)atol)r	   r*   r   float32r-   r   r.   float64r   r   r   r    "test_float32_aware_assert_allclose   s    r'  zcannot start subprocessc                  C   s   d} t |  d} tjtdd t |  W d    n1 sw   Y  d} tjtdd t | dd W d    n1 s=w   Y  dd	d
g} tjtdd t | dd W d    d S 1 sbw   Y  d S )Nzx = 1zprint('something to stdout')zExpected no outputr$   z:output was not supposed to match.+got.+something to stdoutz
to.+stdout)pattern
z
import sysz-print('something to stderr', file=sys.stderr)z:output was not supposed to match.+got.+something to stderrz
to.+stderr)r   r-   r   r.   r   )coder   r   r    ,test_assert_run_python_script_without_output2  s(   
"r+  )marksc                 C   s    t jddddd}t||  dS )zyNon-regression test to check that we can still convert a sparse container
    from a given format to another format.
    
   g?csr)densityformatN)r   randomr   )r
  X_sparser   r   r    'test_convert_container_sparse_to_sparseJ  s   r3  c                 C   s  | j dkr)|r)tj| j| jd tj| j| jd W d    n1 s$w   Y  | j dkrtjddD}| j}d|v r>d}tj|| jd |rPt|d	ksQJ 	 |rht	|d	 j|ks^J |d	 j| jkspJ W d    d S W d    d S 1 s{w   Y  d S d S )
NrA   r$   )rd   rC   r   T)re   Pyarrowz*
Pyarrow will become a required dependencyr   )
actionr-   r   rC   rd   r<   r=   r^   rb   str)warning_infowarnings_as_errorsre   rd   r   r   r    check_warnings_as_errorsg  s2   
"r9  r7  c                 C   s"   t jdddk}t| |d d S )NSKLEARN_WARNINGS_AS_ERRORS0r8  )r   environgetr9  )r7  r8  r   r   r    test_sklearn_warnings_as_errors  s   r?  c                 C   s@   t   t  t| dd W d    d S 1 sw   Y  d S )NTr<  )r<   r^   r   r9  )r7  r   r   r    test_turn_warnings_into_errors  s   
"r@  )r   )_r   r   r<   numpyr*   r-   scipyr   sklearn.discriminant_analysisr   sklearn.treer   sklearn.utils._testingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   sklearn.utils.deprecationr   sklearn.utils.fixesr   r   r   r   r   sklearn.utils.metaestimatorsr   r!   markparametrizer9   rh   ro   rq   rr   rt   ru   rw   ry   r   r   r   r   r   r   r   r   paramr   r   r   r   r   r   r   r   r   xfailr   r   r   ndarray
csr_matrixr   r  int32integerint64r%  floatingr&  r  r  r  r  skipifr  r#  r'  r+  r3  r9  r?  r@  r   r   r   r    <module>   sN   D	
 1
 





.
0
%
	

	






	
F




