
    0Phn                     j	   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	 Z&ej'        (                    d
e           d             Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0 G d d          Z1 G d d          Z2 G d d          Z3ed             Z4d Z5d Z6d Z7ed             Z8eej'        (                    de5e6gdgd gd!d"fe5e6gd#d$gd%d&fg          d'                         Z9eej'        (                    d( ej:        e5e6gd)dgid*d*d+,           ej:        e5e6gd-d.id*d*d/,           ej:        e5e6e7gd)dgid0d*d1,           ej:        e5e6e7gd)d gid2d*d3,           ej:        e6e7gd)d4gid5d*d6,           ej:        e5e6gd.d gd!d*d7d8,          g          d9                         Z;d: Z<d; Z=d< Z>ed=             Z?ed>             Z@ G d? d@          ZAdkdBZBdC ZCej'        D                    edDE          dF             ZEej'        (                    dGdHeFfdIeGfdJejH        fdKejI        fg eJdLdMge!           eJdNdOge           dPdQ fdRdS fdTdU fdVeKf          ej'        (                    dWejL        ejM        fejN        ejM        fejO        ejP        fejQ        ejP        fg          dX                         ZRdY ZSdZ ZTd[ ZUej'        V                    e# e"d\          k    d]E          ej'        (                    d^dMdOg          ej'        (                    d_ejL        ejN        ejO        ejQ        g          d`                                     ZWda ZXdb ZYej'        D                    edcE          dd             ZZej'        (                    d^dLdN ej:        dMej'        V                    e# e"d\          k     d]E          e           ej:        dOej'        V                    e# e"d\          k     d]E          e          g          df             Z[dg Z\ej'        (                    dh e                      di             Z]ej'        (                    dh e                      dj             Z^dS )l    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                      t                      } t                      }t          | d           t          |d           |j        dk    sJ d S )N   )r   r   r   random_state)ldatrees     `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/utils/tests/test_testing.pytest_set_random_stater"   '   sR    
$
&
&C!##DS!T1!!!!!!    csr_containerc                    t          j        d                              dd          }d} | |          }||fD ]X}t          j        t
          |          5  t          ||dz             d d d            n# 1 swxY w Y   t          ||           Yt          j        t          d          5  t          ||           d d d            n# 1 swxY w Y   t          j	        t          j
        d          d	                                          } | t          j
        d
                    }t          j        t
          d          5  t          ||           d d d            d S # 1 swxY w 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Bs          r!   !test_assert_allclose_dense_sparser<   0   s   
	!Q""A
#CaAV + +]>555 	3 	3(AE222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3$Q****	z)F	G	G	G + +$Q***+ + + + + + + + + + + + + + + 	RWQZZ+++1133Abgfoo&&A	~-C	D	D	D + +$Q***+ + + + + + + + + + + + + + + + + +s6   A77A;	>A;	.CCCE&&E*-E*c                     d d t          j                    5  t          j        d           t                     t          t                     d d d            n# 1 swxY w Y   t          j        t                    5   t          t                                 d d d            n# 1 swxY w Y   t          j                    5 }  t          t                                 d d d            n# 1 swxY w Y   t          |           dk    sJ t          | d         j        t                    sJ t          | d         j        t                    sJ t          j                    5 }  t          t                                 d d d            n# 1 swxY w Y   t          |           dk    sJ t          | d         j        t                    sJ t          j                    5  t          j        d           t          t          t          f           d d d            n# 1 swxY w Y   t          fd            }t          t          t          f          fd	            }t          t                    fd
            }t          t                    fd            }t          t                    fd            }t          t                    fd            }t          j                    5  t          j        d            |              |              |             d d d            n# 1 swxY w Y   t          j        t                    5   |             d d d            n# 1 swxY w Y   t          j        t                    5   |             d d d            n# 1 swxY w Y   t          j        t                    5   |             d d d            n# 1 swxY w Y   fd}fd}fd}	fd}
