a
    hn                     @   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   \/var/www/html/assistant/venv/lib/python3.9/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 ]J}tjt|d t||d  W d    n1 s\0    Y  t|| q&tjtdd t|| W d    n1 s0    Y  tj	t 
ddd	 }| t 
d
}tjtdd t|| W d    n1 s0    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 sL0    Y  tt ttd  W d    n1 s0    Y  t } t td  W d    n1 s0    Y  t	| dksJ t
| d jtsJ t
| d	 jtsJ t } t td  W d    n1 s*0    Y  t	| d	ksFJ t
| d jts\J t  * t d tttfd W d    n1 s0    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`0    Y  tt |  W d    n1 s0    Y  tt |  W d    n1 s0    Y  tt |  W d    n1 s0    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 s0    Y  tt |
  W d    n1 s0    Y  tt |  W d    n1 s0    Y  tt |  W d    n1 s0    Y  t}d"}tjt|d#" t|}|  W d    n1 sd0    Y  tjt|d#  t|d$d% }W d    n1 s0    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                      s
      d S r>   r   r   r:   r   r   decorator_no_warning_multiplen   s    z:test_ignore_warning.<locals>.decorator_no_warning_multiplec                      s
      d S r>   r   r   r9   r   r    decorator_no_deprecation_warningr   s    z=test_ignore_warning.<locals>.decorator_no_deprecation_warningc                      s
      d S r>   r   r   rC   r   r   decorator_no_user_warningv   s    z6test_ignore_warning.<locals>.decorator_no_user_warningc                      s
      d S r>   r   r   rA   r   r   )decorator_no_deprecation_multiple_warningz   s    zFtest_ignore_warning.<locals>.decorator_no_deprecation_multiple_warningc                      s
      d S r>   r   r   rA   r   r   "decorator_no_user_multiple_warning~   s    z?test_ignore_warning.<locals>.decorator_no_user_multiple_warningc                      s0   t      W d    n1 s"0    Y  d S r>   )r   r   rC   r   r   context_manager_no_warning   s    z7test_ignore_warning.<locals>.context_manager_no_warningc                      s8   t ttfd    W d    n1 s*0    Y  d S Nr<   )r   r8   UserWarningr   rA   r   r   #context_manager_no_warning_multiple   s    z@test_ignore_warning.<locals>.context_manager_no_warning_multiplec                      s4   t td    W d    n1 s&0    Y  d S rI   r   r8   r   rC   r   r   &context_manager_no_deprecation_warning   s    zCtest_ignore_warning.<locals>.context_manager_no_deprecation_warningc                      s4   t td    W d    n1 s&0    Y  d S rI   r   rJ   r   rC   r   r   context_manager_no_user_warning   s    z<test_ignore_warning.<locals>.context_manager_no_user_warningc                      s4   t td    W d    n1 s&0    Y  d S rI   rL   r   rA   r   r   /context_manager_no_deprecation_multiple_warning   s    zLtest_ignore_warning.<locals>.context_manager_no_deprecation_multiple_warningc                      s4   t td    W d    n1 s&0    Y  d S rI   rN   r   rA   r   r   (context_manager_no_user_multiple_warning   s    zEtest_ignore_warning.<locals>.context_manager_no_user_multiple_warningzA'obj' should be a callable.+you should use 'category=UserWarning'r"   c                   S   s   d S r>   r   r   r   r   r   test   s    z!test_ignore_warning.<locals>.test)r6   catch_warningssimplefilterr   r8   r)   warnsrJ   FutureWarninglen
isinstancemessager   r+   )recordr@   rB   rD   rE   rF   rG   rH   rK   rM   rO   rP   rQ   Zwarning_classr#   Zsilence_warnings_funcrR   r   r?   r   test_ignore_warningD   s    

*,
,
.

0

&&&&

&&&&&r[   c                 C   s   | | }|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   s    ra   c                 C   s   | | }|S )zFunction f

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

    Results
    -------
    c : list
        Parameter c
    r   r]   r   r   r   f_bad_sections   s    rb   c                 C   s   ||  }|S r\   r   )r_   r^   r`   r   r   r   f_bad_order   s    rc   c                 C   s   | | }|S )zFunction f

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

    Returns
    -------
    d : list
        Parameter c
    r   )r^   r_   dr   r   r   f_too_many_param_docstring  s    re   c                 C   s   | | }|S )zFunction f

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

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

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

        Results
        -------
        c : list
            Parameter c
        Nr   rj   r   r   r   rb   ?  s    zKlass.f_bad_sectionsN)__name__
