o
    &ѹgn                     @   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   Zrandom_state)Zldatree r   d/Users/admin/.pyenv/versions/3.10.0/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)npZarangeZreshapepytestr   AssertionErrorr
   
ValueErrorr   ZdiagsonesZtocsr)r    xmsgyXABr   r   r   !test_assert_allclose_dense_sparse0   s    "r3   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 r4   r5   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:   r9   r   r   decorator_no_warningi   s   
z1test_ignore_warning.<locals>.decorator_no_warningc                      
      d S r>   r   r   r:   r   r   decorator_no_warning_multiplen      
z:test_ignore_warning.<locals>.decorator_no_warning_multiplec                      rA   r>   r   r   r9   r   r    decorator_no_deprecation_warningr   rD   z=test_ignore_warning.<locals>.decorator_no_deprecation_warningc                      rA   r>   r   r   rE   r   r   decorator_no_user_warningv   rD   z6test_ignore_warning.<locals>.decorator_no_user_warningc                      rA   r>   r   r   rB   r   r   )decorator_no_deprecation_multiple_warningz   rD   zFtest_ignore_warning.<locals>.decorator_no_deprecation_multiple_warningc                      rA   r>   r   r   rB   r   r   "decorator_no_user_multiple_warning~   rD   z?test_ignore_warning.<locals>.decorator_no_user_multiple_warningc                      s2   t      W d    d S 1 sw   Y  d S r>   )r   r   rE   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 Nr<   )r   r8   UserWarningr   rB   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 rK   r   r8   r   rE   r   r   &context_manager_no_deprecation_warning      "zCtest_ignore_warning.<locals>.context_manager_no_deprecation_warningc                      rN   rK   r   rL   r   rE   r   r   context_manager_no_user_warning   rQ   z<test_ignore_warning.<locals>.context_manager_no_user_warningc                      rN   rK   rO   r   rB   r   r   /context_manager_no_deprecation_multiple_warning   rQ   zLtest_ignore_warning.<locals>.context_manager_no_deprecation_multiple_warningc                      rN   rK   rR   r   rB   r   r   (context_manager_no_user_multiple_warning   rQ   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 r>   r   r   r   r   r   test   s   z!test_ignore_warning.<locals>.test)r6   catch_warningssimplefilterr   r8   r)   warnsrL   FutureWarninglen
isinstancemessager   r+   )recordr@   rC   rF   rG   rH   rI   rJ   rM   rP   rS   rT   rU   Zwarning_classr#   Zsilence_warnings_funcrW   r   r?   r   test_ignore_warningD   s   