fd}fd}t          j                    5  t          j        d            |              |              |	             d d d            n# 1 swxY w Y   t          j        t                    5   |
             d d d            n# 1 swxY w Y   t          j        t                    5   |             d d d            n# 1 swxY w Y   t          j        t                    5   |             d d d            n# 1 swxY w Y   t          }d}t          j        t          |          5   t          |                    } |             d d d            n# 1 swxY w Y   t          j        t          |          5  t          |          d             }d d d            d S # 1 swxY w Y   d S )Nc                  :    t          j        dt                     d S Nzdeprecation warningwarningswarnDeprecationWarning r#   r!   _warning_functionz.test_ignore_warning.<locals>._warning_functionG   s    +-?@@@@@r#   c                  b    t          j        dt                     t          j        d           d S r?   r@   rD   r#   r!   _multiple_warning_functionz7test_ignore_warning.<locals>._multiple_warning_functionJ   s-    +-?@@@+,,,,,r#   errorcategoryr)   r   r,   c                  0                                 d S NrD   )rG   rE   s   r!   decorator_no_warningz1test_ignore_warning.<locals>.decorator_no_warningi   s'    ""$$$$$r#   c                                     d S rL   rD   rG   s   r!   decorator_no_warning_multiplez:test_ignore_warning.<locals>.decorator_no_warning_multiplen       ""$$$$$r#   c                                     d S rL   rD   rE   s   r!    decorator_no_deprecation_warningz=test_ignore_warning.<locals>.decorator_no_deprecation_warningr       r#   c                                     d S rL   rD   rS   s   r!   decorator_no_user_warningz6test_ignore_warning.<locals>.decorator_no_user_warningv   rU   r#   c                                     d S rL   rD   rO   s   r!   )decorator_no_deprecation_multiple_warningzFtest_ignore_warning.<locals>.decorator_no_deprecation_multiple_warningz   rQ   r#   c                                     d S rL   rD   rO   s   r!   "decorator_no_user_multiple_warningz?test_ignore_warning.<locals>.decorator_no_user_multiple_warning~   rQ   r#   c                  j    t                      5                 d d d            d S # 1 swxY w Y   d S rL   )r   rS   s   r!   context_manager_no_warningz7test_ignore_warning.<locals>.context_manager_no_warning   s     	  	 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   (,,c                      t          t          t          f          5                 d d d            d S # 1 swxY w Y   d S NrI   )r   rC   UserWarningrO   s   r!   #context_manager_no_warning_multiplez@test_ignore_warning.<locals>.context_manager_no_warning_multiple   s    '9;&GHHH 	) 	)&&(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   6::c                  x    t          t                    5                 d d d            d S # 1 swxY w Y   d S r_   r   rC   rS   s   r!   &context_manager_no_deprecation_warningzCtest_ignore_warning.<locals>.context_manager_no_deprecation_warning   s    &8999 	  	 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	    /33c                  x    t          t                    5                 d d d            d S # 1 swxY w Y   d S r_   r   r`   rS   s   r!   context_manager_no_user_warningz<test_ignore_warning.<locals>.context_manager_no_user_warning   s    k222 	  	 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 re   c                  x    t          t                    5                 d d d            d S # 1 swxY w Y   d S r_   rc   rO   s   r!   /context_manager_no_deprecation_multiple_warningzLtest_ignore_warning.<locals>.context_manager_no_deprecation_multiple_warning   s    &8999 	) 	)&&(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)re   c                  x    t          t                    5                 d d d            d S # 1 swxY w Y   d S r_   rg   rO   s   r!   (context_manager_no_user_multiple_warningzEtest_ignore_warning.<locals>.context_manager_no_user_multiple_warning   s    k222 	) 	)&&(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)re   zA'obj' should be a callable.+you should use 'category=UserWarning'r'   c                      d S rL   rD   rD   r#   r!   testz!test_ignore_warning.<locals>.test   s    Dr#   )rA   catch_warningssimplefilterr   rC   r0   warnsr`   FutureWarninglen
