
    -i              	       L   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJr	  SSK
r
SSKrSSKrSSKrSSKrSSKrSSK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  SS
KJ r J!r!J"r"J#r#  SSK$r$SSK%r&SSK'r(SSK)J*r+  SSK)J,r,J-r-J.r.J/r/  SSK0r0SSK1J2r2J3r3J4r4J5r5J6r6  SSK7J8r8  SSK9J:r:J;r;J<r<  SSK=J>r>  SSK?J@r@JArAJBrB  / SQrC\R                  R                  rES\F4S jrG " S S5      rH SAS jr*SBS jrISCS jrJS rK \8" S5        SrL SSKOrO\OR                  R                  \:SS9rR\OR                  R                  \<" 5       SS9rT\OR                  R                  \$R                  R                  (       + S S9rW\OR                  R                  \L(       + S!S9rX\OR                  R                  \R                  S":H  S#S9rZ\OR                  R                  \K" 5       (       + S$S9r[S% r\SDS& jr] " S' S(5      r^SES) jr_SDS* jr`S+ raSFS, jrbS- rcS. rdS/ reS\f" 5       4S0 jrgSSSSSSS\f" 5       4S1 jrhSGS2 jri    SHS3 jrjSIS4 jrk " S5 S6\R                  5      rm " S7 S85      rn " S9 S:5      ro " S; S<5      rpS= rqS> rrS? rsS@ rtg! \M\N4 a    SrL GNf = f! \M a     Nf = f)JzTesting utilities.    N)defaultdict
namedtuple)Iterable)	dataclass)context_diffwraps)	signature)chaingroupby)STDOUTCalledProcessErrorTimeoutExpiredcheck_output)assert_allclose)assert_almost_equalassert_array_almost_equalassert_array_equalassert_array_less)ClassifierTagsRegressorTagsTags
TargetTagsTransformerTags)_check_array_api_dispatch)	_IS_32BITVisibleDeprecationWarning#_in_unstable_openblas_configuration)check_classification_targets)check_arraycheck_is_fitted	check_X_y)SkipTestr   r   r   r   r   'assert_run_python_script_without_outputc                     [        U [        5      (       a9  [        U [        5      (       a$  U R                  n[        SR                  US95      e[        U 5      (       a  [        US9" U 5      $ [        US9$ )a  Context manager and decorator to ignore warnings.

Note: Using this (in both variants) will clear all warnings
from all python modules loaded. In case you need to test
cross-module-warning-logging, this is not your tool of choice.

Parameters
----------
obj : callable, default=None
    callable where you want to ignore the warnings.
category : warning class, default=Warning
    The category to filter. If Warning, all categories will be muted.

Examples
--------
>>> import warnings
>>> from sklearn.utils._testing import ignore_warnings
>>> with ignore_warnings():
...     warnings.warn('buhuhuhu')

>>> def nasty_warn():
...     warnings.warn('buhuhuhu')
...     print(42)

>>> ignore_warnings(nasty_warn)()
42
z'obj' should be a callable where you want to ignore warnings. You passed a warning class instead: 'obj={warning_name}'. If you want to pass a warning class to ignore_warnings, you should use 'category={warning_name}')warning_namecategory)	
isinstancetype
issubclassWarning__name__
ValueErrorformatcallable_IgnoreWarnings)objr(   r&   s      I/var/www/html/venv/lib/python3.13/site-packages/sklearn/utils/_testing.pyignore_warningsr4   J   sn    8 #tC!9!9 ||7 8>v<v7X	
 	
 
#1#6611    c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
r1   v   aX  Improved and simplified Python warnings context manager and decorator.

This class allows the user to ignore the warnings raised by a function.
Copied from Python 2.7.5 and modified as required.

Parameters
----------
category : tuple of warning class, default=Warning
    The category to filter. By default, all the categories will be muted.

c                 j    SU l         [        R                  S   U l        SU l        / U l        Xl        g )NTwarningsF)_recordsysmodules_module_enteredlogr(   selfr(   s     r3   __init___IgnoreWarnings.__init__   s,    {{:. r5   c                 4   ^ ^ [        T5      UU 4S j5       nU$ )z<Decorator to catch and hide warnings without visual nesting.c                     > [         R                  " 5          [         R                  " STR                  5        T" U 0 UD6sS S S 5        $ ! , (       d  f       g = f)Nignore)r9   catch_warningssimplefilterr(   )argskwargsfnrA   s     r3   wrapper)_IgnoreWarnings.__call__.<locals>.wrapper   s<    ((*%%h>4*6* +**s   )A


Ar   )rA   rK   rL   s   `` r3   __call___IgnoreWarnings.__call__   s"     
r	+ 
	+
 r5   c                 "   / nU R                   (       a  UR                  S5        U R                  [        R                  S   La  UR                  SU R                  -  5        [        U 5      R                  nU< SSR                  U5      < S3$ )Nzrecord=Truer9   z	module=%r(z, ))r:   appendr=   r;   r<   r*   r-   join)rA   rI   names      r3   __repr___IgnoreWarnings.__repr__   sf    <<KK&<<s{{:66KKdll23Dz""411r5   c                 :   U R                   (       a  [        SU -  5      eSU l         U R                  R                  U l        U R                  S S  U R                  l        U R                  R
                  U l        [        R                  " SU R                  5        g )NzCannot enter %r twiceTrF   )
r>   RuntimeErrorr=   filters_filtersshowwarning_showwarningr9   rH   r(   rA   s    r3   	__enter___IgnoreWarnings.__enter__   sm    ==6=>>,,#}}Q/ LL44h6r5   c                     U R                   (       d  [        SU -  5      eU R                  U R                  l        U R
                  U R                  l        / U R                  S S & g )Nz%Cannot exit %r without entering first)r>   rY   r[   r=   rZ   r]   r\   r?   )rA   exc_infos     r3   __exit___IgnoreWarnings.__exit__   sI    }}FMNN#}}#'#4#4 r5   )r>   r[   r=   r:   r]   r(   r?   N)r-   
__module____qualname____firstlineno____doc__rB   rN   rV   r_   rc   __static_attributes__ r5   r3   r1   r1   v   s     
!	27r5   r1   T c           
          / n[         R                  " U 5      [         R                  " U5      pU R                  UR                  /nUc2  U Vs/ s H  o[         R                  :X  a  SOSPM     n	n[	        U	5      n[        U UUUUUUS9  gs  snf )a  dtype-aware variant of numpy.testing.assert_allclose

This variant introspects the least precise floating point dtype
in the input argument and automatically sets the relative tolerance
parameter to 1e-4 float32 and use 1e-7 otherwise (typically float64
in scikit-learn).

`atol` is always left to 0. by default. It should be adjusted manually
to an assertion-specific value in case there are null values expected
in `desired`.

The aggregate tolerance is `atol + rtol * abs(desired)`.

Parameters
----------
actual : array_like
    Array obtained.
desired : array_like
    Array desired.
rtol : float, optional, default=None
    Relative tolerance.
    If None, it is set based on the provided arrays' dtypes.
atol : float, optional, default=0.
    Absolute tolerance.
equal_nan : bool, optional, default=True
    If True, NaNs will compare equal.
err_msg : str, optional, default=''
    The error message to be printed in case of failure.
verbose : bool, optional, default=True
    If True, the conflicting values are appended to the error message.

Raises
------
AssertionError
    If actual and desired are not equal up to specified precision.

See Also
--------
numpy.testing.assert_allclose

Examples
--------
>>> import numpy as np
>>> from sklearn.utils._testing import assert_allclose
>>> x = [1e-5, 1e-3, 1e-1]
>>> y = np.arccos(np.cos(x))
>>> assert_allclose(x, y, rtol=1e-5, atol=0)
>>> a = np.full(shape=10, fill_value=1e-5, dtype=np.float32)
>>> assert_allclose(a, 1e-5)
Ng-C6?Hz>)rtolatol	equal_nanerr_msgverbose)np
asanyarraydtypefloat32maxnp_assert_allclose)
actualdesiredrn   ro   rp   rq   rr   dtypesru   rtolss
             r3   r   r      s    j FmmF+R]]7-CGllGMM*F|DJKF5"**,$6FK5z Ls   !Bc                    [         R                  R                  U 5      (       a  [         R                  R                  U5      (       a  U R                  5       n UR                  5       nU R	                  5         UR	                  5         [        U R                  UR                  US9  [        U R                  UR                  US9  [        U R                  UR                  X#US9  g[         R                  R                  U 5      (       d0  [         R                  R                  U5      (       d  [        XX#US9  g[        S5      e)a@  Assert allclose for sparse and dense data.

