
    /ii`                        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! 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 Z. G d d          Z/ G d d          Z0 G d d          Z1ed             Z2d Z3d Z4d Z5ed             Z6eej%        &                    de3e4gdgd gd!d"fe3e4gd#d$gd%d&fg          d'                         Z7eej%        &                    d( ej8        e3e4gd)dgid*d*d+,           ej8        e3e4gd-d.id*d*d/,           ej8        e3e4e5gd)dgid0d*d1,           ej8        e3e4e5gd)d gid2d*d3,           ej8        e4e5gd)d4gid5d*d6,           ej8        e3e4gd.d gd!d*d7d8,          g          d9                         Z9d: Z:d; Z;d< Z<ed=             Z=ed>             Z> G d? d@          Z?dmdBZ@dC ZAdD ZBej%        &                    dEdFeCfdGeDfdHejE        fdIejF        fg eGdJdKge!           eGdLdMge           dNdO fdPdQ fdRdS fdTdU fdVdW fdXdY fdZd[ fd\eHf          ej%        &                    d]ejI        ejJ        fejK        ejJ        fejL        ejM        fejN        ejM        fg          d^                         ZOd_ ZPd` ZQda ZRdb ZSdc ZTej%        U                    edde          df             ZVej%        &                    dgdJdL ej8        dK           ej8        dM          g          dh             ZWdi ZXej%        &                    dj e                      dk             ZYej%        &                    dj e                      dl             ZZdS )n    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)available_ifc                      t                      } t                      }t          | d           t          |d           |j        dk    sJ d S )N   )r   r   r   random_state)ldatrees     f/var/www/html/bet.cuttalo.com/ml/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:   .   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_functionE   s    +-?@@@@@r!   c                  b    t          j        dt                     t          j        d           d S r=   r>   rB   r!   r   _multiple_warning_functionz7test_ignore_warning.<locals>._multiple_warning_functionH   s-    +-?@@@+,,,,,r!   errorcategoryr'   r   r*   c                  0                                 d S NrB   )rE   rC   s   r   decorator_no_warningz1test_ignore_warning.<locals>.decorator_no_warningg   s'    ""$$$$$r!   c                                     d S rJ   rB   rE   s   r   decorator_no_warning_multiplez:test_ignore_warning.<locals>.decorator_no_warning_multiplel       ""$$$$$r!   c                                     d S rJ   rB   rC   s   r    decorator_no_deprecation_warningz=test_ignore_warning.<locals>.decorator_no_deprecation_warningp       r!   c                                     d S rJ   rB   rQ   s   r   decorator_no_user_warningz6test_ignore_warning.<locals>.decorator_no_user_warningt   rS   r!   c                                     d S rJ   rB   rM   s   r   )decorator_no_deprecation_multiple_warningzFtest_ignore_warning.<locals>.decorator_no_deprecation_multiple_warningx   rO   r!   c                                     d S rJ   rB   rM   s   r   "decorator_no_user_multiple_warningz?test_ignore_warning.<locals>.decorator_no_user_multiple_warning|   rO   r!   c                  j    t                      5                 d d d            d S # 1 swxY w Y   d S rJ   )r   rQ   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 NrG   )r   rA   UserWarningrM   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   rA   rQ   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^   rQ   s   r   context_manager_no_user_warningz<test_ignore_warning.<locals>.context_manager_no_user_warning   s    k222 	  	 	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 rc   c                  x    t          t                    5                 d d d            d S # 1 swxY w Y   d S r]   ra   rM   s   r   /context_manager_no_deprecation_multiple_warningzLtest_ignore_warning.<locals>.context_manager_no_deprecation_multiple_warning   s    &8999 	) 	)&&(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)rc   c                  x    t          t                    5                 d d d            d S # 1 swxY w Y   d S r]   re   rM   s   r   (context_manager_no_user_multiple_warningzEtest_ignore_warning.<locals>.context_manager_no_user_multiple_warning   s    k222 	) 	)&&(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)rc   zA'obj' should be a callable.+you should use 'category=UserWarning'r%   c                      d S rJ   rB   rB   r!   r   testz!test_ignore_warning.<locals>.test   s    Dr!   )r?   catch_warningssimplefilterr   rA   r.   warnsr^   FutureWarninglen