isinstancemessager   r2   )recordrM   rP   rT   rW   rY   r[   r]   ra   rd   rh   rj   rl   warning_classr(   silence_warnings_funcrn   rG   rE   s                    @@r!   test_ignore_warningry   D   s
   A A A- - -
 
	 	"	" H Hg&&&)***)4FGGGG	H H H H H H H H H H H H H H H 
(	)	) C C@)K@@@BBBC C C C C C C C C C C C C C C 
 N6K2]KKKMMMN N N N N N N N N N N N N N Nv;;!fQi');<<<<<fQi'55555	 L6I2[IIIKKKL L L L L L L L L L L L L L Lv;;!fQi');<<<<<		 	"	" W Wg&&&)5G4UVVVVW W W W W W W W W W W W W W W % % % % % _% 1;?@@@% % % % A@% 0111    21 k***    +* 0111% % % % 21% k***% % % % +*% 
	 	"	" + +g&&&%%'''((***+ + + + + + + + + + + + + + + 
(	)	) $ $!!###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $	k	"	" 4 4113334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	(	)	) - -**,,,- - - - - - - - - - - - - - -         ) ) ) ) )                  ) ) ) ) )) ) ) ) ) 
	 	"	" 1 1g&&&""$$$++---..0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
(	)	) * *'')))* * * * * * * * * * * * * * *	k	"	" : :77999: : : : : : : : : : : : : : :	(	)	) 3 3002223 3 3 3 3 3 3 3 3 3 3 3 3 3 3  MOE	z	/	/	/     > > >?P Q Q                              
z	/	/	/  		'	'	 	 
(	'	                 s  :A""A&)A&B11B58B5C::C>C>1FF #F 12H//H36H33MM
M
*NNN%N<<O O  O77O;>O;33Q22Q69Q6R--R14R1S((S,/S,T##T'*T'#VVV'WWWc                     | |z   }|S zFunction f

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

    Returns
    -------
    c : list
        Parameter c
    rD   abcs      r!   f_okr           	
AAHr#   c                     | |z   }|S )zFunction f

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

    Results
    -------
    c : list
        Parameter c
    rD   r|   s      r!   f_bad_sectionsr      r   r#   c                     || z   }|S r{   rD   )r~   r}   r   s      r!   f_bad_orderr      r   r#   c                     | |z   }|S )zFunction f

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

    Returns
    -------
    d : list
        Parameter c
    rD   )r}   r~   ds      r!   f_too_many_param_docstringr     s    " 	
AAHr#   c                     | |z   }|S )zFunction f

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

    Returns
    -------
    c : list
        Parameter c
    rD   r|   s      r!   	f_missingr     s     	
AAHr#   c                     | |z   |z   |z   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
    rD   )r}   r~   r   r   es        r!   f_check_param_definitionr   (  s      q519q=r#   c                       e Zd Zd Zd ZdS )Klassc                     d S rL   rD   selfr9   r8   s      r!   r   zKlass.f_missing<  s    r#   c                     dS )zFunction f

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

        Results
        -------
        c : list
            Parameter c
        NrD   r   s      r!   r   zKlass.f_bad_sections?  s	     	r#   N)__name__
__module____qualname__r   r   rD   r#   r!   r   r   ;  s2              r#   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )MockEstc                     dS )MockEstimatorNrD   r   s    r!   __init__zMockEst.__init__R        r#   c                     |S rL   rD   r   s      r!   fitzMockEst.fitU      r#   c                     |S rL   rD   r   r9   s     r!   predictzMockEst.predictX  r   r#   c                     |S rL   rD   r   s     r!   predict_probazMockEst.predict_proba[  r   r#   c                     dS )N      ?rD   r   s     r!   scorezMockEst.score^  s    sr#   N)r   r   r   r   r   r   r   r   rD   r#   r!   r   r   Q  s_                    r#   r   c                       e Zd Zd Z ed           d             Z ed            ed          d                         Z ed           d             Z ed	          d
             Z	dS )MockMetaEstimatorc                     || _         dS )zMetaEstimator to check if doctest on delegated methods work.

        Parameters
        ---------
        delegate : estimator
            Delegated estimator.
        Ndelegate)r   r   s     r!   r   zMockMetaEstimator.__init__c  s     !r#   c                 ,    t          | j        d          S )Nr   hasattrr   r   s    r!   <lambda>zMockMetaEstimator.<lambda>m  s    wt}i@@ r#   c                 6    | j                             |          S )zThis is available only if delegate has predict.

        Parameters
        ----------
        y : ndarray
            Parameter y
        )r   r   r   s     r!   r   zMockMetaEstimator.predictm  s     }$$Q'''r#   c                 ,    t          | j        d          S )Nr   r   r   s    r!   r   zMockMetaEstimator.<lambda>x  s    wt}g>> r#   z%Testing a deprecated delegated methodc                     dS )zThis is available only if delegate has score.

        Parameters
        ---------
        y : ndarray
            Parameter y
        NrD   r   s     r!   r   zMockMetaEstimator.scorex  r   r#   c                 ,    t          | j        d          S )Nr   r   r   s    r!   r   zMockMetaEstimator.<lambda>  s    wt}oFF r#   c                     |S )zThis is available only if delegate has predict_proba.

        Parameters
        ---------
        X : ndarray
            Parameter X
        rD   r   s     r!   r   zMockMetaEstimator.predict_proba  s	     r#   z-Testing deprecated function with wrong paramsc                     dS )z,Incorrect docstring but should not be testedNrD   r   s      r!   r   zMockMetaEstimator.fit  r   r#   N)
r   r   r   r   r   r   r   r   r   r   rD   r#   r!   r   r   b  s        ! ! ! \@@AA( ( BA( \>>??Z788  98 @? \FFGG  HG Z?@@; ; A@; ; ;r#   r   c                     t          t                    } | g k    sJ t          t          dg          } | g k    sJ t          t          dg          } | g k    sJ t          j        t
          d          5  t          t                     d d d            n# 1 swxY w Y   t          j        t
          d          5  t          t          j                   d d d            n# 1 swxY w Y   t          t                    } t          t                                }|j        j        }| g dk    sJ g dg d	g d
g ddd| dz   ddddddgdd| dz   dz   dddgdd| dz   dddgdd| dz   ddddgg}t          |t          t          t          t          j        |j        |j        |j        |j        g          D ]+\  }}t          |          } || k    sJ d|d| d             ,d S )!Nr~   )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
"z"
 not in 