$r`   c                 C      | | }|S zFunction f

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

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

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

    Results
    -------
    c : list
        Parameter c
    Nr   rc   r   r   r   f_bad_sections   rh   ri   c                 C   s   ||  }|S rb   r   )re   rd   rf   r   r   r   f_bad_order   rh   rj   c                 C   ra   )zFunction f

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

    Returns
    -------
    d : list
        Parameter c
    Nr   )rd   re   dr   r   r   f_too_many_param_docstring  s   rl   c                 C   ra   )zFunction f

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

    Returns
    -------
    c : list
        Parameter c
    Nr   rc   r   r   r   	f_missing  s   rm   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
    Nr   )rd   re   rf   rk   er   r   r   f_check_param_definition(  s   ro   c                   @      e Zd Zdd Zdd ZdS )Klassc                 C   rV   r>   r   selfr0   r/   r   r   r   rm   <     zKlass.f_missingc                 C      dS )zFunction f

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

        Results
        -------
        c : list
            Parameter c
        Nr   rr   r   r   r   ri   ?  s   zKlass.f_bad_sectionsN)__name__
__module____qualname__rm   ri   r   r   r   r   rq   ;      rq   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   ru   )ZMockEstimatorNr   rs   r   r   r   __init__R      zMockEst.__init__c                 C      |S r>   r   rr   r   r   r   fitU  rt   zMockEst.fitc                 C   r~   r>   r   rs   r0   r   r   r   predictX  rt   zMockEst.predictc                 C   r~   r>   r   r   r   r   r   predict_proba[  rt   zMockEst.predict_probac                 C   ru   )N      ?r   r   r   r   r   score^  rt   zMockEst.scoreN)rv   rw   rx   r|   r   r   r   r   r   r   r   r   rz   Q  s    rz   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)rs   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
        N)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   ru   )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
        Nr   r   r   r   r   r     s   	zMockMetaEstimator.predict_probaz-Testing deprecated function with wrong paramsc                 C   ru   )z,Incorrect docstring but should not be testedNr   rr   r   r   r   r     r}   zMockMetaEstimator.fitN)
rv   rw   rx   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 )Nre   )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   rg   rm   r)   r   RuntimeErrorri   rq   ro   r   rz   	__class__rv   ziprj   rl   r   r   r   r   )Z	incorrectZ	mock_metaZmock_meta_namemessagesr.   fr   r   r   test_check_docstring_parameters  s   




	
Sr   c                 C   ru   )zFunction one.

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

    b : str
        Parameter b.

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

    d : int
       Returning
    Nr   rd   re   r   r   r   f_one  s   r   c                 C   ru   )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   ru   )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, errorrd   re   )include_paramsZexclude_paramszThe 'exclude_params' argumentFrf   )include_returnsZ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kwargsr;   r   r   r   ,test_assert_docstring_consistency_arg_checksg  s   "r   zobjects, kwargs, error, warnr    
whitespace)idr   TZ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 grouprn   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   rZ   rL   )r   r   r;   r7   r   r   r   !test_assert_docstring_consistency}  s   1""r   c                 C   ru   )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   ru   )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   ru   )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   )r.   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   Z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*   )Z
regex_fullZregex_wordsZregex_errorr.   r   r   r   5test_assert_docstring_consistency_descr_regex_pattern  s,   "r   c                   @   rp   )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   )rs   Zto_register_funcr   r   r   __call__;  s   zRegistrationCounter.__call__N)rv   rw   rx   r|   r   r   r   r   r   r   7  ry   r   rc                 C   s:   t |tjsJ |dk}|jj|u sJ tj| | d S )Nr   )r]   r(   Zmemmapflags	writeableZtestingZassert_array_equal)input_arrayZ	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(   r,   r   r   ospathdirnamefilenamenameexistsr   )monkeypatchregistration_counterr   dataZ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)Zreturn_folderr$   r   r      znot-an-array)r   r   r   r(   r,   r   r   r   r   r   r   r   r   )
r   r   r   r   folderr   Z
input_listZmmap_data_listZoutput_dataotherr   r   r   test_create_memmap_backed_data\  s,   



r   z constructor_name, container_typelisttuplearrayr   Z
sparse_csrZsparse_csr_arrayZ
sparse_cscZsparse_csc_array	dataframec                   C      t djS Npandas)r)   importorskipZ	DataFramer   r   r   r   r     r   r   seriesc                   C   r   r   )r)   r   Z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   Zpolars_seriesr   r   r'   dtype)r   r   r   r   dtypesN)r   r]   r(   Z
issubdtypetyper   r   r   )constructor_nameZcontainer_typer   Z
superdtype	containerZ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   r-   r   r1   Zcategorical_feature_namesr   r=   )r)   r   r   r   Z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   r-   r1   r   )r)   r   r   schemaZ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 )NZpyarrowr-   r1   r   r   )r)   r   r   r   r   Z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 patternsZhellozBad message)r#   r   zDid not raiseT)r#   Zmay_pass)r   r   Z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㈵>)Z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   )Z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?Zcsr)ZdensityformatN)r   randomr   )r   ZX_sparser   r   r   'test_convert_container_sparse_to_sparseJ  s   r   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 )Nr;   r"   )r^   r=   r   T)r_   ZPyarrowz*
Pyarrow will become a required dependencyr   r'   )
actionr)   r   r=   r^   r6   r7   rX   r\   str)warning_infowarnings_as_errorsr_   r^   r   r   r   check_warnings_as_errorsg  s2   
"r  r  c                 C   s"   t jdddk}t| |d d S )NZSKLEARN_WARNINGS_AS_ERRORS0r  )r   environgetr  )r  r  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  )r6   rX   r   r  )r  r   r   r   test_turn_warnings_into_errors  s   
"r	  )r   )_r   r   r6   Znumpyr(   r)   Zscipyr   Zsklearn.discriminant_analysisr   Zsklearn.treer   Zsklearn.utils._testingr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   Zsklearn.utils.deprecationr   Zsklearn.utils.fixesr   r   r   r   r   Zsklearn.utils.metaestimatorsr   r   markZparametrizer3   r`   rg   ri   rj   rl   rm   ro   rq   rz   r   r   r   r   r   r   r   paramr   r   r   r   r   r   r   r   r   Zxfailr   r   r   ZndarrayZ
csr_matrixr   r   Zint32integerZint64r   Zfloatingr   r   r   r   r   Zskipifr   r   r   r   r   r  r  r	  r   r   r   r   <module>   sN   D	
 1
 





.
0
%
	

	

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