Both x and y need to be either sparse or dense, they
can't be mixed.

Parameters
----------
x : {array-like, sparse matrix}
    First array to compare.

y : {array-like, sparse matrix}
    Second array to compare.

rtol : float, default=1e-07
    relative tolerance; see numpy.allclose.

atol : float, default=1e-9
    absolute tolerance; see numpy.allclose. Note that the default here is
    more tolerant than the default for numpy.testing.assert_allclose, where
    atol=0.

err_msg : str, default=''
    Error message to raise.
)rq   )rn   ro   rq   zGCan only compare two sparse matrices, not a sparse matrix and an array.N)spsparseissparsetocsrsum_duplicatesr   indicesindptrr   datar.   )xyrn   ro   rq   s        r3   assert_allclose_dense_sparser      s    2 
yy!!3!3A!6!6GGIGGI		199aiiA188QXXw?TgNYY""299+=+=a+@+@4GDU
 	
r5   c                 L    SU R                  5       ;   a  U R                  US9  gg)aZ  Set random state of an estimator if it has the `random_state` param.

Parameters
----------
estimator : object
    The estimator.
random_state : int, RandomState instance or None, default=0
    Pseudo random number generator state.
    Pass an int for reproducible results across multiple function calls.
    See :term:`Glossary <random_state>`.