__module____qualname__rf   rb   r   r   r   r   ri   ;  s   ri   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   s   dS )ZMockEstimatorNr   rk   r   r   r   __init__R  s    zMockEst.__init__c                 C   s   |S r>   r   rj   r   r   r   fitU  s    zMockEst.fitc                 C   s   |S r>   r   rk   r0   r   r   r   predictX  s    zMockEst.predictc                 C   s   |S r>   r   rs   r   r   r   predict_proba[  s    zMockEst.predict_probac                 C   s   dS )N      ?r   rs   r   r   r   score^  s    zMockEst.scoreN)rl   rm   rn   rq   rr   rt   ru   rw   r   r   r   r   ro   Q  s
   ro   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)rk   rz   r   r   r   rq   c  s    zMockMetaEstimator.__init__c                 C   s   t | jdS )Nrt   hasattrrz   rp   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
        )rz   rt   rs   r   r   r   rt   m  s    	zMockMetaEstimator.predictc                 C   s   t | jdS )Nrw   r{   rp   r   r   r   r}   x  r~   z%Testing a deprecated delegated methodc                 C   s   dS )zThis is available only if delegate has score.

        Parameters
        ---------
        y : ndarray
            Parameter y
        Nr   rs   r   r   r   rw   x  s    zMockMetaEstimator.scorec                 C   s   t | jdS )Nru   r{   rp   r   r   r   r}     r~   c                 C   s   |S )zThis is available only if delegate has predict_proba.

        Parameters
        ---------
        X : ndarray
            Parameter X
        r   rs   r   r   r   ru     s    	zMockMetaEstimator.predict_probaz-Testing deprecated function with wrong paramsc                 C   s   dS )z,Incorrect docstring but should not be testedNr   rj   r   r   r   rr     s    zMockMetaEstimator.fitN)
rl   rm   rn   rq   r   rt   r   rw   ru   rr   r   r   r   r   rx   b  s   




	


rx   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sHJ tjtdd t t W d    n1 st0    Y  tjtdd t tj W d    n1 s0    Y  t t} t	t
 d}|jj}| g dksJ 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 )Nr_   )ignorezUnknown section Resultsr"   zUnknown section Parameterry   )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'].ru   z&potentially wrong underline length... zParameters z--------- in z.scorez.fitr   r   r   z
"%s"
 not in 