"")r   r   r   r0   r   RuntimeErrorr   r   r   r   r   	__class__r   zipr   r   r   r   r   r   )	incorrect	mock_metamock_meta_namemessagesr7   fs         r!   test_check_docstring_parametersr     s:   *400I????*4>>>I????*9cUCCCI????	|+D	E	E	E 3 3">2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	|+F	G	G	G 9 9"5#78889 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ++CDDI!799555I(1N        		
 		
 		
	
 	
 	
		
 		
 		
		
 		
 		
 J.JJJKC 	
 C.CCCD 5	
 H.HHHI4	
 V.VVVV4 		
OQHf &O#OM		
  M MQ /q11	iSSS)))!LM Ms$   6BBB=C##C'*C'c                     dS )zFunction one.

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

    b : str
        Parameter b.

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

    d : int
       Returning
    NrD   r}   r~   s     r!   f_oner     s	    ( 	Dr#   c                     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
    NrD   r   s     r!   f_twor   -  s	    . 	Dr#   c                     dS )zFunction two.

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

    b : str
        Parameter B!

    e :
        Extra parameter.

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

    d : int
       Returning
    NrD   r   s     r!   f_threer   G  s	    , 	Dr#   c                      t          j        t          d          5  t          dt          g           ddd           dS # 1 swxY w Y   dS )z1Check error raised when `objects` incorrect type.zAll 'objects' must be one ofr'   stringN)r0   r   	TypeErrorr   r   rD   r#   r!   -test_assert_docstring_consistency_object_typer   `  s     
y(F	G	G	G 8 8$h%67778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8s   A  AAzobjects, kwargs, errorr}   r~   )include_paramsexclude_paramszThe 'exclude_params' argumentFr   )include_returnsexclude_returnszThe 'exclude_returns' argumentc                     t          j        t          |          5  t          | fi | ddd           dS # 1 swxY w Y   dS )z?Check `assert_docstring_consistency` argument checking correct.r'   N)r0   r   r   r   )objectskwargsrH   s      r!   ,test_assert_docstring_consistency_arg_checksr   g  s    $ 
y	.	.	. 8 8$W777778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8s   7;;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 groupr   zPThe type specification of Parameter 'e' is inconsistent between\n\['f_two'\] andz
empty typez,Checking was skipped for Parameters: \['e'\]z	skip warnc                 4   |rCt          j        t          |          5  t          | fi | ddd           dS # 1 swxY w Y   dS |rCt          j        t
          |          5  t          | fi | ddd           dS # 1 swxY w Y   dS t          | fi | dS )z;Check `assert_docstring_consistency` gives correct results.r'   N)r0   r   r1   r   rq   r`   )r   r   rH   rB   s       r!   !test_assert_docstring_consistencyr   }  sQ   b  8]>777 	< 	<(;;F;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<	 8\+T222 	< 	<(;;F;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	%W7777777s   9= =#A>>BBc                     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.
    NrD   labelss    r!   f_fourr     	     	Dr#   c                     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.
    NrD   r   s    r!   f_fiver     s	     	Dr#   c                     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.
    NrD   r   s    r!   f_sixr     r   r#   c                      d} t          j        t          |           5  t          t          t
          t          gd           ddd           dS # 1 swxY 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)r0   r   r1   r   r   r   r   )r7   s    r!   +test_assert_docstring_consistency_error_msgr     s    (CT 