random_state)r   N)
get_params
set_params)	estimatorr   s     r3   set_random_stater   "  s+     --//,7 0r5   c                  :     SS K n g! [        [        4 a     gf = f)Nr   TF)numpydocImportErrorAssertionError)r   s    r3   _is_numpydocr   2  s(      ( s    Fzskipped on 32bit platforms)reasonz+OpenBLAS is unstable for this configurationzjoblib is in serial modez<SCIPY_ARRAY_API not set, or versions of NumPy/SciPy too old.darwinz)Possible multi-process bug with some BLASz+numpydoc is required to test the docstringsc                  v    [        [        R                  R                  SS5      5      (       a  [	        S5      eg )NSKLEARN_SKIP_NETWORK_TESTSr   z-Text tutorial requires large dataset download)intosenvirongetr#   rj   r5   r3   check_skip_networkr   o  s.    
2::>>6:;;FGG <r5   c                      [         R                  R                  U 5      (       a  [        R                  " U 5        gg! [
         a%    U(       a  [        R                  " SU -  5         g gf = f)zmUtility function to cleanup a temporary folder if still existing.

Copy from joblib.pool (for independence).
z$Could not delete temporary folder %sN)r   pathexistsshutilrmtreeOSErrorr9   warn)folder_pathr   s     r3   _delete_folderr   t  s[    
P77>>+&& MM+& '  PMM@;NO Ps   :> *A-,A-c                   .    \ rS rSrSrSS jrS rS rSrg)	
TempMemmapi  z9
Parameters
----------
data
mmap_mode : str, default='r'
c                     X l         Xl        g N)	mmap_moder   )rA   r   r   s      r3   rB   TempMemmap.__init__  s    "	r5   c                 R    [        U R                  U R                  SS9u  ol        U$ )NT)r   return_folder)create_memmap_backed_datar   r   temp_folder)rA   data_read_onlys     r3   r_   TempMemmap.__enter__  s)    +DIIt,
(( r5   c                 .    [        U R                  5        g r   )r   r   )rA   exc_typeexc_valexc_tbs       r3   rc   TempMemmap.__exit__  s    t''(r5   )r   r   r   N)r)	r-   re   rf   rg   rh   rB   r_   rc   ri   rj   r5   r3   r   r     s    )r5   r   c                 (   [         R                  " SS9n[        R                  " [        R
                  " [        USS95        [        R                  " US5      n[        R                  " X5        [        R                  " XAS9nU(       d  UnU$ XS4nU$ )z^
Parameters
----------
data
mmap_mode : str, default='r'
return_folder :  bool, default=False
sklearn_testing_)prefixT)r   zdata.pkl)r   )tempfilemkdtempatexitregister	functoolspartialr   oprT   joblibdumpload)r   r   r   r   filenamememmap_backed_dataresults          r3   r   r     s     ""*<=K
OOI%%nkMNww{J/H
KKXC"/  M 7I5V  Mr5   c                     [        U 5      R                  nUR                  5        VVs/ s H/  u  p4UR                  UR
                  UR                  4;  d  M-  UPM1     nnnU(       aZ  UR                  5        Vs/ s H+  nUR                  UR
                  :X  d  M  UR                  PM-     nn[        U5      S:X  a  SnXQ4$ U$ ! [         a    / s $ f = fs  snnf s  snf )z!Helper to get function arguments.r   N)
r
   
parametersr.   itemskindVAR_POSITIONALVAR_KEYWORDvaluesrU   len)functionvarargsparamskeyparamrI   s         r3   	_get_argsr     s    8$// !,,.(JC::e22E4E4EFF 	( 	 
   
(zzU111 EJJ( 	 

 w<1G}%  	
s(   C ,CC<CCCCc                 J   / n[         R                  " U 5      nU(       a  UR                  UR                  5        U R                  nX0R                  :w  a#  UR                  USUR                  S5       5        UR                  U R                  5        SR                  U5      $ )zGet function full name.

Parameters
----------
func : callable
    The function object.

Returns
-------
name : str
    The function name.
N.)inspect	getmodulerS   r-   rf   findrT   )funcpartsmodulequalnames       r3   _get_func_namer     s|     Et$FV__%  H== X2c 234	LL88E?r5   c           	        ^ SSK Jn  / nTc  / OTm[        U 5      nUR                  S5      (       a  UR                  S5      (       a  U$ [        R
                  " U 5      (       a  U$ UR                  S5      S   S;   a  U$ UR                  S5      S	   S
:X  a  U$ [        [        U4S j[        U 5      5      5      n[        U5      S:  a  US   S:X  a  UR                  S5        Ucr  / n[        R                  " SS9   [        R                  " S[        5         UR!                  U 5      nSSS5        [        U5      (       a  [)        SU< SUS   < 35      e/ n
US    H  u  pnUR+                  5       (       d{  SU;   a7  USUR-                  S5       SS R+                  5       (       a  UUSU-  -   /-  nO>UR/                  5       R1                  S5      (       a  UUSUR3                  5       -  -   /-  nSU;  d  M  U
R%                  UR                  S5      S   R+                  S5      5        M     [        U5      S:  a  U$ [        [        U4S jU
5      5      n
/ n	[5        [7        [        U
5      [        U5      5      5       H%  nXn   X   :w  d  M  U	SU< SXn   < S X   < 3/-  n	  O   [        U5      [        U
5      :  a  U	S!U[        U
5         -  /-  n	O-[        U5      [        U
5      :  a  U	S"U
[        U5         -  /-  n	[        U	5      S:X  a  / $ SSKnSSKnUR=                  U
5      R?                  5       nUR=                  U5      R?                  5       nU	S#/-  n	U	RA                  S$ URC                  UU5       5       5        URA                  U	5        SU-   /U-   nU$ ! [         am  nS[#        U5      ;   a9  [#        U5      R                  S5      SS n	USU 3/U	-   -  nUs SnAsSSS5        $ UR%                  [#        U5      5         SnAGNSnAf[&         a)  nXES-   [#        U5      -   /-  nUs SnAsSSS5        $ SnAff = f! , (       d  f       GN3= f)%a>  Helper to check docstring.

Parameters
----------
func : callable
    The function object to test.
doc : str, default=None
    Docstring if it is passed manually to the test.
ignore : list, default=None
    Parameters to ignore.

Returns
-------
incorrect : list
    A list of string describing the incorrect results.
r   )	docscrapeNzsklearn.zsklearn.externalsr   )setup_moduleteardown_module   estimator_checksc                    > U T;  $ r   rj   r   rF   s    r3   <lambda>,check_docstring_parameters.<locals>.<lambda>  s	    AVOr5   rA   T)recorderrorz"potentially wrong underline length
   zIn function: z parsing error: z
Error for z:

Parameters:z9 There was no space between the param name and colon (%r)z6 Parameter %r has an empty type spec. Remove the colon*z` c                    > U T;  $ r   rj   r   s    r3   r   r   >  s	    qr5   z\There's a parameter name mismatch in function docstring w.r.t. function signature, at index z diff: z != zbParameters in function docstring have less items w.r.t. function signature, first missing item: %sz`Parameters in function docstring have more items w.r.t. function signature, first extra item: %sz
Full diff:c              3   B   #    U  H  nUR                  5       v   M     g 7fr   )strip.0lines     r3   	<genexpr>-check_docstring_parameters.<locals>.<genexpr>i  s      RD 	

Rs   )"r   r   r   
startswithr   isdatadescriptorsplitlistfilterr   r   remover9   rG   rH   UserWarningFunctionDocstrrS   	ExceptionrY   r   indexrstripendswithlstriprangemindifflibpprintpformat
splitlinesextendndiff)r   docrF   r   	incorrect	func_nameparam_signaturerecordsexpmessage
param_docsrU   type_definition	param_docir
  r  param_docs_formattedparam_signature_formatteds     `                r3   check_docstring_parametersr    so   " #I>RvFt$I
++y/C/C0 0 %%sB#FFsA"446";Yt_MNO
?aOA$6&$@v& {$$D1!!';7!++D1 2  w<<iLMMJ,/,=(y$$&&d{t$5djjo6rs;AACCQTXXY 	 '',,N{{}&& 	 d?djjoa066t<=% ->, 9~ f6
CDJ G3s:O(<=>. &'(:JMK G
  ? ?c*o-:c*o./
 	
 
_	J	/8_-./
 	
 7|q	!>>*5@@B & ? J J L~GNN MM";=QR 
 W !9,-	9I  )73s8C "#hnnT22A6GM)"=!>!HHI$$ 21 s3x(( !*<<s3xGHH	   21! 21sZ   ?QN..
Q89P 1Q2Q P Q Q-QQQQQ
Q(c                 |    UR                   SLa  XR                   ;  a  gUR                  b  XR                  ;   a  gg)z7Helper to check if item should be included in checking.TF)includeexclude)	item_namerI   s     r3   _check_item_includedr"  v  s3    ||4I\\$A||I$=r5   c                     U R                  S5      (       a  gU R                  S5      (       a  gU R                  S5      (       a  gU R                  S5      (       a  gg)z,Key for grouping output from `context_diff`.z  z- z+ z! N)r   )r   s    r3   	_diff_keyr$    sM    t									r5   c                    SnSn/ nU R                  5        H  u  pEU(       d  U(       d  X$-  nUR                  U5        [        [        UR	                  5       UR	                  5       [        U5      [        U5      SS95      nUSR                  USS 5      -  n[        USS [        S9 HB  u  puUc  USSR                  U5      -   -  nM!  USU-   SR                  S	 U 5       5      -   -  nMD     US
-  nM     U$ )a	  Get message showing the difference between type/desc docstrings of all objects.

`docstrings_grouped` keys should be the type/desc docstrings and values are a list
of objects with that docstring. Objects with the same type/desc docstring are
thus grouped together.
rk      )fromfiletofilenNr   )r   r    c              3   *   #    U  H	  oS S v   M     g7f)r   Nrj   )r   words     r3   r    _get_diff_msg.<locals>.<genexpr>  s     3OHs   z

)	r   r  r   r   r   r  rT   r   r$  )docstrings_groupedmsg_diffref_str	ref_group	docstringgroupdiffstarts           r3   _get_diff_msgr6    s     HGI.446	y GU#!Y5z
 	BGGT"1X''#DH)<LE}D499U#333D5L3883O3O+OOO	 = 	F- 7. Or5   c                 f   / nU R                  5        GHp  u  px[        UR                  5        V	s/ s H  n	[        U	5      PM     sn	5      U:  a  UR	                  U5        MP  US:X  a  U(       a  / n
UR                  5        H3  u  p[
        R                  " XK5      (       a  M"  U
R                  U5        M5     U
(       a1  [        R                  " SUSS  SU SU
 SU S3	5      n[        U5      eM  US	:X  a  Xu;   a  M  [        UR                  5       5      S
:  d  GM  [        U5      nSR                  S UR                  5        5       5      n[        R                  " SU SUSS  SU SU S3	5      nX-  n[        U5      e   U(       a  [        R                  " SU SU S35        ggs  sn	f )a+  Helper to check docstring consistency of all `items_docs`.

If item is not present in all objects, checking is skipped and warning raised.
If `regex` provided, match descriptions to all descriptions.

Parameters
----------
items_doc : dict of dict of str
    Dictionary where the key is the string type or description, value is
    a dictionary where the key is "type description" or "description"
    and the value is a list of object names with the same string type or
    description.

type_or_desc : {"type description", "description"}
    Whether to check type description or description between objects.

section : {"Parameters", "Attributes", "Returns"}
    Name of the section type.

n_objects : int
    Total number of objects.

descr_regex_pattern : str, default=""
    Regex pattern to match for description of all objects.
    Ignored when `type_or_desc="type description".

ignore_types : tuple of str, default=()
    Tuple of parameter/attribute/return names for which type description
    matching is ignored. Ignored when `type_or_desc="description".
descriptionzThe description of Nr   z 'z' in z' does not match 'descr_regex_pattern': r*  type specification   z and c              3   8   #    U  H  n[        U5      v   M     g 7fr   )r  )r   r3  s     r3   r   +_check_consistency_items.<locals>.<genexpr>  s      &(CuE

(Cs   zThe z of z' is inconsistent between r   zChecking was skipped for z: z' as they were not found in all objects.)r   sumr   r   rS   researchr  textwrapfillr   keysr6  rT   r9   r   )
items_docstype_or_descsection	n_objectsdescr_regex_patternignore_typesskippedr!  r.  objsnot_matchedr2  r3  msgr/  
obj_groupss                   r3   _check_consistency_itemsrN    s   L G)3)9)9);%	&8&?&?&AB&AdD	&ABCiONN9%]*/BK$6$<$<$> 	yy!4@@&&u- %? mm)'#2,r)E+=>Q=RRSU %S))  11i6O#((*+a/$%78H  &(:(A(A(C& J --|nD"b D%,a)C OC %%= *<> 'y7) <( (	
 ; Cs   F.
c	           	        ^ SSK Jn	  [        S/ SQ5      mU4S jn
0 U
" XSS5      EU
" X4SS	5      EU
" XVS
S5      En[        5       nU  H  n[        R
                  " U5      (       d6  [        R                  " U5      (       d  [        R                  " U5      (       a*  U	" [        R                  " U5      5      XR                  '   M~  [        S[        U5       S35      e   [        U 5      nUR                  5        H  u  nn[        S 5      n[        S 5      nUR                  5        H  u  nnUU    H  u  nnn[        UU5      (       d  M  SR!                  UR#                  5       R%                  5       5      nSR!                  [&        R(                  " S U 5       5      5      nUU   U   R+                  U5        UU   U   R+                  U5        M     M     [-        USUUUS9  [-        USUUUS9  M     g)a+  Check consistency between docstring parameters/attributes/returns of objects.

Checks if parameters/attributes/returns have the same type specification and
description (ignoring whitespace) across `objects`. Intended to be used for
related classes/functions/data descriptors.

Entries that do not appear across all `objects` are ignored.

Parameters
----------
objects : list of {classes, functions, data descriptors}
    Objects to check.
    Objects may be classes, functions or data descriptors with docstrings that
    can be parsed by numpydoc.

include_params : list of str or bool, default=False
    List of parameters to be included. If True, all parameters are included,
    if False, checking is skipped for parameters.
    Can only be set if `exclude_params` is None.

exclude_params : list of str or None, default=None
    List of parameters to be excluded. If None, no parameters are excluded.
    Can only be set if `include_params` is True.

include_attrs : list of str or bool, default=False
    List of attributes to be included. If True, all attributes are included,
    if False, checking is skipped for attributes.
    Can only be set if `exclude_attrs` is None.

exclude_attrs : list of str or None, default=None
    List of attributes to be excluded. If None, no attributes are excluded.
    Can only be set if `include_attrs` is True.

include_returns : list of str or bool, default=False
    List of returns to be included. If True, all returns are included,
    if False, checking is skipped for returns.
    Can only be set if `exclude_returns` is None.

exclude_returns : list of str or None, default=None
    List of returns to be excluded. If None, no returns are excluded.
    Can only be set if `include_returns` is True.

descr_regex_pattern : str, default=None
    Regular expression to match to all descriptions of included
    parameters/attributes/returns. If None, will revert to default behavior
    of comparing descriptions between objects.

ignore_types : tuple of str, default=tuple()
    Tuple of parameter/attribute/return names to exclude from type description
    matching between objects.

Examples
--------
>>> from sklearn.metrics import (accuracy_score, classification_report,
... mean_absolute_error, mean_squared_error, median_absolute_error)
>>> from sklearn.utils._testing import assert_docstring_consistency
... # doctest: +SKIP
>>> assert_docstring_consistency([mean_absolute_error, mean_squared_error],
... include_params=['y_true', 'y_pred', 'sample_weight'])  # doctest: +SKIP
>>> assert_docstring_consistency([median_absolute_error, mean_squared_error],
... include_params=True)  # doctest: +SKIP
>>> assert_docstring_consistency([accuracy_score, classification_report],
... include_params=["y_true"],
... descr_regex_pattern=r"Ground truth \(correct\) (labels|target values)")
... # doctest: +SKIP
r   )NumpyDocStringrI   )r  r   arg_namec                 d   > U(       a  U SLa  [        SU SU S35      eU SL a  0 $ UT" XU5      0$ )NTzThe 'exclude_z-' argument can be set only when the 'include_z' argument is True.F)	TypeError)r  r   rQ  section_nameArgss       r3   _create_args2assert_docstring_consistency.<locals>._create_argsN  sT    wd*z *$:%8:  eId7X>??r5   r   r   attrs
AttributesreturnsReturnszDAll 'objects' must be one of: function, class or descriptor, got a: r   c                       [        [        5      $ r   r   r   rj   r5   r3   r   .assert_docstring_consistency.<locals>.<lambda>n  	    T):r5   c                       [        [        5      $ r   r]  rj   r5   r3   r   r^  o  r_  r5   r*  c              3   @   #    U  H  oR                  5       v   M     g 7fr   )r   r   s     r3   r   /assert_docstring_consistency.<locals>.<genexpr>u  s     7VQU

QUs   r9  )rH  r8  )rG  N)numpydoc.docscraperP  r   dictr   r   
isfunctionisclassgetdocr-   rS  r*   r   r   r   r"  rT   r   r   r   from_iterablerS   rN  )objectsinclude_paramsexclude_paramsinclude_attrsexclude_attrsinclude_returnsexclude_returnsrG  rH  rP  rV  section_argsobjects_docr2   rF  rE  rI   
type_items
desc_itemsobj_nameobj_docr!  type_defdescrU  s                           @r3   assert_docstring_consistencyrx    s   Z 2f@AD@
~x
N
}Wl
K I
NL &K$$S))!!#&&s##(6w~~c7J(KK%s)A'   GI%++- !:;
 !:;
!,!2!2!4Hg-4W-=)	8T'	488"xx(8(>(>(@AH88E$7$77VQU7V$VWDy)(3::8Dy)$/66x@ .> "5 	! %	
 	! 3	
) .r5   c                    [         R                  " SS9u  p4[        R                  " U5         [	        US5       nUR                  U R                  S5      5        SSS5        [        R                  U/n[        R                  " [        R                  " [        R                  " [        R                  5      S5      5      n[        R                  R!                  5       n [        R"                  R                  XxS   /5      US'   U[&        US.n	[        R                  R)                  S	5      n
U
(       a  XS
   S	'   X)S'     [+        U40 U	D6nUR3                  S5      n[4        R6                  " X5      (       a"  US:X  a  SnOSU< 3nU SU< 3n[9        U5      e [        R<                  " U5        g! , (       d  f       GNb= f! [$         a    XxS'    Nf = f! [,         a,  n[/        SUR0                  R3                  S5      -  5      eSnAff = f! [:         a,  n[/        SUR0                  R3                  S5      -  5      eSnAff = f! [        R<                  " U5        f = f)a'  Utility to check assertions in an independent Python subprocess.

The script provided in the source code should return 0 and the stdtout +
stderr should not match the pattern `pattern`.

This is a port from cloudpickle https://github.com/cloudpipe/cloudpickle

Parameters
----------
source_code : str
    The Python source code to execute.
pattern : str
    Pattern that the stdout + stderr should not match. By default, unless
    stdout + stderr are both empty, an error will be raised.
timeout : int, default=60
    Time in seconds before timeout.
z_src_test_sklearn.py)suffixwbzutf-8Nz..
PYTHONPATH)cwdstderrenvCOVERAGE_PROCESS_STARTr  timeoutzscript errored with output:
%s.+zExpected no outputz%The output was not supposed to match z$, got the following output instead: z!script timeout, output so far:
%s)r   mkstempr   closeopenwriteencoder;   
executabler   normpathrT   dirnamesklearn__file__r   copypathsepKeyErrorr   r   r   r   rY   outputdecoder>  r?  r   r   unlink)source_codepatternr  fdsource_filefcmdr}  r  rJ   coverage_rcouteexpectationr  s                  r3   r$   r$     s   $ &&.DEOBHHRL'+t$GGK&&w/0 %~~{+kk"''"**W-=-=">EFjjoo	$ "

,6G0H IC s;jjnn%=>6A5M23#y	"31&1 **W%Cyy&&d?"6K$I'"UK(M)McWU$W-- ' 			+M %$  	$ #	$ & "58PP   	4qxxw7OO 	
 			+s   I !F6BI !&G ;I G AH 6
G I GI GI 
H&'HHH 
I'III I&c                    US:X  a0  Uc  [        U 5      $ [        R                  " XS9R                  5       $ US:X  a9  Uc  [	        U 5      $ [	        [        R                  " XS9R                  5       5      $ US:X  a  [        R                  " XS9$ US;   aI  [
        R                  " SUS9nUR                  XUS	S
9nUb  U H  nXx   R                  S5      Xx'   M     U$ US:X  Ga  [
        R                  " SUS9n	[        R                  " U 5      n
U
R                  S:X  a	  U
SS2S4   OU
n
Uc+  [        U
R                  S   5       Vs/ s H  nSU 3PM
     nn[        U5       VVs0 s H  u  pXSS2U4   _M     nnnU	R                  R                  U5      nUbT  [        UR                  5       H;  u  pX;   d  M  UR!                  XUR#                  U5      R%                  5       5      nM=     U$ US:X  al  [
        R                  " SUS9nUR                  XSS9nUbB  U H<  nUR'                  UR)                  U5      R+                  UR,                  5      5      nM>     U$ US:X  a$  [
        R                  " SUS9nUR/                  XS9$ US:X  a&  [
        R                  " SUS9n	U	R1                  U 5      $ US:X  a$  [
        R                  " SUS9nUR/                  U S9$ US:X  a$  [
        R                  " SUS9nUR3                  XS9$ US:X  a  [5        U S   U S   5      $ SU;   a  [6        R8                  R;                  U 5      (       d  [        R<                  " U 5      n US;   a  [6        R8                  R?                  XS9$ US:X  a  [6        R8                  RA                  XS9$ US:X  a  [6        R8                  RC                  XS9$ US:X  a  [6        R8                  RE                  XS9$ ggs  snf s  snnf )aw  Convert a given container to a specific array-like with a dtype.

Parameters
----------
container : array-like
    The container to convert.
constructor_name : {"list", "tuple", "array", "sparse", "dataframe",             "series", "index", "slice", "sparse_csr", "sparse_csc",             "sparse_csr_array", "sparse_csc_array", "pyarrow", "polars",             "polars_series"}
    The type of the returned container.
columns_name : index or array-like, default=None
    For pandas container supporting `columns_names`, it will affect
    specific names.
dtype : dtype, default=None
    Force the dtype of the container. Does not apply to `"slice"`
    container.
minversion : str, default=None
    Minimum version for package to install.
categorical_feature_names : list of str, default=None
    List of column names to cast to categorical dtype.

Returns
-------
converted_container
r   N)ru   tuplearray)pandas	dataframer  )
minversionF)columnsru   r  r(   pyarrowr:  colpolarsrow)schemaorientseriespyarrow_arraypolars_series)r   r  slicer   r   )r   
sparse_csrsparse_csr_array
sparse_cscsparse_csc_array)#r   rs   asarraytolistr  pytestimportorskip	DataFrameastypendimr  shape	enumerateTablefrom_pydictcolumn_names
set_columncolumndictionary_encodewith_columnsr  castCategoricalSeriesr  Indexr  r~   r   r   
atleast_2d
csr_matrix	csr_array
csc_matrix	csc_array)	containerconstructor_namecolumns_nameru   r  categorical_feature_namespdr   col_namepar  r  rU   r   col_idxpls                   r3   _convert_containerr    s   D 6!=	?"::i5<<>>	W	$=##I;BBDEE	W	$zz)11	4	4  jAiUQVW$05#)#3#:#::#F  6	Y	&  zB

9%"'**/agu/4U[[^/DE/D!c!I/DLE1:<1HI1HgaAqDk!1HI%%d+$0%.v/B/B%C!8#..6==+B+T+T+VF &D
 	X	%  jAiUK$05,,RVVH-=-B-B2>>-RS 6	X	%  jAyyy00	_	,  zBxx	""	_	,  jAyy	y**	W	$  jAxx	x//	W	$Yq\9Q<00	%	%yy!!),,
 i0I7799''	'??!3399&&y&>>-99''	'??!3399&&y&>> 4 
&? FIs   	O6(O;c                     [        XX#5      $ )a  Context manager to ensure exceptions are raised within a code block.

This is similar to and inspired from pytest.raises, but supports a few
other cases.

This is only intended to be used in estimator_checks.py where we don't
want to use pytest. In the rest of the code base, just use pytest.raises
instead.

Parameters
----------
excepted_exc_type : Exception or list of Exception
    The exception that should be raised by the block. If a list, the block
    should raise one of the exceptions.
match : str or list of str, default=None
    A regex that the exception message should match. If a list, one of
    the entries must match. If None, match isn't enforced.
may_pass : bool, default=False
    If True, the block is allowed to not raise an exception. Useful in
    cases where some estimators may support a feature but others must
    fail with an appropriate error message. By default, the context
    manager will raise an exception if the block does not raise an
    exception.
err_msg : str, default=None
    If the context manager fails (e.g. the block fails to raise the
    proper exception, or fails to match), then an AssertionError is
    raised with this message. By default, an AssertionError is raised
    with a default error message (depends on the kind of failure). Use
    this to indicate how users should fix their estimators to pass the
    checks.

Attributes
----------
raised_and_matched : bool
    True if an exception was raised and a match was found, False otherwise.
)_Raises)expected_exc_typematchmay_passrq   s       r3   raisesr  4  s    J $X??r5   c                        \ rS rSrS rS rSrg)r  i\  c                     [        U[        5      (       a  UOU/U l        [        U[        5      (       a  U/OUU l        X0l        X@l        SU l        g )NF)r)   r   expected_exc_typesr  matchesr  rq   raised_and_matched)rA   r  r  r  rq   s        r3   rB   _Raises.__init__^  sP     +X66 #$ 	
 #-UC"8"8we "'r5   c                 2  ^^ Tc?  U R                   (       a  gU R                  =(       d    SU R                   3n[        U5      e[	        U4S jU R                   5       5      (       d$  U R                  b  [        U R                  5      TegU R
                  b~  U R                  =(       d4    SR                  SR                  U R
                  5      [        T5      5      n[	        U4S jU R
                   5       5      (       d  [        U5      TeSU l	        g)NTzDid not raise: c              3   <   >#    U  H  n[        TU5      v   M     g 7fr   )r+   )r   expected_typer   s     r3   r   #_Raises.__exit__.<locals>.<genexpr>t  s"      
!8 x//!8s   FzIThe error message should contain one of the following patterns:
{}
Got {}r   c              3   d   >#    U  H%  n[         R                  " U[        T5      5      v   M'     g 7fr   )r>  r?  r  )r   r  	exc_values     r3   r   r    s#     R\EryyI77\s   -0)
r  rq   r  r   anyr  r/   rT   r  r  )rA   r   r  _rq   s    ``  r3   rc   _Raises.__exit__i  s     }},,UOD<S<S;T*U$W-- 
!%!8!8
 
 
 ||'$T\\2	A<<#ll ((.tyy/FI(W  RT\\RRR$W-9<&*D#r5   )rq   r  r  r  r  N)r-   re   rf   rg   rB   rc   ri   rj   r5   r3   r  r  \  s    	(r5   r  c                   P    \ rS rSrSrSS jrSS jrS rS rS r	S	 r
S
 rS rSrg)MinimalClassifieri  zMinimal classifier implementation without inheriting from BaseEstimator.

This estimator should be tested with:

* `check_estimator` in `test_estimator_checks.py`;
* within a `Pipeline` in `test_pipeline.py`;
* within a `SearchCV` in `test_search.py`.
Nc                     Xl         g r   r   rA   r   s     r3   rB   MinimalClassifier.__init__      
r5   c                     SU R                   0$ Nr   r  rA   deeps     r3   r   MinimalClassifier.get_params      $$r5   c                 P    UR                  5        H  u  p#[        XU5        M     U $ r   r   setattrrA   r   r   values       r3   r   MinimalClassifier.set_params  #     ,,.JCDu% )r5   c                     [        X5      u  p[        U5        [        R                  " USS9u  U l        nUR                  5       U l        U $ )NT)return_counts)r"   r   rs   uniqueclasses_argmax_most_frequent_class_idx)rA   Xr   countss       r3   fitMinimalClassifier.fit  s?    $Q' "		!4 @v(.%r5   c                     [        U 5        [        U5      nUR                  S   U R                  R                  4n[
        R                  " U[
        R                  S9nSUS S 2U R                  4'   U$ )Nr   )r  ru   g      ?)	r!   r    r  r  sizers   zerosfloat64r  )rA   r  proba_shapey_probas       r3   predict_probaMinimalClassifier.predict_proba  s]    Nwwqz4==#5#56((BJJ?4740001r5   c                 `    U R                  U5      nUR                  SS9nU R                  U   $ )Nr:  )axis)r  r  r  )rA   r  r  y_preds       r3   predictMinimalClassifier.predict  s1    $$Q'Q'}}V$$r5   c                 <    SSK Jn  U" X R                  U5      5      $ )Nr   )accuracy_score)sklearn.metricsr  r  )rA   r  r   r  s       r3   scoreMinimalClassifier.score  s    2aa11r5   c           
      :    [        S[        5       S S [        SS9S9$ )N
classifierTrequiredestimator_typeclassifier_tagsregressor_tagstransformer_tagstarget_tags)r   r   r   r^   s    r3   __sklearn_tags__"MinimalClassifier.__sklearn_tags__  s&    '*,!"D1
 	
r5   )r  r  r   r   T)r-   re   rf   rg   rh   rB   r   r   r  r  r  r  r$  ri   rj   r5   r3   r  r    s/    %
%
2

r5   r  c                   J    \ rS rSrSrSS jrSS jrS rS rS r	S	 r
S
 rSrg)MinimalRegressori  zMinimal regressor implementation without inheriting from BaseEstimator.

This estimator should be tested with:

* `check_estimator` in `test_estimator_checks.py`;
* within a `Pipeline` in `test_pipeline.py`;
* within a `SearchCV` in `test_search.py`.
Nc                     Xl         g r   r  r  s     r3   rB   MinimalRegressor.__init__  r  r5   c                     SU R                   0$ r  r  r  s     r3   r   MinimalRegressor.get_params  r  r5   c                 P    UR                  5        H  u  p#[        XU5        M     U $ r   r  r  s       r3   r   MinimalRegressor.set_params  r  r5   c                 d    [        X5      u  pSU l        [        R                  " U5      U l        U $ NT)r"   
is_fitted_rs   mean_meanrA   r  r   s      r3   r  MinimalRegressor.fit  s(    WWQZ
r5   c                     [        U 5        [        U5      n[        R                  " UR                  S   4S9U R
                  -  $ )Nr   )r  )r!   r    rs   onesr  r3  )rA   r  s     r3   r  MinimalRegressor.predict  s5    Nwwaggaj]+djj88r5   c                 <    SSK Jn  U" X R                  U5      5      $ )Nr   )r2_score)r  r:  r  )rA   r  r   r:  s       r3   r  MinimalRegressor.score  s    ,<<?++r5   c           
      :    [        SS [        5       S [        SS9S9$ )N	regressorTr  r  )r   r   r   r^   s    r3   r$  !MinimalRegressor.__sklearn_tags__  s%    & (?!"D1
 	
r5   )r3  r1  r   r   r&  )r-   re   rf   rg   rh   rB   r   r   r  r  r  r$  ri   rj   r5   r3   r(  r(    s*    %
9
,

r5   r(  c                   V    \ rS rSrSrSS jrSS jrS rSS jrSS jr	SS	 jr
S
 rSrg)MinimalTransformeri  zMinimal transformer implementation without inheriting from
BaseEstimator.

This estimator should be tested with:

* `check_estimator` in `test_estimator_checks.py`;
* within a `Pipeline` in `test_pipeline.py`;
* within a `SearchCV` in `test_search.py`.
Nc                     Xl         g r   r  r  s     r3   rB   MinimalTransformer.__init__  r  r5   c                     SU R                   0$ r  r  r  s     r3   r   MinimalTransformer.get_params  r  r5   c                 P    UR                  5        H  u  p#[        XU5        M     U $ r   r  r  s       r3   r   MinimalTransformer.set_params  r  r5   c                 *    [        U5        SU l        U $ r0  )r    r1  r4  s      r3   r  MinimalTransformer.fit  s    Ar5   c                 2    [        U 5        [        U5      nU$ r   )r!   r    r4  s      r3   	transformMinimalTransformer.transform  s    Nr5   c                 B    U R                  X5      R                  X5      $ r   )r  rJ  r4  s      r3   fit_transform MinimalTransformer.fit_transform  s    xx~''--r5   c           
      :    [        SS S [        5       [        SS9S9$ )NtransformerFr  r  )r   r   r   r^   s    r3   r$  #MinimalTransformer.__sklearn_tags__  s&    ( ,."E2
 	
r5   )r1  r   r   r&  )r-   re   rf   rg   rh   rB   r   r   r  rJ  rM  r$  ri   rj   r5   r3   r@  r@    s*    %


.
r5   r@  c                     [         R                  " U 5      n[
        R                  R                  S5      c  [	        S5      eSSKJ	n  U" UR                  S5      5      nU S:X  a:  US:X  a4  UR                  R                  R                  5       (       d  [	        S	5      eU S:X  ab  US
:X  a\  [
        R                  " S5      S:w  a  [	        S5      eUR                  R                  R                  5       (       d  [	        S5      e U$ U S:X  a7  SS KnUR                  R"                  R%                  5       S:X  a  [	        S5      eU$ ! [        [        4 a    [	        U  S35      ef = f)Nz/ is not installed: not checking array_api inputSCIPY_ARRAY_APIz8SCIPY_ARRAY_API is not set: not checking array_api inputr   )get_namespacer:  torchcudaz2PyTorch test requires cuda, which is not availablempsPYTORCH_ENABLE_MPS_FALLBACK1zHSkipping MPS device test because PYTORCH_ENABLE_MPS_FALLBACK is not set.zXMPS is not available because the current PyTorch install was not built with MPS enabled.cupyz/CuPy test requires cuda, which is not available)	importlibimport_moduleModuleNotFoundErrorr   r#   r   r   r   "sklearn.externals.array_api_compatrT  r  backendsrV  is_builtgetenvrW  rZ  runtimegetDeviceCount)array_namespacedevice	array_modrT  xprZ  s         r3   _array_api_for_testsrh    s\   
++O<	 
zz~~'(0QRR@ 
y((+	,B7"f  ))++KLL	G	#%9923s:   {{''))*  * I 
F	"99++-2LMMIO  - 
NO
 	

s   E E&c                  D   [          " S S5      5       n U " S[        S9U " S[        S9U " S[        S9U " SS[        S9U " SS[        S9U " SS	[        S9U " SS
[        S9U " SS[        S9U " SS[        S9U " SS[        S9U " SS[        S9U " SS[        S9U " SS[        S9/$ )Nc                   H    \ rS rSr% S\S'   Sr\\S'   \r\	\   \S'   S r
Srg	)
4_get_warnings_filters_info_list.<locals>.WarningInfoiK  zwarnings._ActionKindactionrk   r  r(   c                     U R                   R                  S:X  a  U R                   R                  nO/U R                   R                   SU R                   R                   3nU R                   SU R                   SU 3$ )Nbuiltinsr   r   )r(   re   r-   rl  r  r@   s     r3   to_filterwarning_strI_get_warnings_filters_info_list.<locals>.WarningInfo.to_filterwarning_strQ  sh    }}'':5==11"mm667q9O9O8PQkk]!DLL>8*==r5   rj   N)r-   re   rf   rg   __annotations__r  r  r,   r(   r*   ro  ri   rj   r5   r3   WarningInfork  K  s%    &&")$w-)	>r5   rr  r   r'   rF   z%pkg_resources is deprecated as an APIr  r(   z!Deprecated call to `pkg_resourceszQThe --rsyncdir command line argument and rsyncdirs config variable are deprecatedz,\s*Pyarrow will become a required dependencyz"datetime.datetime.utcfromtimestampzast.Num is deprecatedzAttribute n is deprecatedzast.Str is deprecatedzAttribute s is deprecatedz0.+scattermapbox.+deprecated.+scattermap.+instead)r   DeprecationWarningFutureWarningr   )rr  s    r3   _get_warnings_filters_info_listrv  J  s
   > > > 	G&89Gm4G&?@ 	;'	

 	7'	
 	 (	
 	C'	
 	8'	
 	5@R	
 	9DV	
 	5@R	
 	9DV	
 	F'	
}C Cr5   c                  b    [        5       n U  Vs/ s H  nUR                  5       PM     sn$ s  snf r   )rv  ro  )warning_filters_info_listwarning_infos     r3   get_pytest_filterwarning_linesrz    s;     ? A 65L 	))+5  s   ,c                      [        5       n U  H7  n[        R                  " UR                  UR                  UR
                  S9  M9     g )Nrs  )rv  r9   filterwarningsrl  r  r(   )warnings_filters_info_listry  s     r3   turn_warnings_into_errorsr~    s>    !@!B2 ((!**	
 3r5   )Ng        Trk   T)rm   g&.>rk   )r   )F)r   F)NN)r  <   )NNNN)NFN)urh   r   
contextlibr   r[  r   r   os.pathr   r   r>  r   r;   r   r@  unittestr9   collectionsr   r   collections.abcr   dataclassesr   r
  r   r	   r
   	itertoolsr   r   
subprocessr   r   r   r   r   numpyrs   scipyr~   numpy.testingr   rx   r   r   r   r   r  sklearn.utilsr   r   r   r   r   sklearn.utils._array_apir   sklearn.utils.fixesr   r   r   sklearn.utils.multiclassr   sklearn.utils.validationr    r!   r"   __all__caser#   r,   r4   r1   r   r   r   ARRAY_API_COMPAT_FUNCTIONALr   rY   r  markskipifskip_if_32bitxfailfails_if_unstable_openblasparallelmpskip_if_no_parallel'skip_if_array_api_compat_not_configuredplatform!if_safe_multiprocessing_with_blasskip_if_no_numpydocr   r   r   r   r   r   r  r"  r$  r6  r  rN  rx  r$   r  r  AbstractContextManagerr  r  r(  r@  rh  rv  rz  r~  rj   r5   r3   <module>r     s   
      	  	  
     / $ !     $ O O    ?    ? 
 B  ==!! w )2X6 6t OSFR'
T8 (d#"&+	KK&&y9U&VM!'!2!2+-< "3 " !++,,OO'A -  /5kk.@.@''M /A /+0 )/(:(: )T ); )% !++,,N< - H
P) ),,44Pf
!R J
^ J
Z;B 
"i?X%@P*j// *Z5
 5
p,
 ,
^*
 *
Z*ZRj
S# 	\" ("'(Z  		s%   
J	 CJ 	
JJJ#"J#