"%s")r   ra   rf   r)   r   RuntimeErrorrb   ri   rh   rx   ro   	__class__rl   ziprc   re   rt   ru   rw   rr   )Z	incorrectZ	mock_metaZmock_meta_namemessagesr.   fr   r   r   test_check_docstring_parameters  s    &(



	
Sr   c                 C   s   dS )zFunction one.

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

    b : str
        Parameter b.

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

    d : int
       Returning
    Nr   r^   r_   r   r   r   f_one  s    r   c                 C   s   dS )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   s   dS )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   n1 s00    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, errorr^   r_   )include_paramsZexclude_paramszThe 'exclude_params' argumentFr`   )include_returnsZexclude_returnszThe 'exclude_returns' argumentc                 C   sB   t jt|d  t| fi | W d   n1 s40    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 grouprg   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   |rDt jt|d  t| fi | W d   q1 s80    Y  nT|rt jt|d  t| fi | W d   q1 s|0    Y  nt| fi | dS )z;Check `assert_docstring_consistency` gives correct results.r"   N)r)   r   r*   r   rU   rJ   )r   r   r;   r7   r   r   r   !test_assert_docstring_consistency}  s    100r   c                 C   s   dS )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  s    
r   c                 C   s   dS )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   s   dS )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  s    
r   c                  C   sH   d} t jt| d" ttttgdd W d   n1 s:0    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	   n1 s0    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                   @   s   e Zd Zdd Zdd ZdS )RegistrationCounterc                 C   s
   d| _ d S )Nr   )nb_callsrp   r   r   r   rq   8  s    zRegistrationCounter.__init__c                 C   s    |  j d7  _ |jtu sJ d S )Nr'   )r   funcr   )rk   Zto_register_funcr   r   r   __call__;  s    zRegistrationCounter.__call__N)rl   rm   rn   rq   r   r   r   r   r   r   7  s   r   rc                 C   s:   t |tjsJ |dk}|jj|u s(J tj| | d S )Nr   )rX   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 sT0    Y  tjdkrxtj|rxJ |jdksJ d}t||d,}t|||d tj	|j
}W d    n1 s0    Y  tjdkrtj|rJ |jdksJ 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snJ |jdks|J d}t||d}t||| |jdksJ ||d |d g}t|}t||D ]\}}t|| q|jd	ksJ t|d
g\}}	t|| |	d
ksJ 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   s   t djS Npandas)r)   importorskipZ	DataFramer   r   r   r   r}     r~   r}   seriesc                   C   s   t djS r   )r)   r   ZSeriesr   r   r   r   r}     r~   indexc                   C   s   t djS r   )r)   r   Indexr   r   r   r   r}     r~   slicezdtype, superdtypec                 C   s   | dv r| }ddg}t || |d}t||s2J | dv rTtt|d |sJ n6t|drn|j|ksJ nt|dr|jd |ksJ 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   rX   r(   Z
issubdtypetyper|   r   r   )constructor_name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s6J 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s8J 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   sN   ddg}t jtdt d t|| |d W d   n1 s@0    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   sJ  t t t W d    n1 s$0    Y  t tdd} tdW d    n1 sX0    Y  | jslJ t tddgd} tdW d    n1 s0    Y  | jsJ tj tdd@ t t} tdW d    n1 s0    Y  W d    n1 s0    Y  | jrJ tj tddD t tdd} t W d    n1 sT0    Y  W d    n1 st0    Y  | jrJ tj tddF t tdd} tdW d    n1 s0    Y  W d    n1 s0    Y  | jrJ tj td	dF t td
d} tdW d    n1 s80    Y  W d    n1 sX0    Y  | jrnJ tj tddH t td
dd} tdW d    n1 s0    Y  W d    n1 s0    Y  | jrJ tj tdd: t t} W d    n1 s0    Y  W d    n1 s20    Y  | jrHJ t td
dd} W d    n1 sn0    Y  | jrJ t ttf t W d    n1 s0    Y  t ttf t W d    n1 s0    Y  t t> t ttf W d    n1 s0    Y  W d    n1 s<0    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  sX    
$&
&

FFHHH
@ &&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 sP0    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 s0    Y  tt( t tjdgtjdd W d    n1 s0    Y  t tjdgtjddd	d
 d S )Ng㈵ ?r   rv   gX ?gc^  ?g55  ?gh㈵>g        gh㈵>)Zatol)r	   r(   r   float32r)   r   r*   float64r   r   r   r   "test_float32_aware_assert_allclose   s    666r   zcannot start subprocessc                  C   s   d} t |  d} tjtdd t |  W d    n1 s<0    Y  d} tjtdd t | dd W d    n1 sz0    Y  dd	d
g} tjtdd t | dd W d    n1 s0    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rR|rRtj| j| jd" tj| j| jd W d    n1 sH0    Y  | j dkrtjddz}| j}d|v r|d}tj|| jd |rt|d	ksnd
sJ |rt	|d	 j|ksJ |d	 j| jksJ W d    n1 s0    Y  d S )Nr;   r"   )rY   r=   r   T)rZ   ZPyarrowz*
Pyarrow will become a required dependencyr   r'   )
actionr)   r   r=   rY   r6   r7   rS   rW   str)warning_infowarnings_as_errorsrZ   rY   r   r   r   check_warnings_as_errorsg  s&    $
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    n1 s00    Y  d S )NTr   )r6   rS   r   r   )r   r   r   r   test_turn_warnings_into_errors  s    
r   )r   )_r   r   r6   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[   ra   rb   rc   re   rf   rh   ri   ro   rx   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>   sL  D	
 1
 





.
0
%	

	


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