isinstancemessager   r0   )recordrK   rN   rR   rU   rW   rY   r[   r_   rb   rf   rh   rj   warning_classr&   silence_warnings_funcrl   rE   rC   s                    @@r   test_ignore_warningrw   B   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
    rB   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
    rB   rz   s      r   f_bad_sectionsr      r   r!   c                     || z   }|S ry   rB   )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
    rB   )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
    rB   rz   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
    rB   )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 rJ   rB   selfr7   r6   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
        NrB   r   s      r   r   zKlass.f_bad_sections=  s	     	r!   N)__name__
__module____qualname__r   r   rB   r!   r   r   r   9  s2              r!   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )MockEstc                     dS )MockEstimatorNrB   r   s    r   __init__zMockEst.__init__P        r!   c                     |S rJ   rB   r   s      r   fitzMockEst.fitS      r!   c                     |S rJ   rB   r   r7   s     r   predictzMockEst.predictV  r   r!   c                     |S rJ   rB   r   s     r   predict_probazMockEst.predict_probaY  r   r!   c                     dS )N      ?rB   r   s     r   scorezMockEst.score\  s    sr!   N)r   r   r   r   r   r   r   r   rB   r!   r   r   r   O  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__a  s     !r!   c                 ,    t          | j        d          S )Nr   hasattrr   r   s    r   <lambda>zMockMetaEstimator.<lambda>k  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.predictk  s     }$$Q'''r!   c                 ,    t          | j        d          S )Nr   r   r   s    r   r   zMockMetaEstimator.<lambda>v  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
        NrB   r   s     r   r   zMockMetaEstimator.scorev  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
        rB   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 testedNrB   r   s      r   r   zMockMetaEstimator.fit  r   r!   N)
r   r   r   r   r   r   r   r   r   r   rB   r!   r   r   r   `  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dddddgd| ddddgd| ddddgd| d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: 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']z.predict_probaz&potentially wrong underline length... zParameters z--------- in z.scorez.fitr   r   r   z
"z"
 not in 
"")r   r~   r   r.   r   RuntimeErrorr   r   r   r   r   	__class__r   zipr   r   r   r   r   r   )	incorrect	mock_metamock_meta_namemessagesr5   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        		
 		
 		

	
 
	
 
	
		
 		
 		
		
 		
 		
 V^UUUC 	
0>   5	
 T^SSS4		
 R^QQQ4 		
INH` &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
    NrB   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
    NrB   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
    NrB   r   s     r   f_threer   B  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)r.   r   	TypeErrorr   r   rB   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)r.   r   r   r   )objectskwargsrF   s      r   ,test_assert_docstring_consistency_arg_checksr   b  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)r.   r   r/   r   ro   r^   )r   r   rF   r@   s       r   !test_assert_docstring_consistencyr   x  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.
    NrB   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.
    NrB   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.
    NrB   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)r.   r   r/   r   r   r   r   )r5   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splitr.   r   r/   )
regex_fullregex_wordsregex_errorr5   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__3  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__6  s,    $666666r!   N)r   r   r   r   r   rB   r!   r   r   r   2  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   )rr   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+   r2   r   r  ospathdirnamefilenamenameexistsr   )monkeypatchregistration_counterr  datatemp_folderr  s         r   test_tempmemmapr  B  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c                    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+   r2   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!  W  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r.   importorskip	DataFramerB   r!   r   r   r     s    f1(;;E r!   seriesc                  4    t          j        d          j        S r+  r.   r.  SeriesrB   r!   r   r   r     s    6.x88? r!   indexc                  4    t          j        d          j        S r+  )r.   r.  IndexrB   r!   r   r   r     s    &-h77= r!   pyarrowc                  4    t          j        d          j        S Nr7  )r.   r.  TablerB   r!   r   r   r     s    F/	::@ r!   pyarrow_arrayc                  4    t          j        d          j        S r9  )r.   r.  ArrayrB   r!   r   r   r     s    &"5i"@"@"F r!   polarsc                  4    t          j        d          j        S Nr>  r-  rB   r!   r   r   r     s    6.x88B r!   polars_seriesc                  4    t          j        d          j        S r@  r2  rB   r!   r   r   r     s    &"5h"?"?"F r!   slicezdtype, superdtypec                 f   | dv r
 |            }ddg}t          || |          }t          ||          sJ | dv r,t          j        t	          |d                   |          sJ dS | dv r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)  r4  r>  rA  r7  r;  r0  r   r*   dtype)r"  r#  r4  )r>  rA  r7  r;  NrF  dtypes)r   rr   r+   
issubdtypetyper   rF  rG  )constructor_namecontainer_typerF  
superdtype	containercontainer_converteds         r   test_convert_containerrO  u  s   L     ())AI,  
 )>:::::555 }T"5a"899:FFFFFFF	T	T	T	$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 )Nr,  r4   r)  r8   categorical_feature_namesr   rH   )r.   r.  r   rG  iloc)dfs    r   (test_convert_container_categories_pandasrU    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>  r4   r8   rQ  )r.   r.  r   schemaCategorical)plrT  s     r   (test_convert_container_categories_polarsrZ    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 )Nr7  r4   r8   rQ  r   )r.   r.  r   rI  rW  DictionaryType)parT  s     r   )test_convert_container_categories_pyarrowr^    s]    		Y	'	'B	cUGYRUQV	W	W	WB	!!""b&7777777r!   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_matchedr.   r0   r/   )cms    r   test_raisesre    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㈵ ?rE  r   gX ?gc^  ?g55  ?gh㈵>g        gh㈵>)atol)r
   r+   r$  float32r.   r   r/   float64rB   r!   r   "test_float32_aware_assert_allcloserj    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 subprocess)reasonc                     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   r.   r   r/   r   )codes    r   ,test_assert_run_python_script_without_outputrp  (  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rJ  c                 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   )rJ  X_sparses     r   'test_convert_container_sparse_to_sparserx  @  s3    " }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 )
NrF   r%   )rs   rH   r   T)rt   Pyarrowz*
Pyarrow will become a required dependencyr   )
actionr.   r   rH   rs   r?   r@   rm   rq   str)warning_infowarnings_as_errorsrt   rs   s       r   check_warnings_as_errorsr  U  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r}  c                 p    t           j                            dd          dk    }t          | |           d S )NSKLEARN_WARNINGS_AS_ERRORS0r~  )r  environgetr  )r}  r~  s     r   test_sklearn_warnings_as_errorsr  m  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  )r?   rm   r   r  )r}  s    r   test_turn_warnings_into_errorsr  s  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  r?   numpyr+   r.   scipyr   sklearn.discriminant_analysisr   sklearn.treer   sklearn.utils._testingr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   sklearn.utils.deprecationr   sklearn.utils.fixesr   r   r   sklearn.utils.metaestimatorsr   r    markparametrizer:   rw   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   paramr   r   r   r   r   r   r   r  r  r!  r"  r#  ndarray
csr_matrixr   rC  int32integerint64rh  floatingri  rO  rU  rZ  r^  re  rj  xfailrp  rx  r  r  r  rB   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~	 	 	.	 	 	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: : : :. . .*# # #< &		%	"*	6$%	 
l./	@	@ 
l./	@	@ 
EEF 
??@ 
==> 
@@A 
FFG 
BBC 
FFG  
%! * 	2:	2:	R[!	R[!	 &6 &6 + <&6R+ + +. . .8 8 8C C CLH H H$ 8$=>>L L ?>L. 	
 	
 		
 	
	 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!   