
    -i:                        S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
rSSKrSSKJr  SSKJr  SSKrSSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJrJr  SSKJ r   SSK!J"r"  SSK#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*J+r+J,r,J-r-J.r.J/r/  SSK0J1r1J2r2  SSK3J4r4J5r5  SSK6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?  SSK@JArA  SSKBJCrCJDrDJErEJFrFJGrG  SSKHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`JaraJbrbJcrc  S rdS re\R                  R                  S\R                  R                  S5      \R                  " SSSS 9/5      S! 5       riS" rjS# rkS$ rl\R                  R                  S%\R                  S&4\R                  S'4\R                  S&4/5      \R                  R                  S(\R                  \R                  /5      S) 5       5       rq\R                  R                  S*\R                  S+S,S-4\R                  SS,S.4\R                  S/S,S04\R                  SS'S.4\R                  S+S,S14\R                  SS,S24\R                  S3S,S44\R                  S+S5S64\R                  S+S7S14/	5      \R                  R                  S(\R                  \R                  /5      S8 5       5       rr\R                  R                  S9/ S:Q5      \R                  R                  S(\R                  \R                  /5      S; 5       5       rsS< rt\R                  R                  S=\R                  " S7\R                  //5      S>4\R                  " S7\R                  //5      S>4\R                  " S7\R                  //5      S?4\R                  " S7\R                  //\vS@9SA4/5      \R                  R                  SBS,S&/5      SC 5       5       rwSD rx\R                  R                  SE5      SF 5       rz\R                  R                  SSGSH/SISJ//\R                  " SGSH/SISJ//SKS@9\R                  " SGSH/SISJ//SLS@9SMSN/SOSP//\R                  " SMSN/SOSP//SQS@9/5      SR 5       r{\R                  R                  SS/ STQ5      \R                  R                  SU\R                  \R                  /\R                  4\R                  \R                  4SV\R                  4/5      SW 5       5       r~SX rSY rSZ rS[ rS\ rS] rS^ r\GR                  " / S_QS`9Sa 5       rSb rSc rSd rSe rSf rSg rSh rSi rSj rSk r\R                  R                  Sl\" S5      \\// SmQSn9So 5       rSp r\R                  R                  Sq\2" 5       \1Sn9Sr 5       rSs rSt rSu r\R                  R                  Sv\R                  \R                  4\R                  SSV45      \R                  R                  SwSx5      Sy 5       5       rSz rS{ r " S| S}5      r " S~ S5      rS r\R                  R                  SS,S&/5      S 5       r\R                  R                  SS\" SSSS,05      SS,S4S\" SSSS,05      SS,S4S\" SSSS,05      /S/S,S4S\" SSSS,05      S/S,S4S\" SSSS,05      SS\4S\" SSSS,05      SS\4// SQSn9S 5       r\R                  R                  S(\R                  \R                  \GRJ                  \GRL                  \GRN                  \GRP                  \GRR                  \GRT                  /5      S 5       rS rS r\R                  R                  S/ SQ5      S 5       r\R                  R                  SS7S\SSS\" S5      4SS\GRb                  SSS\" S5      4SS\GRd                  SSS\" S5      4S7S\\4SSS\" S5      4S7S\SSS\" S5      4SS\SSS\" S5      4SS\SSS\" S5      4SS\SSS\" S5      4SS\SSS\" S5      4SS\SSS\" S5      4SS\SSS\" S5      4/5      S 5       rS\R                  " S7S/5      SS+4\R                  " S7S/5      \R                  " S7S/5      SS+4S\R                  " SS/5      \S4S\R                  " SS/5      \S+4\R                  " S7S/\R                  S@9\R                  " S7S/\R                  S@9\S4\R                  " S7S/\R                  S@9\R                  " S7S/\R                  S@9\S4S\R                  " SS/5      \S4S.r\R                  R                  S\" \GRo                  5       5      \" \GRq                  5       5      Sn9\R                  R                  SS,S&/5      S 5       5       rS\S4S\S4S\S4\R                  " SS/\R                  S@9\S4\R                  " SS/\R                  S@9\S4S.r\R                  R                  S\" \GRo                  5       5      \" \GRq                  5       5      Sn9S 5       rS r\R                  R                  S\R                  \R                  \GRJ                  /5      S 5       r\R                  R                  S\R                  \R                  \GRJ                  /5      S 5       r\R                  R                  S\R                  \GRJ                  /5      S 5       rS rS rS r\R                  R                  SSS7S//5      S 5       r\R                  R                  S/ SQ5      S 5       r\R                  R                  S/ SQ5      S 5       r\R                  R                  SSS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4SS\GR                  4/5      S 5       r\R                  R                  S/ SQ5      S 5       r\R                  R                  S/ SQ/ SQ/ SQ/ SQGS S70GSS0GSS0/// GSQSn9\R                  R                  S/ GSQ5      GS 5       5       r\R                  R                  S/ GSQ/ GSQSn9GS 5       r\R                  R                  GS	\" \" S5      5      \" S5      SGS GS/GSGS
//// GSQSn9GS 5       rGS r\R                  R                  GS/ GSQ5      GS 5       r\R                  R                  S/ GSQ5      GS 5       rGS rGS r\R                  R                  GSGS\GS   S   4GS\GS   S   4GS\GS   S   4/5      GS 5       rGS rGS r\R                  R                  GSGS S7/GS4GSGS GS//GS4/GS GS!/Sn9GS" 5       r " GS# GS$\5      rGS% rGS& rGS' r\R                  R                  GS(/ GS)Q5      GS* 5       rGS+ rGS, r\R                  R                  GS-SS7SS7S\R                  // GS.Q/5      GS/ 5       r\?GS0 5       r\R                  R                  GS1/ GS2Q5      \R                  R                  GS3S,S&/5      GS4 5       5       rGS5 r\R                  R                  GS6\E\D-   \C-   \F-   5      \R                  R                  GS7/ GS8Q5      GS9 5       5       r\R                  R                  GS:\R                  " S75      \R                  " S5      /S7S/SS///5      GS; 5       rGS< rGS= rGS> rGS? rGS@ r\?GSA 5       rGSB r\R                  R                  / GSCQ\R                  " S7S/SS//S7S/SS///5      \" 5       GSD4\R                  " S7S/SS//S7S/SS///5      SGSE4/5      GSF 5       rg(G  z$Tests for input validation functions    N)product)
itemgetter)NamedTemporaryFile)importorskip)config_context)dependent_packages)BaseEstimator)
make_blobs)RandomForestRegressor)NotFittedErrorPositiveSpectrumWarning)ARDRegression)EstimatorWithFit)KNeighborsClassifier)_sparse_random_matrix)SVR)_safe_indexingas_float_arraycheck_arraycheck_symmetric	check_X_y
deprecated)_get_namespace_device_dtype_ids)yield_namespace_device_dtype_combinations)MockDataFrame_MockEstimatorOnOffPrediction)	SkipTest
TempMemmap_array_api_for_tests_convert_containerassert_allcloseassert_allclose_dense_sparseassert_array_equalcreate_memmap_backed_data'skip_if_array_api_compat_not_configured)_NotAnArray)COO_CONTAINERSCSC_CONTAINERSCSR_CONTAINERSDIA_CONTAINERSDOK_CONTAINERS)FLOAT_DTYPES_allclose_dense_sparse_check_feature_names_in_check_method_params_check_psd_eigenvalues_check_response_method_check_sample_weight_check_y_deprecate_positional_args_estimator_has_get_feature_names
_is_fitted_is_pandas_df_is_polars_df_num_features_num_samples_to_object_arrayassert_all_finitecheck_consistent_lengthcheck_is_fittedcheck_memorycheck_non_negativecheck_random_statecheck_scalarcolumn_or_1dhas_fit_parametervalidate_datac                     [        S 5      [        R                  R                  R                  L d   e[        [        R                  5      [        R                  R                  R                  L d   e[        R                  R                  S5      n [        S5      R                  S5      U R                  S5      :X  d   e[        R                  R                  S5      n [        U 5      U L d   e[        R                  R                  S5      n [        S5      R                  S5      U R                  S5      :w  d   e[        R                  " [        5         [        S5        S S S 5        g ! , (       d  f       g = f)N*   d   +   zsome invalid seed)
rB   nprandommtrand_randRandomStaterandintpytestraises
ValueError)rng_42s    V/var/www/html/venv/lib/python3.13/site-packages/sklearn/utils/tests/test_validation.pytest_make_rngrV   _   s
   d#ryy'7'7'='====bii(BII,<,<,B,BBBBYY""2&Fb!))#.&..2EEEEYY""2&Ff%///YY""2&Fb!))#.&..2EEEE	z	"./ 
#	"	"s   E--
E;c                     [         R                  " S[         R                  S9n U [         R                  " S[         R                  S9-   n [	        U SS9nUR
                  [         R                  :X  d   eU R                  [         R                  5      n [	        U SS9n[	        U SS9U Ld   eUR
                  [         R                  :X  d   e[        [         R                  [         R                  [         R                  [         R                  [         R                  [         R                  /nU H?  nU R                  U5      n [	        U 5      nUR
                  [         R                  :X  a  M?   e   U R                  [         5      n [	        U SS9nUR
                  [         R                  :X  d   e[         R                  " S[         R                  S9n [	        U SS9U L d   e[         R"                  " U 5      n [         R$                  " [	        U SS95      (       d   e[&        R(                  " [         R                  " S5      5      R+                  5       [-        SSS	S
9R+                  5       /nU HK  n[	        USS9n[         R.                  US'   [         R0                  " U5      R3                  5       (       d  MK   e   g )N)   
   dtyperY   FcopyT)rX         皙?)densityr   r   )rK   onesint32aranger   r[   float32astypeint64float64boolint8int16uint8uint16uint32objectasfortranarray	isfortransp
csc_matrixtoarrayr   nanisnanany)XX2tested_dtypesr[   matricesMNs          rU   test_as_float_arrayr   q   s   
rxx(A	BIIb))A		&B88rzz!!!	A		%B!%(11188rzz!!!277BHHbhh"))RYYWMHHUOAxx2::%%%  	
A		%B88rzz!!! 	bjj)A!%(A---
!A<<qt45555 	biil#++-b"d3;;=H 14(&&$88A;??$$$$     ry   rY   r^   rY   r^   csrformatc                 z    [         R                  U S'   [         R                  U S'   [        U SS9n[        X5        g )N)r_   r   )      	allow-nanensure_all_finite)rK   rv   r   r"   )ry   X_converteds     rU   test_as_float_array_nanr      s2     ffAdGffAdG kBK 0r   c                      [         R                  " S5      R                  SS5      n [        [	        U 5      [         R
                  5      (       a   e[        [	        [        R                  " U 5      5      [         R
                  5      (       a   eg )N   rX      )rK   re   reshape
isinstancer   matrixrs   rt   ry   s    rU   test_np_matrixr      s`    
		"a#A.+RYY7777.q)9:BIIFFFFFr   c                  R   S n [        SS9 n[        R                  " US[        R                  S9nSUS S & [        [        R
                  U 4 H=  nU" U5      nSUS S & [        UR                  5       UR                  5       5        SUS S & M?     S S S 5        g ! , (       d  f       g = f)Nc                     [        U SS9$ )NFr\   )r   )xs    rU   <lambda>test_memmap.<locals>.<lambda>   s    nQU3r   zsklearn-test)prefixrY   rY   )shaper[   r   r   )r   rK   memmaprf   r   asarrayr#   ravel)asflttmpr}   fry   s        rU   test_memmapr      s     4E	>	2cIIc<!rzz51A!AAaDqwwy!'')4AaD	 2	 
3	2	2s   BB
B&c                     [         R                  " S5      n X R                  4 H]  nS HT  n[        USUS9nUR                  S   (       d   e[        USUS9nUR                  S   (       d   eU(       d  MN  XLa  MT   e   M_     [
        R                  " U 5      n U R                  S S S2   U l        U R                  R                  S   (       a   eg )	N)rY   r_   )TFC)orderr]   C_CONTIGUOUSFF_CONTIGUOUS)rK   rc   Tr   flagsrs   
csr_matrixdata)ry   Ar]   Bs       rU   test_orderingr      s     	AV!DASt4A77>***ASt4A77>***tz!z "  	aAVVDbD\AFvv||N++++r   zvalue, ensure_all_finiteFr   retypec                     U" [         R                  " S5      R                  SS5      R                  [        5      5      nXS'   [        X1SS9n[        X45        g )Nr   r^   rb   T)r   accept_sparse)rK   re   r   rg   floatr   r"   )valuer   r   ry   	X_checkeds        rU   (test_check_array_ensure_all_finite_validr      sJ     	ryy|##Aq)0078AdGARVWI .r   z/value, input_name, ensure_all_finite, match_msg TzInput contains infinityzInput X contains infinitysample_weightz%Input sample_weight contains infinityInput contains NaNzInput X contains NaNyzInput y contains NaNz	allow-infz1ensure_all_finite should be a bool or 'allow-nan'r   c                    U" [         R                  " S5      R                  SS5      R                  [         R                  5      5      nXS'   [
        R                  " [        US9   [        UUUSS9  S S S 5        g ! , (       d  f       g = f)Nr   r^   rb   matchT)
input_namer   r   )	rK   re   r   rg   ri   rQ   rR   rS   r   )r   r   r   	match_msgr   ry   s         rU   *test_check_array_ensure_all_finite_invalidr      sg    . 	ryy|##Aq)00<=AdG	z	3!/		
 
4	3	3s   'A==
Br   )ry   r   r   c                 B   U" [         R                  " S5      R                  SS5      R                  [         R                  5      5      n[         R
                  US'   [        5       nSUR                  R                   S3n[        R                  " [        SU  S3S9 n[        UUU S	S
9  S S S 5        U S:X  a   UWR                  R                  S   ;   d   eOUWR                  R                  S   ;  d   eU S:X  a  [        R                  " [        SU  S3S9 n[        5       R                  U[         R                   " UR"                  S   5      5        S S S 5        XER                  R                  S   ;   d   eg g ! , (       d  f       N= f! , (       d  f       N?= f)Nr   r^   rb   
aX   does not accept missing values encoded as NaN natively. For supervised learning, you might want to consider sklearn.ensemble.HistGradientBoostingClassifier and Regressor which accept missing values encoded as NaNs natively. Alternatively, it is possible to preprocess the data, for instance by using an imputer transformer in a pipeline or drop samples with missing values. See https://scikit-learn.org/stable/modules/impute.html You can find a list of all estimators that handle NaN values at the following page: https://scikit-learn.org/stable/modules/impute.html#estimators-that-handle-nan-valueszInput z contains NaNr   T)	estimatorr   r   ry   r   )rK   re   r   rg   ri   rv   r   	__class____name__rQ   rR   rS   r   r   argsfitrc   r   )r   r   r   r   extended_msgctxs         rU   0test_check_array_links_to_imputer_doc_only_for_Xr      s\    "))A,&&q!,33BJJ?@DDJI
Y  ))* +- 	-  
z6*])K	LPS!		
 
M Ssyy~~a0000399>>!#4444S ]]:vj\-OPTWEIIdBGGDJJqM23 Qyy~~a0000  
M	L  QPs   E?<F?
F
Fc                  .   [         R                  " SS[         R                  //[        S9R                  n [        U S SS9nXL d   e[        U S SS9nXL d   e[        R                  " [        SS9   [        U S S	S9  S S S 5        g ! , (       d  f       g = f)
NabrZ   r   r[   r   Fr   r   T)	rK   arrayrv   rp   r   r   rQ   rR   rS   )ry   r   s     rU   )test_check_array_ensure_all_finite_objectr   (  s}    
3RVV$%V466AAT[II>>ATUCI>>	z)=	>ATT: 
?	>	>s   1B
Bz
X, err_msgInput contains NaN.z5Input contains infinity or a value too large for.*intrZ   z#cannot convert float NaN to integerr   c                     [         R                  " [        US9   [        U [        US9  S S S 5        g ! , (       d  f       g = f)Nr   r   )rQ   rR   rS   r   int)ry   err_msgr   s      rU   8test_check_array_ensure_all_finite_object_unsafe_castingr   5  s+    0 
z	1AS4EF 
2	1	1s	   3
Ac                      [         R                  " S5      n U R                  / SQ5      nS[        U5       S3n[         R                  " [
        US9   [        USS9  SSS5        g! , (       d  f       g= f)	z
Check that we raise a proper error message when passing a Series and we expect a
2-dimensional container.

Non-regression test for:
https://github.com/scikit-learn/scikit-learn/issues/27498
pandasr   r^   rX   z+Expected a 2-dimensional container but got z	 instead.r   T	ensure_2dN)rQ   r   SeriestyperR   rS   r   )pdsermsgs      rU   test_check_array_series_err_msgr   Q  sX     
		X	&B
))I
C7S	{)
LC	z	-C4( 
.	-	-s   A&&
A4z3ignore:Can't check dok sparse matrix for nan or infc                  `   SS/SS//n [         R                  " U 5      n[        R                  " [        5         [        U5        S S S 5        [        / SQSS9nUR                  S:X  d   e[        R                  " [        SS	9   [        / SQS
S9  S S S 5        [        R                  " [        SS	9   [        SS
S9  S S S 5        [        [         S5      (       ae  [        [        [         R                  " U 5      5      5      nUR                  S:X  a-  [        R                  " [        SS	9   [        US
S
S9  S S S 5        [        R                  " S5      R                  SSS5      n[        R                  " [        5         [        U5        S S S 5        [        US
S9  [        R                  " S5      R                  SS5      R                  S5      nUR                  S5      nUR!                  ["        5      nUR!                  [$        5      nXVXx/n	[        R&                  ["        [$        [        R(                  S [*        [,        /n
/ SQnS
S/n[/        XX5       GH   u  pp[        XXS9nUb  UR0                  U:X  d   eOUR0                  U R0                  :X  d   eUS:X  a-  UR2                  S   (       d   eUR2                  S   (       a   eO2US:X  a,  UR2                  S   (       d   eUR2                  S   (       a   eU(       a	  U ULd   eM  U R0                  UR0                  :X  d  M  UR2                  S   U R2                  S   :X  d  M  UR2                  S   U R2                  S   :X  d  GM  U UL a  GM!   e   / n	U	R5                  [6        [8        -   [:        -   [<        -    Vs/ s H  nU" U5      PM     sn5        U	R5                  U	S   R!                  [        R>                  5      U	S   R!                  [        R@                  5      /5        SS/SS//nU
 Vs/ s H  nU[,        Ld  M  UPM     nn[/        U	UUU5       H  u  pnn[        XUUS9nUb  UR0                  U:X  d   eOUR0                  U R0                  :X  d   eU RB                  U;   a  U RB                  URB                  :X  d   eOURB                  US   :X  d   eU(       a	  U ULd   eM  U R0                  UR0                  :X  d  M  U RB                  URB                  :X  d  M  U UL a  M   e   [        SS/SS//5      n[E        U[        RF                  5      (       d   e[        R                  " [        5         [        URI                  5       5        S S S 5        [        URI                  5       S
S9  [K        U5      n[        U5      n[E        U[        RF                  5      (       d   e[        SS/SS//5      nSn[        R                  " [        US	9   [        US
S[M        5       S 9  S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN/= f! , (       d  f       GN= fs  snf s  snf ! , (       d  f       GN= f! , (       d  f       g = f)!Nr   r^   rX   r   )r   r   r^   Fr   z'Expected 2D array, got 1D array insteadr   Tz+Expected 2D array, got scalar array insteadrY   	csr_arrayzExpected 2D input, got)r   r      allow_ndr   r   )r   r   N)r[   r   r]   r   r   r   r   coodokr[   r   r]   z<Negative values in data passed to X in RandomForestRegressorry   )ensure_non_negativer   r   )'rs   r   rQ   rR   	TypeErrorr   ndimrS   hasattrnextiterr   rK   re   r   r]   rg   r   r   rd   rf   rj   rp   r   r[   r   extendr)   r(   r'   r+   rh   ri   r   r   ndarraytolistr&   r   )ry   X_csrX_array
sparse_rowX_ndimX_CX_FX_intX_floatXsdtypesorderscopysr[   r   r]   r   sparse_containeraccept_sparsesdtnon_object_dtypesr   X_dense
X_no_arrayresultX_negr   s                              rU   test_check_arrayr	  `  s}    Q!QAMM!E	y	!E 
" )u5G<<1	z)R	SI. 
T 
z)V	WB$' 
X r;$r||A/0
??az1IJJddK K YYq\!!!Q*F	z	"F 
#& ))A,

q!
$
)
)#
.C
((3-CJJsOEjjG
E	#BhhUBJJdFCFF5ME!(V!C%eG	??e+++??agg---C<??>222 ~6666c\??>222 ~666I%%% 9??*OON3qww~7NNOON3qww~7NNI~%~+ "D4 
BII %3%% %	
%  S!%	
 IIr!u||BHH%r!u||BJJ'?@Aenuen5N '-Af&0@fA)0
~u*%-  mRVW	??e+++??agg---88}$88y///// ##}Q'7777I%%% ww)//)ahh):J:J.JI~%~'*. Aq6Aq6*+Ggrzz****	z	"FMMO$ 
#$/ W%J$Ffbjj)))) !Q"a)*ELG	z	1 $+-		
 
2	1m 
"	! 
T	S 
X	W KJ
 
#	"T	
 B6 
#	" 
2	1se   X)X;2Y+Y Y1*Z"Z3Z.ZZ)
X8;
Y

Y
Y.1
Z 
Z
Z-1234US   1   2   3   4V1c                     Sn[         R                  " [        US9   [        U SS9  SSS5        g! , (       d  f       g= f)ziTest that check_array errors when it receives an array of bytes/string
while a numeric dtype is required.z>dtype='numeric' is not compatible with arrays of bytes/stringsr   numericrZ   NrQ   rR   rS   r   )ry   expected_msgs     rU   test_check_array_numeric_errorr    s.     UL	z	6AY' 
7	6	6s   0
>pd_dtype)Int8Int16UInt8UInt16Float32Float64zdtype, expected_dtyper  c                    [         R                  " S5      nU S;   a  [         R                  " SSS9n[        R                  " SSS[        R                  [        R                  /[        R                  [        R                  SS	S
// SQ/5      R
                  nUR                  X@/ SQS9nUS   R                  S5      US'   [        USUS9n[        Xd5        UR                  U:X  d   e[        USUS9n[        Xd5        UR                  U:X  d   eSn[         R                  " [        US9   [        USS9  S S S 5        g ! , (       d  f       g = f)Nr   >   r  r   z1.2
minversionr   r^   rX   r   r   r   )r   r^   rX   r   r_   r   r   c)r[   columnsr%  r   r   )r   r[   Fr   r   Tr   )rQ   r   rK   r   rv   r   	DataFramerg   r   r!   r[   rR   rS   )r  r[   expected_dtyper   X_npry   r   r   s           rU   "test_check_array_pandas_na_supportr*    s    
		X	&B))  e<88
Q266266	"RVVRVVQ1$=Oa 	
 	T?CAsV]]7#AcFAEJII$??n,,,AeDII$??n,,,
C	z	-A. 
.	-	-s   -E
Ec                  (   [         R                  " S5      n U R                  SSU R                  /SS9nSn[         R                  " [
        US9   [        USS	S
9  SSS5        [        US	S	S
9n[        USS[        R                  /5        UR                  [        R                  :X  d   e[        US	S	[        R                  S9n[        USS[        R                  /5        UR                  [        R                  :X  d   eg! , (       d  f       N= f)z4Check check_array is correct with pd.NA in a series.r   r   r^   Int64rZ   r   r   TF)r   r   N)r   r   r[   )rQ   r   r   NArR   rS   r   r!   rK   rv   r[   ri   rf   )r   X_int64r   X_outs       rU   *test_check_array_panadas_na_support_seriesr0    s    			X	&BiiAruuWi5G
C	z	-GtuE 
. 5EJEEAq"&&>*;;"**$$$5EE EAq"&&>*;;"**$$$ 
.	-s   D
Dc                  x   [         R                  " S5      n [        R                  " / SQ/ SQ/ SQ/[        R                  S9nU R                  U5      n[        U5      R                  [        R                  :X  d   e[        U[        S9R                  [        R                  :X  d   eUR                  S[        R                  05      n[        UR                  [        R                  [        R                  [        R                  45        [        U5      R                  [        R                  :X  d   e[        U[        S9R                  [        R                  :X  d   eUR                  S[        R                  05      n[        U5      R                  [        R                  :X  d   e[        U[        S9R                  [        R                  :X  d   eUR                  S[        R                  05      n[        U5      R                  [        R                  :X  d   e[        U[        S9R                  [        R                  :X  d   eUR                  [        R                  5      n[        U5      R                  [        R                  :X  d   e[        U[        S9R                  [        R                  :X  d   eU R                  SU R                  / SQ5      05      n[        U5      R                  [        R                   :X  d   e[        U[        S9R                  [        R                  :X  d   eg )	Nr   r   r   r_   r      r   	   rZ   r   r^   cat_col)rQ   r   rK   r   rf   r'  r   r[   r,   rg   float16r#   r   rl   ri   Categoricalrh   )r   ry   X_dfcat_dfs       rU   %test_check_array_pandas_dtype_castingr;  4  s7   			X	&B
)Y	2"**EA<<?Dt""bjj000t<066"**DDD;;2::'Dt{{RZZRZZ$HIt""bjj000t<066"**DDD;;288}%Dt""bjj000t<066"**DDD;;2::'Dt""bjj000t<066"**DDD;;rxx Dt""bhh... t<066"**DDD
 \\9bnnY&?@AFv$$000v\288BJJFFFr   c                  D   [         R                  " SS/SS/SS/SS//5      n [        U 5      n[        U5      nUR                  U R                  :X  d   e[        U[         R
                  S9nUR                  [         R                  " [         R
                  5      :X  d   eg )Ng?gffffff?g333333?g      ?g?r`   rZ   )rK   r   r   r   r[   rf   )arrmock_dfchecked_arrs      rU   "test_check_array_on_mock_dataframer@  Y  s    
((S#Jc
S#Jc
C
DCC Gg&K		)))gRZZ8K 4444r   c                      / SQ/ SQ/ SQ/n [        U 5      R                  R                  S:X  d   e[        U SS9R                  R                  S:X  d   eg )Nr   r2  r3  iFr   )r   r[   kindr   s    rU    test_check_array_dtype_stabilityrD  b  sM    	Iy)Aq>$$+++qE*0055<<<r   c            	      ~   / SQ/ SQ/ SQ/n [         R                  " U [         R                  S9n[         R                  " U [         R                  S9n[        R
                  " U5      n[        R                  " U5      n[        R                  " U[         R                  S9nX%/nXU/n[        R                  " 5          [        R                  " S5        U H<  n[        U[         R                  SS9n	U	R                  [         R                  :X  a  M<   e   U H  n[        U[         R                  [         R                  /SS9n	U	R                  [         R                  :X  d   eXL d   e[        U[         R                  [         R                  /SS	/SS
9n	U	R                  [         R                  :X  d   eXLa  M   e   [        U[         R                  [         R                  /SS	/SS
9n	U	R                  [         R                  :X  d   eXLd   eU	R                  S:X  d   e S S S 5        g ! , (       d  f       g = f)Nr   r2  r3  rZ   errorT)r[   r   r   r   r   F)rK   r   rf   rh   rs   r   rt   rd   warningscatch_warningssimplefilterr   ri   r[   r   )

X_int_list	X_float32r.  X_csr_float32X_csc_float32X_csc_int32integer_datafloat32_datary   r   s
             rU   test_check_array_dtype_warningrQ  i  s   Y	2J

:RZZ8Ijj2884GMM),MMM),M--rxx8K)Lm<L		 	 	"g&A#ARZZtLI??bjj000  A#"**bjj1I ??bjj000>!>#zz2::.$en	I ??bjj000%%%    ::rzz* %.	
	 "**,,,---5(((? 
#	"	"s   =AH.B&H.<A(H..
H<c                     SS/SS//n [         R                  " U 5      n[        5       nSn[        R                  " [
        US9   [        USS9  S S S 5        S	n[        R                  " [        US9   [        XS9  S S S 5        S
n[        R                  " [        US9   [        U/ S9  S S S 5        [        R                  " [        US9   [        USS9  S S S 5        [        R                  " [
        SS9   [        X/S9  S S S 5        g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Nn= f! , (       d  f       g = f)Nr   r^   rX   r   ziSparse data was passed, but dense data is required. Use '.toarray\(\)' to convert to a dense numpy array.r   Fr   zjParameter 'accept_sparse' should be a string, boolean or list of strings. You provided 'accept_sparse=.*'.z]When providing 'accept_sparse' as a tuple or list, it must contain at least one string value. r   )rs   r   r   rQ   rR   r   r   rS   )ry   r   invalid_typer   s       rU   -test_check_array_accept_sparse_type_exceptionrV    s
   
Q!QAMM!E5L	A  
y	,E/ 
-	G  
z	-E6 
.	5  
z	-E, 
.	z	-E, 
.	y	.E8 
/	.% 
-	, 
.	- 
.	-	-	-	.	.s<   D2
DD-D>7E
D
D*-
D;>
E
Ec                      SS/SS//n [         R                  " U 5      n[        USS9  [        USS9  [        US/S9  [        USS9  g )	Nr   r^   rX   r   TrS  r   )r   )rs   r   r   )ry   r   s     rU   +test_check_array_accept_sparse_no_exceptionrX    sL    
Q!QAMM!ET*U+eW-X.r   )r   cscr   bsr)paramsc              #     #    [         R                  " SSU R                  S9nU R                  S:X  at  [        US5      (       a"  [	        S UR
                   5       5      Ul        OUR                  R                  S5      Ul        UR                  R                  S5      Ul        O@UR                  R                  S5      Ul	        UR                  R                  S5      Ul
        Uv   g 7f)N   rY   r   r   coordsc              3   B   #    U  H  oR                  S 5      v   M     g7f)rh   N)rg   ).0vs     rU   	<genexpr>X_64bit.<locals>.<genexpr>  s     A1XXg..s   rh   )rs   rL   paramr   tupler^  rowrg   colindicesindptr)requestry   s     rU   X_64bitrk    s     
		"b/A}}1h AAAAH EELL)AEEELL)AEII$$W-	88??7+
Gs   C*C,c                     [        U SSS9  g )NT)accept_large_sparser   )r   )rk  s    rU   1test_check_array_accept_large_sparse_no_exceptionrn    s    TFr   c                     Sn[         R                  " [        US9   [        U SSS9  S S S 5        g ! , (       d  f       g = f)NzbOnly sparse matrices with 32-bit integer indices are accepted. Got int64 indices. Please do reportr   TF)r   rm  r  )rk  r   s     rU   4test_check_array_accept_large_sparse_raise_exceptionrp    s4    	<  
z	-G4UK 
.	-	-s   1
?c                     Sn [         R                  " [        U S9   [        / /5        S S S 5        Sn [         R                  " [        U S9   [        / SS9  S S S 5        [        R
                  " S5      n [         R                  " [        U S9   [        SSS9  S S S 5        [        R                  " S5      n[        R                  " S	5      nS
n [         R                  " [        U S9   [        XSS9  S S S 5        [         R                  " [        U S9   [        XSSS9  S S S 5        [        R                  " S5      n[        R                  " S5      nSn [         R                  " [        U S9   [        XSS9  S S S 5        [         R                  " [        U S9   [        XSSS9  S S S 5        [        R                  " S5      R                  SS5      n[        R                  " S5      nSn [         R                  " [        U S9   [        X5        S S S 5        [        R                  " S5      n[        R                  " S5      n[        XSS9u  p4[        X5        [        X$5        g ! , (       d  f       GNG= f! , (       d  f       GN+= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNP= f! , (       d  f       GN5= f! , (       d  f       N= f)NzC0 feature\(s\) \(shape=\(1, 0\)\) while a minimum of 1 is required.r   z@0 sample\(s\) \(shape=\(0,\)\) while a minimum of 1 is required.Fr   zgInput should have at least 1 dimension i.e. satisfy `len(x.shape) > 0`, got scalar `array(42)` instead.rH   )r   rY   r   zC1 sample\(s\) \(shape=\(1, 10\)\) while a minimum of 2 is required.r^   )ensure_min_samples)rr  r   r   zD2 feature\(s\) \(shape=\(10, 2\)\) while a minimum of 3 is required.rX   )ensure_min_featuresT)rs  r   r   rY   zD0 feature\(s\) \(shape=\(10, 0\)\) while a minimum of 1 is required.)rY   r      rt  r   )rQ   rR   rS   r   reescaper   rK   rc   r   emptyr   r#   )r   ry   r   r   	y_checkeds        rU   2test_check_array_min_samples_and_features_messagesry    s   
PC	z	-RD 
.
 NC	z	-B%( 
. ))BC 
y	,B%( 
- 	A

A
PC	z	-!1- 
.
 
z	-!1> 
.
 	A

A
QC	z	-!A. 
.
 
z	-!A= 
.
 	B"A
A
QC	z	-! 
. 	 A
A$QD9Iq$q$s 
.	- 
.	- 
-	, 
.	-
 
.	- 
.	-
 
.	- 
.	-s_   I)I;J(JJ1/KKK')
I8;
J

J
J.1
K 
K
K$'
K5c                     [         R                  " / SQ/ SQ/5      n [        R                  " [        SS9   [        U 5        S S S 5        / SQ/ SQ/n [        R                  " [        SS9   [        U 5        S S S 5        Sn [        R                  " [        SS9   [        U 5        S S S 5        [         R                  " / SQ5      [         R                  " / SQ5      /n [        R                  " [        SS9   [        U 5        S S S 5        [         R                  " / SQ5      [         R                  " / SQ5      4n [        R                  " [        SS9   [        U 5        S S S 5        [        [         R                  " / SQ/ SQ/5      5      n [        R                  " [        SS9   [        U 5        S S S 5        [        R                  " SS/SS//5      n [        R                  " [        SS9   [        U 5        S S S 5        [         R                  " / SQ5      n[        R                  " [        SS9   [        U5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN8= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g = f)	N      ?       @      @      @      @      @       @      @      @      @      @      @zComplex data not supportedr   )r{  r  r   r|  )r|  r}  r~  r  r  r  )
rK   r   rQ   rR   rS   r   r   rs   
coo_matrixr3   )ry   r   s     rU   #test_check_array_complex_data_errorr  "  s   
*,DEFA	z)E	FA 
G 
"#;<A	z)E	FA 
G 	=A	z)E	FA 
G 
*	+RXX6N-OPA	z)E	FA 
G 
*	+RXX6N-OPA	z)E	FA 
G 	bhh 8:RSTUA	z)E	FA 
G 	6{QF+,A	z)E	FA 
G
 	ABA	z)E	F 
G	FI 
G	F
 
G	F
 
G	F
 
G	F
 
G	F
 
G	F
 
G	F 
G	Fs_   I	+II-7I?J&J#/J44K	
I
I*-
I<?
J
J #
J14
K
Kc                     [        [        S5      (       a   e[        [        S5      (       d   e[        [        S5      (       d   e[        [        5       S5      (       d   e " S S5      n [        U S5      (       d   S5       eg )Nr   c                   4    \ rS rSr\" S5      SS j5       rSrg)@test_has_fit_parameter.<locals>.TestClassWithDeprecatedFitMethodiR  z7Deprecated for the purpose of testing has_fit_parameterNc                     g NrT  )selfry   r   r   s       rU   r   Dtest_has_fit_parameter.<locals>.TestClassWithDeprecatedFitMethod.fitS      r   rT  r  )r   
__module____qualname____firstlineno__r   r   __static_attributes__rT  r   rU    TestClassWithDeprecatedFitMethodr  R  s    	M	N	 
O	r   r  z=has_fit_parameter fails for class with deprecated fit method.)rE   r   r   r   )r  s    rU   test_has_fit_parameterr  L  s|     !5GGGG2ODDDDS/2222SUO4444 
 =OO GOr   c            	      
   [         R                  " SS/SS//5      n [         R                  " S5      n[         R                  " SS/SS//5      nU[        R                  " U5      [        R
                  " U5      [        R                  " U5      [        R                  " U5      [        R                  " U5      [        R                  " U5      S.n[        R                  " [        5         [        U5        S S S 5        UR                  5        H  u  pE[        R                  " [         5         [        U5        S S S 5        [        R                  " [        5         [        USS9  S S S 5        [        USS9n[        R"                  " U5      (       a.  UR$                  U:X  d   e['        UR)                  5       U 5        M  ['        X`5        M     g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f)	Nr   r   r^   )denser   r   rY  r   lilrZ  T)raise_exceptionF)raise_warning)rK   r   rc   rs   
dok_matrixr   rt   r  
lil_matrix
bsr_matrixrQ   rR   rS   r   itemswarnsUserWarningissparser   r#   ru   )arr_symarr_badarr_asymtest_arrays
arr_formatr=  outputs          rU   test_check_symmetricr  \  s`   hhAA'(GggajGxx!Q!Q()H }}X&}}X&}}X&}}X&}}X&}}X&K 
z	"  
# ',,.
\\+&C  ']]:&C6 ' !E:;;v==J...v~~/9v/ /	 
#	" '&&&s$   +G.G#G4
G #
G1	4
H	c                       " S S[         5      n [        R                  " [        5         [	        U " 5       5        S S S 5        [	        U " 5       R                  5       5        g ! , (       d  f       N-= f)Nc                        \ rS rSrS rS rSrg)6test_check_is_fitted_with_is_fitted.<locals>.Estimatori  c                     SU l         U $ )NTr7   r  kwargss     rU   r   :test_check_is_fitted_with_is_fitted.<locals>.Estimator.fit  s    "DOKr   c                 @    [        U S5      =(       a    U R                  $ )Nr7   )r   r7   r  s    rU   __sklearn_is_fitted__Ltest_check_is_fitted_with_is_fitted.<locals>.Estimator.__sklearn_is_fitted__  s    4.B4??Br   r  N)r   r  r  r  r   r  r  rT  r   rU   	Estimatorr    s    		Cr   r  )r	   rQ   rR   r   r?   r   )r  s    rU   #test_check_is_fitted_with_is_fittedr    sG    CM C 
~	&	$ 
'IKOO%& 
'	&s   A""
A0c                  B     " S S[         5      n [        U " 5       5        g)z;Check that check_is_fitted passes for stateless estimators.c                   .   ^  \ rS rSrS rU 4S jrSrU =r$ ):test_check_is_fitted_stateless.<locals>.StatelessEstimatori  c                     U $ r  rT  r  s     rU   r   >test_check_is_fitted_stateless.<locals>.StatelessEstimator.fit      Kr   c                 2   > [         TU ]  5       nSUl        U$ )NF)super__sklearn_tags__requires_fit)r  tagsr   s     rU   r  Ktest_check_is_fitted_stateless.<locals>.StatelessEstimator.__sklearn_tags__  s    7+-D %DKr   rT  )r   r  r  r  r   r  r  __classcell__)r   s   @rU   StatelessEstimatorr    s    		 	r   r  N)r	   r?   )r  s    rU   test_check_is_fitted_statelessr    s    ]  &()r   c                     [         R                  " [        5         [        [        5        S S S 5        [         R                  " [        5         [        S5        S S S 5        [	        5       n [        5       n [         R                  " [        5         [        U 5        S S S 5        [         R                  " [        5         [        U5        S S S 5        SnSn[         R                  " [        US9   [        XS9  S S S 5        SnSn[         R                  " [        US9   [        XS9  S S S 5        U R                  " [        5       6   UR                  " [        5       6   [        U 5      b   e[        U5      b   eg ! , (       d  f       GNW= f! , (       d  f       GN;= f! , (       d  f       GN
= f! , (       d  f       N= f! [         a     S5       ef = f! , (       d  f       N= f! , (       d  f       N= f)	Nr   z&check_is_fitted failed with ValueErrorz!Random message %(name)s, %(name)sz+Random message ARDRegression, ARDRegressionr   )r   z"Another message %(name)s, %(name)szAnother message SVR, SVR)rQ   rR   r   r?   r   r   r   rS   AttributeErrorr   r
   )ardsvrr   r   s       rU   test_check_is_fittedr    sT   	y	!& 
"	y	! 
" /C
%C?]]>*C  +]]>*C  + .C9E	z	/% 
0 /C&E	~U	3% 
4 GGZ\GGZ\3'''3'''? 
"	!	!	! +*** ?>>>u? 
0	/
 
4	3sq   E;F6G F"G >F1
G /
G
G(;
F

F
F.)G 1
F?;G ?G G
G%(
G6c                      " S S[         5      n SnU " 5       n[        USS/S9(       a   e[        R                  " [        US9   [        USS/S9  S S S 5        [        USS/[        S9(       a   e[        R                  " [        US9   [        USS/[        S9  S S S 5        [        USS/[        S9(       a   e[        R                  " [        US9   [        USS/[        S9  S S S 5        S	Ul        [        USS/S9(       a   e[        R                  " [        US9   [        USS/S9  S S S 5        [        USS/[        S9(       a   e[        R                  " [        US9   [        USS/[        S9  S S S 5        [        USS/[        S9(       d   e[        USS/[        S9  S
Ul	        [        USS/S9(       d   e[        USS/S9  [        USS/[        S9(       d   e[        USS/[        S9  [        USS/[        S9(       d   e[        USS/[        S9  g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNh= f! , (       d  f       GN2= f! , (       d  f       N= f)Nc                       \ rS rSrS rSrg)4test_check_is_fitted_attributes.<locals>.MyEstimatori  c                     U $ r  rT  r  ry   r   s      rU   r   8test_check_is_fitted_attributes.<locals>.MyEstimator.fit  r  r   rT  N)r   r  r  r  r   r  rT  r   rU   MyEstimatorr    s    	r   r  z
not fitteda_b_)
attributesr   )r  
all_or_anyr   r   )
r	   r7   rQ   rR   r   r?   allrx   r  r  )r  r   ests      rU   test_check_is_fitted_attributesr    s   m  C
-C#4,777	~S	1t5 
2#4,3GGG	~S	1tE 
2#4,3GGG	~S	1tE 
2 CF#4,777	~S	1t5 
2#4,3GGG	~S	1tE 
2ctTlsCCCCT4LSACFctTl333CT4L1ctTlsCCCCT4LSActTlsCCCCT4LSA3 
2	1 
2	1 
2	1
 
2	1 
2	1s<   H%H7I	#I)I-%
H47
I	
I
I*-
I;wrap)singlelistre  )idsc                 ~   [        5       n[        R                  " [        SS9   [	        X" S/5      5        S S S 5        UR
                  " [        5       6   [	        X" S/5      5        [        R                  " [        SS9   [	        X" S/5      5        S S S 5        g ! , (       d  f       Nl= f! , (       d  f       g = f)Nzis not fitted yetr   coef_	coef_bad_)r   rQ   rR   r   r?   r   r
   )r  r  s     rU   $test_check_is_fitted_with_attributesr    s     /C	~-@	AT7)_- 
B GGZ\ Cwi) 
~-@	AT;-01 
B	A 
B	A 
B	As   BB.
B+.
B<c                     [        S/S/S/S/S/5        [        SS/SS///SS/SS/5        [        S/S[        R                  " S/5      [        R                  " S	5      5        [
        R                  " [        S
S9   [        SS/S/5        SSS5        [
        R                  " [        SS9   [        SS/S5        SSS5        [
        R                  " [        SS9   [        SS/[        5       5        SSS5        [
        R                  " [        5         [        SS/[        R                  " S5      5        SSS5        [
        R                  " [        SS9   [        SS/[        5       5        SSS5        g! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Nz= f! , (       d  f       g= f)zlTest that `check_consistent_length` raises on inconsistent lengths and wrong
input types trigger TypeErrors.r   r^   rX   r   r_   r   r   )r^   r   r^   inconsistent numbers of samplesr   Nzgot <\w+ 'int'>zgot <\w+ 'object'>Expected sequence or array-like)r>   rK   r   rs   r   rQ   rR   rS   r   rp   r   rT  r   rU   test_check_consistent_lengthr    sK    QC!qcA34aVq!fX.Ac
CQCrxx}bmmF6KL	z)J	KA, 
L	y(:	;A* 
<	y(=	>A1 
?	y	!A4 
" 
y(I	JA(=(?@ 
K	J 
L	K	;	;	>	>	!	! 
K	Js<   >E</FF#F/G <
F

F
F,/
F= 
Gzarray_namespace, device, _c                    [        X5      n[        SS9   [        UR                  / SQUS9UR                  SS/SS/SS//US9/ SQ/ SQ[        R                  " S[
        S	9[        R                  " S
S/SS
/S
S
//5      5        [        R                  " [        SS9   [        UR                  SS/US9UR                  S/US95        SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)zCTest that check_consistent_length works with different array types.Tarray_api_dispatchr   )devicer   r^   rX   r$  rZ   r   r  r   N)r   r   r>   r   rK   rp   rs   r   rQ   rR   rS   )array_namespacer  _xps       rU   &test_check_consistent_length_array_apir    s     
o	6B	4	0JJyJ0JJAAA/J?JJf5LL1a&1a&1a&12	
 ]]:-NO#

Aq6&
12::qc&:3Q P 
1	0 PO 
1	0s$   B	C,,C
C,
C)	%C,,
C:c                       SS K n [        R                  " / SQ/ SQ/ SQ/5      nU R                  U/ SQS9n[	        U5        g ! [
         a    [        S5      ef = f)Nr   r   r2  r3  )r   r   r   r&  zPandas not found)r   rK   r   r'  r>   ImportErrorr   )r   ry   r9  s      rU   "test_check_dataframe_fit_attributer  $  sU    +HHiI67||A'8|9% +)**+s   A A Ac                     [         R                  " S[         R                  /5      n [        R                  " [
        5         [        U 5        S S S 5        [        R                  " SS9  [        U 5        [        R                  " SS9  [        R                  " [
        5         [        U 5        S S S 5        g ! , (       d  f       Np= f! , (       d  f       g = f)Nr   T)assume_finiteF)	rK   r   infrQ   rR   rS   r=   sklearn
set_configr   s    rU   test_suppress_validationr  1  s    
!RVVA	z	"! 
#T*aU+	z	"! 
#	" 
#	"
 
#	"s   B7"C7
C
Cc                  8   [        S5      n [        U R                  / SQ5      SS9n[        U[        R
                  " / SQ5      5        U R                  / SQ5      R                  S5      n[        US SS9n[        U[        R
                  " / SQ[        S95        g )	Nr   r   Fr   r$  category)r[   r   rZ   )r   r   r   r#   rK   r   rg   rp   )r   resss      rU   test_check_array_seriesr  <  sr    	h	B
bii	*e
<CsBHHY/0 			/"))*5A
atu
5CsBHH_FCDr   r[   
bool_dtype)rj   booleanc           	         [        S5      nUR                  / SQ/ SQUR                  / SQUS9S./ SQS9n[        X0S9nUR                  [
        R                  :X  d   e[
        R                  " / SQ/ S	Q/ S
Q/[        S9n[        XE5        g )Nr   r   )r   r`    @TFTrZ   )r   r   rj   r  )      ?        r  )       @r`   r   )      @r  r  )
r   r'  r   r   r[   rK   ri   r   r   r"   )r[   r  r   dfr   expected_arrays         rU   'test_check_dataframe_mixed_float_dtypesr  H  s     
h	B	"II1ID	

 ) 
 
B (E;;"**$$$XX	/?;5N !7r   c                  l   [        S5      n U R                  S/ SQ05      n[        USS9nUR                  [        R
                  :X  d   e[        US/S/S//5        U R                  / SQ/ SQS	.SS
/S9n[        USS9nUR                  [        R                  :X  d   e[        USS/SS/SS//5        g)z7Check that dataframe with bool return a boolean arrays.r   rj   r  NrZ   TFr   )rj   r   r   r  r  r   r   r^   rX   )r   r'  r   r[   rK   bool_r#   rh   r   r  r   s      rU   #test_check_dataframe_with_only_boolr	  f  s    	h	B	v23	4B$'E;;"(("""uvw78 
$Y7 
 
B ),E;;"(("""u1v1v1v67r   c                      [        S5      n U R                  SU R                  / SQSS905      n[        USS9nUR                  [
        R                  :X  d   e[        US/S/S//5        g)	zFCheck that dataframe with boolean return a float array with dtype=Noner   rj   r  r  rZ   NTF)r   r'  r   r   r[   rK   ri   r#   r  s      rU   &test_check_dataframe_with_only_booleanr  y  sf    	h	B	vryy)<IyNO	PB$'E;;"**$$$uvw78r   c                       \ rS rSrS rSrg)DummyMemoryi  c                     U$ r  rT  )r  funcs     rU   cacheDummyMemory.cache  s    r   rT  N)r   r  r  r  r  r  rT  r   rU   r  r    s    r   r  c                       \ rS rSrSrg)WrongDummyMemoryi  rT  Nr   r  r  r  r  rT  r   rU   r  r    s    r   r  c                    [        U S-  5      n[        U5      nUR                  U:X  d   e[        S 5      nUR                  b   e[        5       n[        U5      nX#L d   eSn[        R
                  " [        US9   [        S5        S S S 5        [        5       nSR                  U5      n[        R
                  " [        US9   [        U5        S S S 5        g ! , (       d  f       NW= f! , (       d  f       g = f)Ncache_directoryzf'memory' should be None, a string or have the same interface as joblib.Memory. Got memory='1' instead.r   r   zg'memory' should be None, a string or have the same interface as joblib.Memory. Got memory='{}' instead.)	strr@   locationr  rQ   rR   rS   r  r   )tmp_pathr  memorydummyr   s        rU   test_check_memoryr    s    (%667O/*F??o---$F??"""ME% F??	2  
z	-Q 
.E	3396%=  
z	-U 
.	- 
.	- 
.	-s   <CC*
C'*
C8r]   c                     [         R                  " S5      n[        USS9 n[        X S9n[         R                  " X#5      U (       + :X  d   eUR
                  S   U :X  d   e S S S 5        g ! , (       d  f       g = f)N)r   r   r	mmap_moder\   	WRITEABLE)rK   rc   r   r   may_share_memoryr   )r]   ry   X_memmapr   s       rU   test_check_array_memmapr$    sc    
A	A	%4	""87HEEE{+t333 
&	%	%s   A A++
A9zOestimator_name, estimator_value, delegates, expected_result, expected_exception
estimator_SubEstimatorrT  attribute_presentr   estimators_custom_estimatorno_estimatorattribute_absent)'fitted_estimator_with_default_delegates estimator_with_default_delegates#list_of_estimators_with_estimators_&custom_estimator_with_custom_delegates#no_estimator_with_default_delegates5estimator_with_default_delegates_but_absent_attributec                    Uc  [        S5      nO
[        SUS9n " S S5      nU" 5       n[        XpU5        U(       a(  [        R                  " U5         U" U5        SSS5        gU" U5      U:X  d   eg! , (       d  f       g= f)z
Tests the _estimator_has function by verifying:
- Functionality with default and custom delegates.
- Raises ValueError if delegates are missing.
- Raises AttributeError if the specified attribute is missing.
Nr'  )	delegatesc                       \ rS rSrSrg))test_estimator_has.<locals>.MockEstimatori  rT  Nr  rT  r   rU   MockEstimatorr5    s    r   r6  )r5   setattrrQ   rR   )estimator_nameestimator_valuer3  expected_resultexpected_exceptioncheckr6  r   s           rU   test_estimator_hasr=    s|    J 232iH  	AA/]]-.!H /. Qx?*** /.s   	A55
Bc                 <   [         R                  " / SQ/ SQ/ SQ/ SQ/5      nU " U5      n[        US5        U " SS/SS//5      n[        US5        SUS'   U " U5      n[        R                  " [
        SS9   [        US5        S S S 5        g ! , (       d  f       g = f)	N)r   r   r   r   )r   r   r   r   r   r   r   rb   z	Negative r   )rK   r   rA   rQ   rR   rS   )r   r   ry   s      rU   test_check_non_negativer?    s     	,lLIJAq	Aq"AA Aq"AdGq	A	z	51b! 
6	5	5s   7B
Bc                  B   [         R                  " S5      n S nSn[        R                  " [        US9   [        X5        S S S 5        Sn[        R                  " [        US9   [        X[        5       S9  S S S 5        g ! , (       d  f       NE= f! , (       d  f       g = f)Nr^   r^   z;estimator requires y to be passed, but the target y is Noner   zGRandomForestRegressor requires y to be passed, but the target y is Noner   )rK   rc   rQ   rR   rS   r   r   ry   r   r   s      rU    test_check_X_y_informative_errorrD  !  sq    
AA
GC	z	-! 
. TC	z	-!"7"9: 
.	-	 
.	- 
.	-s   A?#B?
B
Bc                       " S S5      n U " 5       n[        U5      [        U5      :X  d   e " S S5      n[        R                  " [        SS9   [        U" 5       5        S S S 5        g ! , (       d  f       g = f)Nc                        \ rS rSrS rS rSrg)Jtest_retrieve_samples_from_non_standard_shape.<locals>.TestNonNumericShapei.  c                     SU l         g N)znot numericr   r  s    rU   __init__Stest_retrieve_samples_from_non_standard_shape.<locals>.TestNonNumericShape.__init__/  	    )DJr   c                     [        / SQ5      $ )Nr   )lenr  s    rU   __len__Rtest_retrieve_samples_from_non_standard_shape.<locals>.TestNonNumericShape.__len__2  s    y>!r   rJ  N)r   r  r  r  rK  rP  r  rT  r   rU   TestNonNumericShaperG  .  s    	*	"r   rR  c                       \ rS rSrS rSrg)Jtest_retrieve_samples_from_non_standard_shape.<locals>.TestNoLenWeirdShapei9  c                     SU l         g rI  rJ  r  s    rU   rK  Stest_retrieve_samples_from_non_standard_shape.<locals>.TestNoLenWeirdShape.__init__:  rM  r   rJ  Nr   r  r  r  rK  r  rT  r   rU   TestNoLenWeirdShaperT  9  s    	*r   rX  r  r   )r;   rO  rQ   rR   r   )rR  ry   rX  s      rU   -test_retrieve_samples_from_non_standard_shaperY  -  s`    " " 	A?c!f$$$* * 
y(I	J(*+ 
K	J	Js   A))
A7r   )r^   rX   g      @r_   c           
          [         R                  " 5          [         R                  " S5        [        U S[        R
                  SSSS9nSSS5        WU :X  d   eg! , (       d  f       N= f)zLTest that check_scalar returns no error/warning if valid inputs are
providedrF  	test_namer^   r_   bothtarget_typemin_valmax_valinclude_boundariesN)rG  rH  rI  rC   numbersReal)r   scalars     rU   test_check_scalar_validre  A  sZ     
	 	 	"g&%
 
# Q;; 
#	"s   3A
A(zJx, target_name, target_type, min_val, max_val, include_boundaries, err_msg
test_name1r   neitherz1test_name1 must be an instance of float, not int.z6test_name1 must be an instance of float, not NoneType.z4test_name1 must be an instance of int, not NoneType.z9test_name1 must be an instance of {float, bool}, not int.
test_name2ztest_name2 == 1, must be > 2.r_   
test_name3ztest_name3 == 5, must be < 4.
test_name4rightztest_name4 == 2, must be > 2.
test_name5leftztest_name5 == 4, must be < 4.
test_name6zbad parameter valuezyUnknown value for `include_boundaries`: 'bad parameter value'. Possible values are: ('left', 'right', 'both', 'neither').
test_name7zT`include_boundaries`='left' without specifying explicitly `min_val` is inconsistent.
test_name8zU`include_boundaries`='right' without specifying explicitly `max_val` is inconsistent.c           
         [         R                  " [        5       n[        U UUUUUS9  SSS5        [	        WR
                  5      [	        U5      :X  d   e[        UR
                  [        U5      5      (       d   eg! , (       d  f       NY= f)zHTest that check_scalar returns the right error if a wrong input is
givenr]  N)rQ   rR   	ExceptionrC   r  r   r   r   )r   target_namer^  r_  r`  ra  r   raised_errors           rU   test_check_scalar_invalidru  R  sw    l 
y	!\#1	
 
" |!!"c'l222l(($w-8888 
"	!s   A==
Br  )r_   y        -C6
?zJThere are imaginary parts in eigenvalues \(1e\-05 of the maximum real part)r_   g-C6
gưz?There are negative eigenvalues \(1e\-06 of the maximum positiveg|۽z?There are negative eigenvalues \(1e\-10 of the maximum positive)r_   g-=z=the largest eigenvalue is more than 1e\+12 times the smallest)nominalnominal_np_arrayinsignificant_imagzinsignificant negzinsignificant neg float32zinsignificant neg float64zinsignificant posz(lambdas, expected_lambdas, w_type, w_msgenable_warningsc                 J   U(       d  S nUcC  [         R                  " 5          [         R                  " S[        5        [	        XS9nS S S 5        O&[
        R                  " X#S9   [	        XS9nS S S 5        [        UW5        g ! , (       d  f       N= f! , (       d  f       N,= f)NrF  )ry  r   )rG  rH  rI  r   r0   rQ   r  r!   )lambdasexpected_lambdasw_typew_msgry  lambdas_fixeds         rU    test_check_psd_eigenvalues_validr    s     ~$$&!!'+BC2M '& \\&.2M /
 $m4 '& /.s   %B$
B
B
B")r_   y              @z/There are significant imaginary parts in eigenv)r   z,All eigenvalues are negative \(maximum is -1)r_   r   z*There are significant negative eigenvaluesga2U0*3?ggh㈵>g|)significant_imagzall negativezsignificant negzsignificant neg float32zsignificant neg float64zlambdas, err_type, err_msgc                 v    [         R                  " XS9   [        U 5        S S S 5        g ! , (       d  f       g = f)Nr   )rQ   rR   r0   )r{  err_typer   s      rU   "test_check_psd_eigenvalues_invalidr  /  s$     
x	/w' 
0	/	/s   *
8c                     [         R                  " S5      S S S2   n U R                  S   (       a   e[        U [         R                  " S5      S9n U R                  S   (       d   e[        S [         R                  " S5      S9n [	        U [         R                  " S5      5        [        S[         R                  " S5      S9n [	        U S[         R                  " S5      -  5        [
        R                  " [        S	S
9   [        [         R                  " S5      [         R                  " S5      S9  S S S 5        Sn[
        R                  " [        US
9   [        [         R                  " S5      [         R                  " S5      S9  S S S 5        [         R                  " S5      n[         R                  " S[         R                  S9n [        X5      n U R                  [         R                  :X  d   e[         R                  " S[        S9n[        S X"R                  S9n U R                  [         R                  :X  d   e[         R                  " S5      n[         R                  " [        U5      5      n SU S'   Sn[
        R                  " [        US
9   [        XSS9  S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN;= f! , (       d  f       g = f)NrY   r^   r   )r_   r   r   )r_   r^   r_   r  z)Sample weights must be 1D array or scalarr   )r^   r   rA  z/sample_weight.shape == \(4,\), expected \(2,\)!r   rZ   ir   z1Negative values in data passed to `sample_weight`T)r   )rK   rc   r   r2   r!   rQ   rR   rS   rf   r[   r   ri   r;   )r   r   ry   r   s       rU   test_check_sample_weightr  <  s   GGBK!$M"">222("''&/JM~... )AMM2771:. )@MM1rwwqz>2 
z)T	URWWV_@ 
V =C	z	-RWWQZ2776?; 
. 	AGGARZZ0M(:M"**,,, 	c"A(q@M"**,,, 	AGGLO,MM"AG	z	1]4H 
2	11 
V	U
 
.	-& 
2	1s$   ?3J*3J<K*
J9<
K
Kru   c                     [         R                  " S5      R                  SS5      nU " U5      U " U5      p2[        X#5      (       d   eg )Nr5  rX   rK   re   r   r-   ru   baser   r   s       rU   !test_allclose_dense_sparse_equalsr  h  s<    99Q<1%D4='$-q!!''''r   c                     [         R                  " S5      R                  SS5      nU " U5      U " US-   5      p2[        X#5      (       a   eg )Nr5  rX   r   r  r  s       rU   %test_allclose_dense_sparse_not_equalsr  o  sD    99Q<1%D4='$(+q%a+++++r   c                     [         R                  " S5      R                  SS5      nU " US-   5      nSn[        R                  " [
        US9   [        X5        S S S 5        g ! , (       d  f       g = f)Nr5  rX   r   zFCan only compare two sparse matrices, not a sparse matrix and an arrayr   )rK   re   r   rQ   rR   rS   r-   )ru   r   r   r   s       rU    test_allclose_dense_sparse_raiser  v  sP    
		!Q"AAA
RC	z	-q$ 
.	-	-s   A""
A0c                  V   [         SSS.S j5       n [        R                  " [        SS9   U " SSS5        S S S 5        [        R                  " [        SS9   U " SSSS	5        S S S 5        [         SSSSS
.S jj5       n[        R                  " [        SS9   U" SS5        S S S 5        [         SSS.S j5       n[        R                  " [        SS9   U" SS5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Nm= f! , (       d  f       g = f)Nr   r%  dc                    g r  rT  r   r   r%  r  s       rU   f1=test_deprecate_positional_args_warns_for_function.<locals>.f1      r   Pass c=3 as keyword argsr   r^   rX   Pass c=3, d=4 as keyword argsr   )r   r%  r  c                    g r  rT  r  s       rU   f2=test_deprecate_positional_args_warns_for_function.<locals>.f2  r  r   zPass b=2 as keyword argsc                    g r  rT  r  s       rU   f3=test_deprecate_positional_args_warns_for_function.<locals>.f3  r  r   )r   r4   rQ   r  FutureWarning)r  r  r  s      rU   1test_deprecate_positional_args_warns_for_functionr    s   1    
m+F	G
1a 
H 
m+K	L
1aA 
M  Q!q    
m+F	G
1a 
H  1    
m+F	G
1a 
H	G% 
H	G 
M	L 
H	G 
H	Gs/   C'C8
D	
D'
C58
D	
D
D(c                      [        SS9S 5       n [        R                  " [        SS9   U " SS5        S S S 5        g ! , (       d  f       g = f)Nz1.1)versionc                    g r  rT  r   r   s     rU   r  Etest_deprecate_positional_args_warns_for_function_version.<locals>.f1  r  r   z,From version 1.1 passing these as positionalr   r   r^   r  )r  s    rU   9test_deprecate_positional_args_warns_for_function_versionr    sH    . / 
L
 	1a
 
 
s	   
<
A
c                      " S S5      n [         R                  " [        SS9   U " SSS5        S S S 5        [         R                  " [        SS9   U " SSSS	5        S S S 5         " S
 S5      n[         R                  " [        SS9   U" SSS5        S S S 5        [         R                  " [        SS9   U" SSSS	5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N^= f! , (       d  f       g = f)Nc                   .    \ rS rSr\SSS.S j5       rSrg):test_deprecate_positional_args_warns_for_class.<locals>.A1i  r   r  c                    g r  rT  r  r   r   r%  r  s        rU   rK  Ctest_deprecate_positional_args_warns_for_class.<locals>.A1.__init__  r  r   rT  Nr   r  r  r  r4   rK  r  rT  r   rU   A1r    s    	#&'1 	 
$	r   r  r  r   r   r^   rX   r  r   c                   2    \ rS rSr\SSSS.S jj5       rSrg):test_deprecate_positional_args_warns_for_class.<locals>.A2i  r   r  c                    g r  rT  r  s        rU   rK  Ctest_deprecate_positional_args_warns_for_class.<locals>.A2.__init__  r  r   rT  N)r   r   r  rT  r   rU   A2r    s    	#	!q 	 
$	r   r  )rQ   r  r  )r  r  s     rU   .test_deprecate_positional_args_warns_for_classr    s     
 
m+F	G
1a 
H 
m+K	L
1aA 
M 
 
m+F	G
1a 
H 
m+K	L
1aA 
M	L 
H	G 
M	L 
H	G 
M	Ls/   CCC*3C;
C
C'*
C8;
D	rh  rX   c                    [         R                  R                  SS5      n/ SQ[         R                  " / SQ5      [        R
                  " / SQ5      R                  [        R
                  " / SQ5      SSS S.n[        XU S9nU b  U O [        [        UR                  S   5      5      nS	 H  nX5   X%   L a  M   e   US
   [        US
   U5      :X  d   e[        US   [        US   U5      5        [        US   [        US   U5      5        g )Nr   r^   )r   r^   rX   r   r   xxx)r  r   
sparse-col
sparse-row
scalar-int
scalar-strNone)r[  rh  r   )r  r  r  r  r  r   r  )rK   rL   randnr   rs   rt   r   r/   r  ranger   r   r#   r"   )rh  ry   _paramsr  indices_keys         rU   test_check_method_paramsr    s    
		1A,'mmL133mmL1G "!WEF!-w4aggaj8I3JHA{gl*** B &>^GFOXFFFFvgww7G(RS |nW\-BHMr   	sp_format)Tr   rY  r   rZ  c                 &   [         R                  " S5      n[        SS5      nUR                  R                  R                  U5      n[        X0S9nU SL a  Sn [        R                  " U5      (       d   eUR                  U :X  d   e[        X$5        g )Nr   rY   rX   rS  Tr   )rQ   r   r   r'  sparsefrom_spmatrixr   rs   r  r   r"   )r  r   sp_matsdfr  s        rU   "test_check_sparse_pandas_sp_formatr    s     
		X	&B"2q)F
,,


+
+F
3C6FD	;;v==I%%% 0r   zntype1, ntype2)	)
longdoubler7  )r7  rf   )rf   double)rl   rd   )rd   long)bytern   )ushortro   )ro   uint64)rm   rk   c           	          [         R                  " S5      nUR                  UR                  R	                  / SQU SS9UR                  R	                  / SQUSS9S.5      n[        USS/S	9  g
)zTCheck that pandas dataframes having sparse extension arrays with mixed dtypes
works.r   r   r   r   r   r[   
fill_valuer   r   r   col1col2r   rY  rS  N)rQ   r   r'  arraysSparseArrayr   )ntype1ntype2r   r  s       rU   %test_check_pandas_sparse_mixed_dtypesr    si    " 
		X	&B	II)))6a)PII)))6a)P	

B 5%.1r   z ntype1, ntype2, expected_subtyper  r  r  rf   ri   rk   r  shortrl   intcrd   intpr  r   rh   longlongint_ubyterm   rn   r  uintcro   uintr  uintp	ulonglongc           	      ,   [         R                  " S5      nUR                  UR                  R	                  / SQU SS9UR                  R	                  / SQUSS9S.5      n[        USS/S	9n[        R                  " UR                  U5      (       d   eg )
Nr   r  r   r  r  r  r   rY  rS  )	rQ   r   r'  r  r  r   rK   
issubdtyper[   )r  r  expected_subtyper   r  r=  s         rU   test_check_pandas_sparse_validr    s    . 
		X	&B	II)))6a)PII)))6a)P	

B b
7C==$45555r   constructor_name)r  re  r   	dataframe
sparse_csr
sparse_cscc                 L    / SQ/ SQ/n[        X5      n[        U5      S:X  d   eg)z$Check _num_features for array-likes.r   r2  rX   N)r    r:   )r  ry   s     rU   test_num_featuresr  '  s+     
IA1/Aq   r   r   r$  )FTF)r  g333333@g      @r   r   r%  )r   r  rj   r   dict)r  re  r   seriesc                    [        X5      n US:X  a  SnOUS:X  a  SnOUnSU 3n[        U S5      (       a  U[        R                  " S5      -  nO;[	        U S   [
        5      (       a  US	-  nO[	        U S   [        5      (       a  US
-  n[        R                  " [        US9   [        U 5        S S S 5        g ! , (       d  f       g = f)Nr   znumpy.ndarrayr  zpandas.*Series5Unable to find the number of features from X of type r   z with shape (3,)r   z" where the samples are of type strz# where the samples are of type dictr   )r    r   ru  rv  r   r  r  rQ   rR   r   r:   )ry   r  expected_type_namemessages       rU   &test_num_features_errors_1d_containersr  2  s     	1/A7",	X	%--
?@R?ST  q'299/00	AaD#		77	AaD$		88	y	0a 
1	0	0s   $B99
C)r   r   Fr  )r   r  rj   r   c                     S[        U 5      R                   3n[        R                  " [        US9   [        U 5        S S S 5        g ! , (       d  f       g = f)Nr  r   )r   r  rQ   rR   r   r:   )ry   r   s     rU    test_num_features_errors_scalarsr  S  s;    A$q'BVBVAW
XC	y	,a 
-	,	,s   A
Anamesr  )zlist-intr  default
MultiIndexc                    [         R                  " S5      nUR                  SS/SS/SS//U S9n[        R                  " 5          [        R
                  " S[        5        [        U5      n S	S	S	5        U b   eg	! , (       d  f       N= f)
zGet feature names with pandas dataframes without warning.

Column names with consistent dtypes will not warn, such as int or MultiIndex.
r   r   r^   r   r_   r   r  rF  N)rQ   r   r'  rG  rH  rI  r  r6   )r  r   ry   s      rU   2test_get_feature_names_pandas_with_ints_no_warningr   Z  sy     
		X	&B
q!fq!fq!f-u=A		 	 	"g}5"1% 
# == 
#	"s   'A::
Bc                      [         R                  " S5      n [        S5       Vs/ s H  nSU 3PM
     nnU R                  / SQ/ SQ/US9n[	        U5      n[        XB5        gs  snf )z)Get feature names with pandas dataframes.r   rX   col_r   r2  r  N)rQ   r   r  r'  r6   r#   )r   rB  r&  ry   feature_namess        rU   test_get_feature_names_pandasr  m  s^    			X	&B#(8,8aaSz8G,
i+W=A&q)M}.	 -s   A"zconstructor_name, minversion))pyarrowz12.0.0)r  z1.5.0)polarsz0.18.2c                 \    / SQ/ SQ/n/ SQn[        X X1S9n[        U5      n[        XS5        g)z:Uses the dataframe exchange protocol to get feature names.r   r   r^   rX   rX   r   )col_0col_1col_2)columns_namer#  N)r    r6   r#   )r  r#  r   r&  r  r  s         rU   )test_get_feature_names_dataframe_protocolr  w  s6     y!D)G	W
B 'r*M}.r   )r  r  r  c                 ~    [        / SQ/ SQ/U 5      nU S;   a  [        U5      (       a   eg [        U5      (       d   eg )Nr  r	  )r  r  )r    r8   )r  r  s     rU   !test_is_pandas_df_other_librariesr    sB    	Y	24D	EB00 $$$$$R    r   c                      [         R                  " S5      n U R                  / SQ/5      n[        U5      (       d   e[        [        R
                  " / SQ5      5      (       a   e[        S5      (       a   eg)z8Check behavior of is_pandas_df when pandas is installed.r   r   r   N)rQ   r   r'  r8   rK   r   )r   r  s     rU   test_is_pandas_dfr    sa    			X	&B	yk	"BRZZ	23333Qr   c                 x    [        [        R                  " / SQ5      5      (       a   e[        S5      (       a   eg)z1Check _is_pandas_df when pandas is not installed.r   r   N)r8   rK   r   )hide_available_pandass    rU   &test_is_pandas_df_pandas_not_installedr    s2     RZZ	23333Qr   r  r  r   r  c                 |    [        / SQ/ SQ/U US9nU S;   a  [        U5      (       a   eg [        U5      (       d   eg )Nr  r	  r"  )r  r  )r    r9   )r  r#  r  s      rU   !test_is_polars_df_other_librariesr    sL     
	I
B
 33 $$$$$R    r   c                  J     " S S5      n U " 5       n[        U5      (       a   eg)zACheck _is_polars_df for object that looks like a polars dataframec                       \ rS rSrS rSrg)Ntest_is_polars_df_for_duck_typed_polars_dataframe.<locals>.NotAPolarsDataFramei  c                 $    / SQU l         SU l        g )Nr   	my_schemar&  schemar  s    rU   rK  Wtest_is_polars_df_for_duck_typed_polars_dataframe.<locals>.NotAPolarsDataFrame.__init__  s    $DL%DKr   r  NrW  rT  r   rU   NotAPolarsDataFramer    s    	&r   r   Nr9   )r   not_a_polars_dfs     rU   1test_is_polars_df_for_duck_typed_polars_dataframer#    s*    & &
 *+O_-----r   c                  \    [         R                  " / SQ/ SQ/5      n [        U 5      nUb   eg)z/Get feature names return None for numpy arrays.r   r2  N)rK   r   r6   )ry   r  s     rU   test_get_feature_names_numpyr%    s)    
)Y'(Aq!E==r   znames, dtypesz['int', 'str']pizzaz['list', 'str']zint-strzlist-strc                    [         R                  " S5      nUR                  SS/SS/SS//U S9n[        R                  " SU S	35      n[         R
                  " [        US
9   [        U5      n SSS5        g! , (       d  f       g= f)zAGet feature names errors when the feature names have mixed dtypesr   r   r^   r   r_   r   r  z]Feature names are only supported if all input features have string names, but your input has a.   as feature name / column name types. If you want feature names to be stored and validated, you must convert them all to strings, by using X.columns = X.columns.astype(str) for example. Otherwise you can remove feature / column names from your input data, or convert them all to a non-string data type.r   N)rQ   r   r'  ru  rv  rR   r   r6   )r  r   r   ry   r   s        rU   %test_get_feature_names_invalid_dtypesr(    s     
		X	&B
q!fq!fq!f-u=A
))	$X &?	?C 
y	,"1% 
-	,	,s   #A88
Bc                   .    \ rS rSrSS jrS rSS jrSrg)PassthroughTransformeri  Nc                     [        XSS9  U $ )NT)reset)rF   r  s      rU   r   PassthroughTransformer.fit  s    dT*r   c                     U$ r  rT  )r  ry   s     rU   	transform PassthroughTransformer.transform  s    r   c                     [        X5      $ r  )r.   )r  input_featuress     rU   get_feature_names_out,PassthroughTransformer.get_feature_names_out  s    &t<<r   rT  r  )r   r  r  r  r   r/  r3  r  rT  r   rU   r*  r*    s    =r   r*  c                     [         R                  " / SQ/5      n [        5       R                  U 5      nUR	                  5       n[        U/ SQ5        SS/n[        R                  " [        SS9   UR	                  U5        SSS5        U?	[        R                  " [        SS9   UR	                  5         SSS5        g! , (       d  f       NC= f! , (       d  f       g= f)	z4Check behavior of check_feature_names_in for arrays.r   r  r  )x0x1x2x10r8  z*input_features should have length equal tor   Nz Unable to generate feature names)
rK   r   r*  r   r3  r#   rQ   rR   rS   n_features_in_)ry   r  r  incorrect_len_namess       rU   test_check_feature_names_inr=    s    
/"#A
 
"
&
&q
)C%%'Eu01 $-	z)U	V!!"56 
W 		z)K	L!!# 
M	L 
W	V
 
M	Ls   .B=#C=
C
Cc                  X   [         R                  " S5      n / SQnU R                  / SQ/US9n[        5       R	                  U5      nUR                  5       n[        U/ SQ5        [         R                  " [        SS9   UR                  / SQ5        SSS5        g! , (       d  f       g= f)	z?Check behavior of check_feature_names_in for pandas dataframes.r   r$  r6  r  zinput_features is not equal tor   )r8  r9  x3N)	rQ   r   r'  r*  r   r3  r#   rR   rS   )r   r  r  r  s       rU   "test_check_feature_names_in_pandasr@    s    			X	&BE	'	7B
 
"
&
&r
*C%%'Euo.	z)I	J!!"45 
K	J	Js   >B
B)c                      Sn [         R                  " [        U S9   [        [	        5       S5        SSS5        g! , (       d  f       g= f)z@Check the error message when passing an unknown response method.zKRandomForestRegressor has none of the following attributes: unknown_method.r   unknown_methodN)rQ   rR   r  r1   r   )r   s    rU   )test_check_response_method_unknown_methodrC    s8     	V  
~W	5468HI 
6	5	5s	   :
Aresponse_method)decision_functionpredict_probapredictc                     SU  S3n[         R                  " [        US9   [        [	        5       U 5        SSS5        g! , (       d  f       g= f)zQCheck the error message when a response method is not supported by the
estimator.z7EstimatorWithFit has none of the following attributes: .r   N)rQ   rR   r  r1   r   )rD  r   s     rU   8test_check_response_method_not_supported_response_methodrJ    sB     B/ARRST  
~W	5/1?C 
6	5	5s	   >
Ac                  p   S/n [        U 5      nSnSS/nSSR                  U5       S3n[        R                  " [        US9   [        X5      " U5        S	S	S	5        SS/n[        X5      " U5      nUS:X  d   eSS/n [        U 5      n/ S
Qn[        X5      " U5      nUS:X  d   eg	! , (       d  f       NX= f)z0Check that we can pass a list of ordered method.rF  mocking_datarE  rG  zD_MockEstimatorOnOffPrediction has none of the following attributes: z, rI  r   N)rE  rG  rF  )r   joinrQ   rR   r  r1   )method_implementedmy_estimatorry   rD  r   method_name_predictings         rU   #test_check_response_method_list_strrQ  "  s    )*01CDLA +I6ON99_%
&a	)  
~W	5|=a@ 
6 +O<O3LRSTU!_444 *9501CDLGO3LRSTU!Y... 
6	5s   B''
B5c                      [        S5      n [        U R                  SS/5      SS9n[        R                  " SS/5      nUR
                  UR
                  :X  d   e[        X5        g)zRegression test for gh-25145r   TFr   N)r   r   r   rK   r   r[   r#   )r   r  expecteds      rU   #test_boolean_series_remains_booleanrT  ?  sU    	h	B
biiu.%
@Cxxu&H99&&&s%r   input_values)r   r   r   r   r   r   c                     [        S5      nUR                  U SS9n[        USSSSS9n[        R                  " UR
                  R                  [        R                  5      (       d   e[        X05        g)zhCheck pandas array with extensions dtypes returns a numeric ndarray.

Non-regression test for gh-25637.
r   Int32rZ   NF)r[   r   r   r   )	r   r   r   rK   r  r[   rC  floatingr!   )rU  r   input_seriesr  s       rU   !test_pandas_array_returns_ndarrayrZ  I  sh     
h	B88L88LF ==**BKK8888F)r   c                     [         R                  " S5      n U R                  U R                  SS/SU R                  S//U R                  S9n[        SS9   [         R                  " [        SS	9   [        U5        S
S
S
5        S
S
S
5        U R                  U R                  SS/SU R                  S//U R                  S9n[        SS9   [         R                  " [        SS	9   [        U5        S
S
S
5        S
S
S
5        g
! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N9= f! , (       d  f       g
= f)z9Checks that Array API arrays checks non-finite correctly.array_api_strictr   r   rX   rZ   Tr  r   r   Nzinfinity or a value too large)
rQ   r   r   rv   rf   r   rR   rS   r   r  )r  X_nanX_infs      rU   )test_check_array_array_api_has_non_finiter_  \  s     
		/	0BJJABFFA7rzzJJE	4	0]]:-BC D 
1 JJABFFA7rzzJJE	4	0]]:-LM N 
1	0	 DC 
1	0 NM 
1	0sH   D0D<DD5%D$1D5
D	D
D!$
D2	.D55
Ezextension_dtype, regular_dtype))r  rj   )r,  rh   )r   ri   )r  rp   include_objectc                 P   [         R                  " S5      nUR                  UR                  / SQUS9UR                  / SQSS9S.5      nU(       a  UR                  / SQSS9US	'   UR	                  US
   R                  U 5      S9n[        USS9n[        USS9n[        Xg5        g)zKCheck pandas extension arrays give the same result as non-extension arrays.r   )r   r   r   r   rZ   )r5  r   r4  r   rh   )r   r%  r  rp   r   r   )r   N)rQ   r   r'  r   assignrg   r   r#   )extension_dtyperegular_dtyper`  r   	X_regularX_extensionX_regular_checkedX_extension_checkeds           rU   $test_check_array_multiple_extensionsri  l  s     
		X	&B<}=<w7	
I #7xH	#""Ys^%:%:?%K"LK#IT:%k>(>r   c                      [         R                  " S5      n U R                  / SQ/ SQS.5      n[        U5      S:X  d   eg)zDUse the DataFrame interchange protocol to get n_samples from polars.r  r   r2  r  rX   N)rQ   r   r'  r;   )plr  s     rU   #test_num_samples_dataframe_protocolrl    s8    			X	&B	II6	7Bq   r   r  output_format)r   rY  r   c                    U " SS/SS//[         R                  S9n[        US5      (       a/  UR                  R	                  [         R
                  5      Ul        O[        US5      (       a@  [        US5      (       a/  UR                  R	                  [         R
                  5      Ul        O~[        US5      (       am  [        US5      (       a\  UR                  R	                  [         R
                  5      Ul        UR                  R	                  [         R
                  5      Ul        [        X!S	9nUS
:X  aU  UR                  R                  [         R
                  :X  d   eUR                  R                  [         R
                  :X  d   egUR                  R                  [         R
                  :X  d   eUR                  R                  [         R
                  :X  d   eg)zGCheck the consistency of the indices dtype with sparse matrices/arrays.r   r   rZ   offsetsrf  rg  rh  ri  rS  r   N)rK   ri   r   ro  rg   rd   rf  rh  ri  r   r[   rg  )r  rm  ry   r   s       rU   1test_check_array_dia_to_int32_indexed_csr_csc_coorp    sL    	1a&1a&)<A q)II$$RXX.		E		wq%00RXX&	I		71h#7#7II$$RXX.	88??288,A;I}}""bhh...}}""bhh...  &&"((222%%111r   sequencec                     [        U 5      n[        U[        R                  5      (       d   eUR                  R
                  S:X  d   eUR                  S:X  d   eg )NOr   )r<   r   rK   r   r[   rC  r   )rq  outs     rU   test_to_object_arrayru    sI    
8
$Cc2::&&&&99>>S   88q==r   c                     S/ SQ4S/ SQ4S[         R                  " S5      S-  4S/ SQ4S/ S	Q4SS
/S/S//4S/ SQ/ SQ/4S/ SQ/4SS
S
/SS/SS
//4SSS
/SS/SS
//4S/ SQ/4S[         R                  " S5      R                  S5      4/n U  Hd  u  pUS;   a+  [        [	        U5      [         R
                  " U5      5        M6  [        R                  " [        5         [	        U5        S S S 5        Mf     g ! , (       d  f       Mx  = f)Nbinary)spameggrx  )r   r   r   r   
continuousrY   g      4@
multiclassr   )r   r   r^   r^   r   r   r^   rX   zmultilabel-indicatorr  )r   r   r   zmulticlass-multioutputr_   r   zcontinuous-multioutput   )r   rX   )rw  r{  rz  )	rK   re   r   r#   rD   r   rQ   rR   rS   )EXAMPLESy_typer   s      rU   test_column_or_1dr    s   	*+	< 	ryy}t+,	y!	'	aS1#'	)Y!78	!I;/	!QFQFQF#;<	!QFQFQF#;<	!I;/	!299R=#8#8#ABH 	;;|A<z*Q +*	  +*s   C88
D	c                  F     " S S5      n [        U " 5       5      (       a   eg)z@Check that _is_polars_df return False for non-dataframe objects.c                       \ rS rSrS rSrg)+test__is_polars_df.<locals>.LooksLikePolarsi  c                 (    SS/U l         SS/U l        g )Nr   r   r  r  s    rU   rK  4test__is_polars_df.<locals>.LooksLikePolars.__init__  s    :DL*DKr   r  NrW  rT  r   rU   LooksLikePolarsr    s    	%r   r  Nr!  )r  s    rU   test__is_polars_dfr    s%    % %
 _./////r   c                  t   [         R                  R                  SS9n [        U SSS9n[         R                  " X5      (       d   eUR
                  R                  (       d   eSU R
                  l        [        U SSS9n[         R                  " X5      (       a   eUR
                  R                  (       d   eg)zqCheck the behavior of check_array when a writeable array is requested
without copy if possible, on numpy arrays.
r   sizeFTr]   force_writeableN)rK   rL   uniformr   r"  r   	writeable)ry   rt  s     rU   test_check_array_writeable_npr    s     			x(A
aeT
:Cs&&&&99AGG
aeT
:C""3****99r   c                  z   [         R                  R                  SS9n [        U SS9n[	        USSS9n[         R
                  " X!5      (       d   eUR                  R                  (       d   e[        U SS9n[	        USSS9n[         R
                  " X!5      (       a   eUR                  R                  (       d   eg	)
a  Check the behavior of check_array when a writeable array is requested
without copy if possible, on a memory-map.

A common situation is when a meta-estimators run in parallel using multiprocessing
with joblib, which creates read-only memory-maps of large arrays.
r   r  zw+r  FTr  r  N)rK   rL   r  r$   r   r"  r   r  )ry   mmaprt  s      rU   test_check_array_writeable_mmapr    s     			x(A$Q$7D
d
=Cs))))99$Q#6D
d
=C""3----99r   c                     [         R                  " S5      n [        R                  R	                  SS9nU R                  USS9n[        USSS9n[        R                  " X25      (       d   eUR                  R                  (       d   eSUR                  l	        U R                  USS9n[        USSS9n[        R                  " X25      (       a   eUR                  R                  (       d   eg)	zpCheck the behavior of check_array when a writeable array is requested
without copy if possible, on a dataframe.
r   r   r  Fr\   Tr  N)
rQ   r   rK   rL   r  r'  r   r"  r   r  )r   ry   r  rt  s       rU   test_check_array_writeable_dfr  	  s     
		X	&B
		x(A	ae	$B
bud
;Cs''''99AGG	ae	$B
bud
;C""3++++99r   c                  J   [         R                  " / SQ/ SQ/5      n [        SS9   [         R                  " [	        U SS95      (       d   e[
        R                  " [        5         [	        U 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr  r  Tr  rS  )rs   r   r   r  r   rQ   rR   r   )X_sps    rU   8test_check_array_on_sparse_inputs_with_array_api_enabledr  	  sl    <<I./D	4	0{{;t4@AAAA]]9% & 
1	0 &% 
1	0s$   A B&B2B
B	B
B"c                     [         R                  R                  SS9n [         R                  R                  SSS9nSn[        R
                  " [        US9   [        U SS9  S S S 5        [        R
                  " [        US9   [        XSS9  S S S 5        [        R
                  " [        US9   [        U SS9  S S S 5        g ! , (       d  f       Ng= f! , (       d  f       NL= f! , (       d  f       g = f)	Nr   r  r   )rY   z5'force_all_finite' was renamed to 'ensure_all_finite'r   T)force_all_finite)
rK   rL   r  rP   rQ   r  r  r   r   r   rC  s      rU   $test_force_all_finite_rename_warningr  $	  s    
		x(A
		!%(A
AC	m3	/A- 
0 
m3	/!. 
0 
m3	/q40 
0	/ 
0	/ 
0	/ 
0	/s$   CC/C%
C
C"%
C3ry   r   expected_error_messagezLFound array with dim 3, while dim <= 2 is required by RandomForestRegressor.z3Found array with dim 3, while dim <= 2 is required.c                 |    [         R                  " [        US9   [        XS9  S S S 5        g ! , (       d  f       g = f)Nr   rB  r  r  s      rU    test_check_array_allow_nd_errorsr  4	  s(    " 
z)?	@A+ 
A	@	@s   
-
;)__doc__rb  ru  rG  	itertoolsr   operatorr   tempfiler   numpyrK   rQ   scipy.sparser  rs   r   r  sklearn._configr   sklearn._min_dependenciesr   sklearn.baser	   sklearn.datasetsr
   sklearn.ensembler   sklearn.exceptionsr   r   sklearn.linear_modelr   (sklearn.metrics.tests.test_score_objectsr   sklearn.neighborsr   sklearn.random_projectionr   sklearn.svmr   sklearn.utilsr   r   r   r   r   r   sklearn.utils._array_apir   r   sklearn.utils._mockingr   r   sklearn.utils._testingr   r   r   r    r!   r"   r#   r$   r%   sklearn.utils.estimator_checksr&   sklearn.utils.fixesr'   r(   r)   r*   r+   sklearn.utils.validationr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rV   r   markparametrizerL   r   r   r   r   r  rv   r   r   r   r   r   r   r   rp   r   r   filterwarningsr	  r  rf   ri   r*  r0  r;  r@  rD  rQ  rV  rX  fixturerk  rn  rp  ry  r  r  r  r  r  r  r  r  re  r  r  r  r  r  r  r  r	  r  r  r  r  r$  r   rS   r  r=  rt   r  r  r  r  
dia_matrixr?  rD  rY  re  r   r   rc  Integralrj   r   ru  _psd_cases_validvalueskeysr  _psd_cases_invalidr  r  r  r  r  r  r  r  r  r  r  rX  integerunsignedintegerr  r  r  r  r  r   r  r  r  r  r  r  r#  r%  r(  r*  r=  r@  rC  rJ  rQ  rT  rZ  r_  ri  rl  rp  ru  r  r  r  r  r  r  r  r  rT  r   rU   <module>r     s<   *  	    '      * 8 & ' 2 F . F 2 ;  
 
 
 7        >0$'%T "))

7
#RYYr1U%C	D11G ,& ffe_rvv{+bffe_= BJJ#>?/ @	
/ 5	T45	d78	$(OP	k#>?	T/0	d23	d23FF?		
 
Q,-& BJJ#>?
 @'(
 'BCBJJ#>?%1 @ D%1P
;  HHq"&&k]#!	

 HHq"&&k]#!	

 HHq"&&k]#C	
 
Arvv;-v	.0UV$ ,tUm<G =%&G) QRA
 SA
H 
sc3Z 
3*sCj)5
3*sCj)5
d|$
4,t-T:	(	( J 
**bjj	!2::.	RZZ 	BJJ//:%*"GJ5=()V9>/ 34 5,G
L<%~'T  0F'*!(H"BJ 
Z]D%(.I  22A(  -/'  

(
+	E rzz2::&

D)D ':;8 <848&9 
	 	6 $/4 04 U &94%@A	
 &94%@A	
 ^R*=t)DE O	
 &94%@A 	
 &94%@A	
 &8$%?@	
M-\	a  8r+s8r+< 









	
"
"	;,( n- .  P IJ	
 LLNO	
 LM	
 DMQR	
 67	
 67	
 67	
 67	
 !M	
 #	
 #	
Cmpb9cpb9& !Q($31a&)288QF+;T2F
!QV	 %bhh1v&68OQST
!U2::.
!Qrzz*K	" 	!VBJJ/
!Qrzz*K	" 	
!QH	- > .		 	 	"#""$%  
 *T5M:5 ;54 	9 	7 	4 	$bjj14  	$rzz24 + :  		"	"	$%$$&'  
(
()IX RXXr}}bmm$LM( N( RXXr}}bmm$LM, N, R]]BMM$BC% D%60 TAq6N3 40 &HI1 J1$ 

2
2 &	<-	9bkk*	9bkk*	$	'2::&	"**%	$	

#	*bjj)	$	'2--.	8R//0	(B../	2--.	+r112(6)(6 G!	! 
qC8c1X& 	0  
 +-QR S
* 28WX Y 	%(^U1XtsCj3*%=>6  

/ "I	/		/ +-OP! Q!   "	&y1!45	(2156	%h/23	!	!	. 
q#$
C:	 12 
J  &&"	=] 	=$$6J HDD/:& 1aAq"&&*ACU)VW* X*$ ) ) $ )D%=9? :?*! ^#n4~E *?@2 A	
2, rxx{BHHQK&@Aq6Aq6BR%ST U 00&,. ) )1  0 HH1v1v&!Q!Q(89:!#%	
 HH1v1v&!Q!Q(89:A	
 ,! ,r   