~S	1	1	1 S S$ffe%<TRRRRS S S S S S S S S S S S S S S S S Ss   $AAAc            	      4   d} t          t          t          t          gdd                    |                                                      d}t          t          t          t          gdd                    |                                                     d}d}t          j        t          |          5  t          t          t          t          gdd                    |                                                     d	d	d	           d	S # 1 swxY w 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splitr0   r   r1   )
regex_fullregex_wordsregex_errorr7   s       r!   5test_assert_docstring_consistency_descr_regex_patternr     sW   
	&  !	HHZ%5%5%7%788    -K 	HH[%6%6%8%899    9K
PC	~S	1	1	1 
 
$VU# #):):)<)< = =	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   6A
DDDc                       e Zd Zd Zd ZdS )RegistrationCounterc                     d| _         d S )Nr   )nb_callsr   s    r!   r   zRegistrationCounter.__init__8  s    r#   c                 F    | xj         dz  c_         |j        t          u sJ d S )Nr,   )r   funcr   )r   to_register_funcs     r!   __call__zRegistrationCounter.__call__;  s,    $666666r#   N)r   r   r   r   r   rD   r#   r!   r   r   7  s2          7 7 7 7 7r#   r   rc                     t          |t          j                  sJ |dk    }|j        j        |u sJ t          j                            | |           d S )Nr   )rt   r-   memmapflags	writeabletestingassert_array_equal)input_array	mmap_data	mmap_moder  s       r!   check_memmapr	  @  sX    i+++++S I?$	1111J!!+y99999r#   c                    t                      }|                     t          d|           t          j        d          }t          |          5 }t          ||           t          j        	                    |j
                  }d d d            n# 1 swxY w Y   t          j        dk    r!t          j                            |          rJ |j        dk    sJ d}t          ||          5 }t          |||           t          j        	                    |j
                  }d d d            n# 1 swxY w Y   t          j        dk    r!t          j                            |          rJ |j        dk    sJ d S )Nregisterr   ntr,   r+r  r)   )r   setattratexitr-   r4   r   r	  ospathdirnamefilenamenameexistsr   )monkeypatchregistration_counterr  datatemp_folderr  s         r!   test_tempmemmapr  G  s   .00
,@AAA'!**K	K	 	  5D[$'''goodm445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 
w$7>>+.....(A----I	K9	5	5	5 5[$)<<<<goodm445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 
w$7>>+.....(A------s$   5BBB+7D..D25D2zmemmap not fully supported)reasonc                    t                      }|                     t          d|           t          j        d          }t          |          }t          ||           |j        dk    sJ t          |d          \  }}t          ||           |t          j	        
                    |j                  k    sJ |j        dk    sJ d}t          ||          }t          |||           |j        dk    sJ ||dz   |dz   g}t          |          }t          ||          D ]\  }}t          ||           |j        d	k    sJ t          |d
g          \  }}	t          ||           |	d
k    sJ d S )Nr  r   r,   T)return_folderr)   r  r     znot-an-array)r   r  r  r-   r4   r   r	  r   r  r  r  r  r   )
r  r  r  r  folderr  
input_listmmap_data_listoutput_dataothers
             r!   test_create_memmap_backed_datar%  \  s   .00
,@AAA'!**K$[11Dd###(A----,[MMMLD&d###RW__T]333333(A----I$[IFFFDdI...(A----{Qa@J.z::N ^<< ( (T[$''''(A----2K3PQQKk***N""""""r#   z constructor_name, container_typelisttuplearrayr   
sparse_csrsparse_csr_array
sparse_cscsparse_csc_array	dataframec                  4    t          j        d          j        S Npandas)r0   importorskip	DataFramerD   r#   r!   r   r     s    f1(;;E r#   seriesc                  4    t          j        d          j        S r/  )r0   r1  SeriesrD   r#   r!   r   r     s    6.x88? r#   indexc                  4    t          j        d          j        S r/  )r0   r1  IndexrD   r#   r!   r   r     s    &-h77= r#   slicezdtype, superdtypec                 Z   | dv r
 |            }ddg}t          || |          }t          ||          sJ | dv r,t          j        t	          |d                   |          sJ dS t          |d          r|j        |k    sJ dS t          |d          r|j        d         |k    sJ dS dS )	z\Check that we convert the container to the right type of array with the
    right data type.)r-  polarsr3  polars_seriesr6  r   r,   dtype)r&  r'  r6  r>  dtypesN)r   rt   r-   
issubdtypetyper   r>  r?  )constructor_namecontainer_typer>  
superdtype	containercontainer_converteds         r!   test_convert_containerrG  {  s   D VVV ())AI,  
 )>:::::555 }T"5a"899:FFFFFFF	$g	.	. 6"(E111111	$h	/	/ 6")!,55556 655r#   c                      t          j        d           t          dggddgdg          } | j        j        d         dk    sJ d S )Nr0  r6   r-  r:   categorical_feature_namesr   rJ   )r0   r1  r   r?  iloc)dfs    r!   (test_convert_container_categories_pandasrM    sZ    
!!!	
seu
 
 
B 9>!
******r#   c                      t          j        d          } t          dggddgdg          }|j        d         |                                 k    sJ d S )Nr;  r6   r:   rI  )r0   r1  r   schemaCategorical)plrL  s     r!   (test_convert_container_categories_polarsrR    sY    		X	&	&B	cUGXuQTPU	V	V	VB9S>R^^--------r#   c                      t          j        d          } t          dggddgdg          }t          |j        d         j                  | j        u sJ d S )Npyarrowr6   r:   rI  r   )r0   r1  r   rA  rO  DictionaryType)parL  s     r!   )test_convert_container_categories_pyarrowrW    s]    		Y	'	'B	cUGYRUQV	W	W	WB	!!""b&7777777r#   z1.8z-sparse arrays are available as of scipy 1.8.0rB  r>  c                     ddg}t          j        t          dt                     5  t	          || |           ddd           dS # 1 swxY 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)r0   r   r2   r   r   )rB  r>  rE  s      r!   7test_convert_container_raise_when_sparray_not_availablerY    s     AI	CzCC
 
 
 E E 	9&6eDDDD	E E E E E E E E E E E E E E E E E Es   AAAc                  z   t          t                    5  t                      # 1 swxY w Y   t          t          d          5 } t          d          # 1 swxY w Y   | j        sJ t          t          ddg          5 } t          d          # 1 swxY w Y   | j        sJ t          j         t          d          5  t          t                    5 } t	          d          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   | j        rJ t          j         t
          d          5  t          t          d          5 } t	                      # 1 swxY w Y   	 d d d            n# 1 swxY w Y   | j        rJ t          j         t          d          5  t          t          d          5 } t	          d          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   | j        rJ t          j         t
          d	          5  t          t          d
          5 } t          d          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   | j        rJ t          j         t
          d          5  t          t          d
d          5 } t          d          # 1 swxY w Y   	 d d d            n# 1 swxY w Y   | j        rJ t          j         t
          d          5  t          t                    5 } 	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | j        rJ t          t          d
d          5 } 	 d d d            n# 1 swxY w Y   | j        rJ t          t          t          f          5  t                      # 1 swxY w Y   t          t          t          f          5  t	                      # 1 swxY w Y   t          j         t
                    5  t          t          t          f          5  	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w 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_matchedr0   r2   r1   )cms    r!   test_raisesr`    s    
			  kk        
		/	/	/ -2+,,,- - - - - - - -     
	.-!@	A	A	A -R+,,,- - - - - - - -     
z)>	?	?	? 4 4I 	4"2333	4 	4 	4 	4 	4 	4 	4 	4 	44 4 4 4 4 4 4 4 4 4 4 4 4 4 4 $$$$ 
~-B	C	C	C  I'<=== 	,,	 	 	 	 	 	 	 	 	               $$$$ 
z)>	?	?	? 4 4I%6777 	422333	4 	4 	4 	4 	4 	4 	4 	4 	44 4 4 4 4 4 4 4 4 4 4 4 4 4 4 $$$$ 
L
 
 
 + + IW--- 	+M***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	++ + + + + + + + + + + + + + +
 $$$$ 
~-B	C	C	C + +IW6KLLL 	+PRM***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	++ + + + + + + + + + + + + + + $$$$ 
~_	=	=	=  I 	"	 	 	 	 	 	 	 	 	 	 	 	 	 	 	               $$$$ 
	4	8	8	8 B              $$$$ 
J'	(	(  kk       	J'	(	(  ll       	~	&	&  Y
+,, 	 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	                 s  $((AAABBB C=C%%C)	)C=,C)	-C==DD,E*EE	E*E	E**E.1E.G0G  G	GG	GGGIH..H2	2I5H2	6II
I
5J5JJ!	!J5$J!	%J55J9<J9$L9L;LL	LL	LL"%L"	MMMNNN;O

OO.P0
PP0P	P0P	 P00P47P4c                  d   t          t          j        dgt          j                  d           t	          j        t                    5  t          t          j        dgt          j                  d           d d d            n# 1 swxY w Y   t          t          j        dgt          j                  d           t	          j        t                    5  t          t          j        dgt          j                  d           d d d            n# 1 swxY w Y   t	          j        t                    5  t          t          j        dgt          j                  d           d d d            n# 1 swxY w Y   t          t          j        dgt          j                  dd	
           d S )Ng㈵ ?r=  r   gX ?gc^  ?g55  ?gh㈵>g        gh㈵>)atol)r
   r-   r(  float32r0   r   r1   float64rD   r#   r!   "test_float32_aware_assert_allclosere     sE   BHj\<<<cBBB	~	&	& G G*RZ@@@#FFFG G G G G G G G G G G G G G G
 BHj\<<<cBBB	~	&	& G G*RZ@@@#FFFG G G G G G G G G G G G G G G 
~	&	& A A$rz:::C@@@A A A A A A A A A A A A A A ABHdV2:666$GGGGGGs6   	0BB	B	0DDD80E44E8;E8zcannot start subprocessc                     d} t          |            d} t          j        t          d          5  t          |            d d d            n# 1 swxY w Y   d} t          j        t          d          5  t          | d           d d d            n# 1 swxY w Y   d                    d	d
g          } t          j        t          d          5  t          | d           d d d            d S # 1 swxY w 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   r0   r   r1   r   )codes    r!   ,test_assert_run_python_script_without_outputrj  2  s   D+D111)D	~-A	B	B	B 6 6/5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 *D	J
 
 
 L L 	0lKKKK	L L L L L L L L L L L L L L L 99l$STUUD	J
 
 
 L L 	0lKKKK	L L L L L L L L L L L L L L L L L Ls5   AAA3BBBC--C14C1)marksc                 V    t          j        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   )rB  X_sparses     r!   'test_convert_container_sparse_to_sparsers  J  s3    2 }RS???Hx!122222r#   c                 <   | j         dk    rZ|rXt          j        | j        | j                  5  t          j        | j        | j                   d d d            n# 1 swxY w Y   | j         dk    rt          j        d          5 }| j        }d|v rd}t          j        || j                   |rt          |          d	k    snnJ |r8t          |d	         j                  |k    sJ |d	         j        | j        k    sJ d d d            d S # 1 swxY w Y   d S d S )
NrH   r'   )ru   rJ   r   T)rv   Pyarrowz*
Pyarrow will become a required dependencyr   )
actionr0   r   rJ   ru   rA   rB   ro   rs   str)warning_infowarnings_as_errorsrv   ru   s       r!   check_warnings_as_errorsrz  g  s   g%%*<%]<08LMMM 	 	M$,%.   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 h&&$D111 	CV"*GG##GM%.    (:@3v;;!###### C6!9,--8888ay)\-BBBBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C '&s$   !AA"AA<DDDrx  c                 p    t           j                            dd          dk    }t          | |           d S )NSKLEARN_WARNINGS_AS_ERRORS0ry  )r  environgetrz  )rx  ry  s     r!   test_sklearn_warnings_as_errorsr    s8    (DcJJcQ\>PQQQQQQr#   c                     t          j                    5  t                       t          | d           d d d            d S # 1 swxY w Y   d S )NTr~  )rA   ro   r   rz  )rx  s    r!   test_turn_warnings_into_errorsr    s    		 	"	" H H!### $GGGGH H H H H H H H H H H H H H H H H Hs    AAA)r   )_r  r  rA   numpyr-   r0   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parametrizer<   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   paramr   r   r   r   r   r   r   r	  r  xfailr%  r&  r'  ndarray
csr_matrixr   r9  int32integerint64rc  floatingrd  rG  rM  rR  rW  skipifrY  r`  re  rj  rs  rz  r  r  rD   r#   r!   <module>r     s	    				             D D D D D D / / / / / /                                 " 1 0 0 0 0 0              6 5 5 5 5 5" " " .99+ + :9+&  J  &  &  &  *  "  &       ,       ".; .; .; .; .; .; .; .;b M M MD	 	 	.	 	 	4	 	 	2 8 8 8  EN #u>>+	
 EN %3%@@,	
 8 8   8 "EN-u5r2,	
 	
 	
 	eU^&7%>B:VVVE7#u%) 		
 		
 		
 	E7#u%4 		
 		
 		
 	Gu%# 		
 		
 		
 	EN#u==;	
 	
 	
G*- -\	8 	8]- - ^	8
	 
	 
		 	 	
	 
	 
	 -S -S -S` "
 "
 "
J7 7 7 7 7 7 7 7: : : :. . .* 8$@AA# # BA#< &		%	"*	6$%	 
l./	@	@ 
l./	@	@ 
EEF 
??@ 
==> 
% " 	2:	2:	R[!	R[!	 6 6 # 46>+ + +. . .8 8 8 --&&&:    +.@BT-UVV28RXrz2:"NOO	E 	E PO WV	 	EC C CLH H H$ 8$=>>L L ?>L. +$$]]5111F %  	
 	
 	
 	+$$]]5111F %  	
 	
 	
 *3 3+ *3C C C0 )H)H)J)JKKR R LKR
 )H)H)J)JKKH H LKH H Hr#   