`L i :dZddlZddlZddlZddlZddlZddlZddlmZ ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZmZddlmZddlmZddlmZddlmZddlmZdd lmZmZdd lm Z m!Z!m"Z"m#Z#ddl$Z$ddl%Z&ddl'Z(dd l)m*Z+dd l)m,Z,m-Z-m.Z.m/Z/ddl0Z0dd l1m2Z2m3Z3m4Z4m5Z5m6Z6ddl7m8Z8ddl9m:Z:m;Z;mZ>ddl?m@Z@mAZAmBZBgdZCejjZEdeFfdZGGddZH dAdZ*dBdZIdCdZJdZK e8ddZL ddlOZOeOjje:dZReOjje<dZTeOjje$jj d ZWeOjjeL d!ZXeOjje jd"k(d#ZZeOjjeK d$Z[d%Z\dDd&Z]Gd'd(Z^dEd)Z_dDd*Z`d+ZadFd,Zbd-Zcd.Zdd/Zedeffd0Zgdddddddeffd1ZhdGd2Zi dHd3ZjdId4ZkGd5d6ejZmGd7d8ZnGd9d:ZoGd;d<Zpd=Zqd>Zrd?Zsd@Zty#eMeNf$rdZLYwxYw#eM$rYwxYw)JzTesting utilities.N) defaultdict namedtuple)Iterable) dataclass) context_diffwraps) signature)chaingroupby)STDOUTCalledProcessErrorTimeoutExpired check_output)assert_allclose)assert_almost_equalassert_array_almost_equalassert_array_equalassert_array_less)ClassifierTags RegressorTagsTags TargetTagsTransformerTags)_check_array_api_dispatch) _IS_32BITVisibleDeprecationWarning#_in_unstable_openblas_configuration)check_classification_targets) check_arraycheck_is_fitted check_X_y)SkipTestrrrrr'assert_run_python_script_without_outputct|tr7t|tr'|j}t dj |t|rt||St|S)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_namecategory) isinstancetype issubclassWarning__name__ ValueErrorformatcallable_IgnoreWarnings)objr(r&s \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/utils/_testing.pyignore_warningsr4Jsh8#tC!9||  78>v.wrappersE((* +%%h >4*6* + + +s (AAr)r@rIrJs`` r3__call__z_IgnoreWarnings.__call__s" r +  + r5cg}|jr|jd|jtjdur|jd|jzt |j }|ddj|dS)Nz record=Truer8z module=%r(z, ))r9appendr<r:r;r*r-join)r@rGnames r3__repr__z_IgnoreWarnings.__repr__sf << KK & < >  ,, #}}Q/  LL44h 6r5c|jstd|z|j|j_|j |j_g|jddy)Nz%Cannot exit %r without entering first)r=rTrVr<rUrXrWr>)r@exc_infos r3__exit__z_IgnoreWarnings.__exit__sI}}FMN N#}} #'#4#4   r5N) r- __module__ __qualname____doc__rArKrRrZr]r5r3r1r1vs  ! 27r5r1Tc g}tj|tj|}}|j|jg}|/|Dcgc]}|tjk(rdnd} }t | }t |||||||ycc}w)audtype-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-C6?Hz>)rtolatol equal_nanerr_msgverbose)np asanyarraydtypefloat32maxnp_assert_allclose) actualdesiredrerfrgrhridtypesrlrtolss r3rrsjFmmF+R]]7-CGFllGMM *F |DJK5"**,$6KK5z  Ls B ctjj|rtjj|r|j}|j}|j |j t |j |j |t |j|j|t|j|j|||ytjj|s0tjj|st|||||ytd)aAssert 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. )rh)rerfrhzGCan only compare two sparse matrices, not a sparse matrix and an array.N) spsparseissparsetocsrsum_duplicatesrindicesindptrrdatar.)xyrerfrhs r3assert_allclose_dense_sparsers2 yy!!3!3A!6 GGI GGI  199aiiA188QXXw?TgN YY   "299+=+=a+@14dGD U  r5cNd|jvr|j|yy)a~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)rN) get_params set_params) estimatorrs r3set_random_stater"s+--//,70r5c8 ddl}y#ttf$rYywxYw)NrTF)numpydoc ImportErrorAssertionError)rs r3 _is_numpydocr2s(  (s Fzskipped on 32bit platforms)reasonz+OpenBLAS is unstable for this configurationzjoblib is in serial modez>6 :;FGG>+ & MM+ & ' P  MM@;N O Ps48#A A c$eZdZdZddZdZdZy) TempMemmapzM Parameters ---------- data mmap_mode : str, default='r' c ||_||_yN) mmap_moder|)r@r|rs r3rAzTempMemmap.__init__s" r5cZt|j|jd\}|_|S)NT)r return_folder)create_memmap_backed_datar|r temp_folder)r@data_read_onlys r3rZzTempMemmap.__enter__s++D IIt, ((r5c.t|jyr)rr)r@exc_typeexc_valexc_tbs r3r]zTempMemmap.__exit__st''(r5N)r)r-r^r_r`rArZr]rar5r3rrs )r5rc*tjd}tjt j t |dtj|d}tj||tj||}|s|}|S||f}|S)zv Parameters ---------- data mmap_mode : str, default='r' return_folder : bool, default=False sklearn_testing_)prefixT)rzdata.pkl)r) tempfilemkdtempatexitregister functoolspartialroprPjoblibdumpload)r|rrrfilenamememmap_backed_dataresults r3rrs""*<=K OOI%%nkMNww{J/H KKhXC"/  M7I+5V  Mr5c t|j}|jDcgc]+\}}|j|j |j fvr|-}}}|rT|jDcgc]'}|j|j k(r |j)}}t|dk(rd}||fS|S#t$rgcYSwxYwcc}}wcc}w)z!Helper to get function arguments.rN) r parametersr.itemskindVAR_POSITIONAL VAR_KEYWORDvaluesrQlen)functionvarargsparamskeyparamrGs r3 _get_argsrs8$// !,,.  C ::e22E4E4EF F  D    zzU111 JJ  w<1 GW} %     sB50C1,C 5 CCc>g}tj|}|r|j|j|j}||jk7r#|j|d|j d|j|jdj |S)zGet function full name. Parameters ---------- func : callable The function object. Returns ------- name : str The function name. N.)inspect getmodulerOr-r_findrP)funcpartsmodulequalnames r3_get_func_namers~ E   t $F  V__%  H4==  X2 c 234 LL 88E?r5c Rddlm}g}gnt|}|jdr|jdr|St j |r|S|j dddvr|S|j dd d k(r|Sttfd t|}t|dkDr|dd k(r|jd |lg}tjd 5tjdt |j!|}dddt|rt)d|d|dg} |dD]\} } } | j+sod| vr2| d| j-dddj+r ||d| zzgz }n9| j/j1dr||d| j3zzgz }d| vs| j%| j ddj+dt|dkDr|Sttfd| } g} t5t7t| t|D]$}||| |k7s| d|d||d | |gz } nt|t| kDr| d!|t| zgz } n,t|t| kr| d"| t|zgz } t| dk(rgSddl}ddl}|j=| j?}|j=|j?}| d#gz } | jAd$|jC||D|jA| d|zg|z}|S#t$rk}dt#|vr9t#|j ddd} |d|g| zz }|cYd}~cdddS|j%t#|Yd}~d}~wt&$r*}||dzt#|zgz }|cYd}~cdddSd}~wwxYw#1swYxYw)%arHelper 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) docscrapeNzsklearn.zsklearn.externalsr) setup_moduleteardown_moduleestimator_checksc |vSrrar}rDs r3z,check_docstring_parameters..s AVOr5r@T)recorderrorz"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 |vSrrars r3rz,check_docstring_parameters..>s qr5z\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:c3<K|]}|jywr)strip.0lines r3 z-check_docstring_parameters..is  )"rrr startswithrisdatadescriptorsplitlistfilterrrremover8rErF UserWarning FunctionDocstrrO ExceptionrTrindexrstripendswithlstriprangemindifflibpprintpformat splitlinesextendndiff)rdocrDr incorrect func_nameparam_signaturerecordsexpmessage param_docsrQtype_definition param_docirrparam_docs_formattedparam_signature_formatteds ` r3check_docstring_parametersrsz"#I>RvFt$I    +y/C/C0%sB#FFsA"446";Yt_MNO ?aOA$6&$@v& {  $ $D 1 !  ! !'; 7 !++D1 ! w<iLM MJ,/ ,=>(oy$$&d{t$5djjo6rs;AACQTXXY '',N{{}&&  d?   djjoa066t< =%>, 9~f6 CDJ G 3s:O(<= > 1 A . &'(:JqMK G  ?c*o- :c*o. /   _ J / 8_-. /   7|q !>>*5@@B & ? J J L ~G NNMM";=QR W!9,- 9I  )73s8C"#hnnT22A6GM)"=!>!HHI$$ ! !s3x(( !i*<.s3ODH3Osz ) rrrrrrrPr r)docstrings_groupedmsg_diffref_str ref_group docstringgroupdiffstarts r3 _get_diff_msgr(sHGI.446 5y y G   U #  !Y5z    BGGT"1X''#DH)< PLE5}D499U#333D5L3883O3O+OOO  P F-. Or5c g}|jD]R\}}t|jD cgc] } t| c} |kr|j |L|dk(rw|rug} |jD]-\} } t j || r| j| /| stjd|ddd|d| d|d } t| |d k(r||vrt|jd kDst|}d jd |jD}tjd |d|ddd|d|d } | |z } t| |rtjd|d|dyycc} w)aHelper 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". descriptionzThe description of Nrz 'z' in z' does not match 'descr_regex_pattern': rtype specificationz and c32K|]}t|ywr)r)rr%s r3rz+_check_consistency_items..s&$E &szThe z of z' is inconsistent between rzChecking was skipped for z: z' as they were not found in all objects.)rsumrrrOresearchrtextwrapfillrkeysr(rPr8r) items_docs type_or_descsection n_objectsdescr_regex_pattern ignore_typesskippedrr objs not_matchedr$r%msgr! obj_groupss r3_check_consistency_itemsr?sLG)3)9)9);&% % &8&?&?&ABdD B Ci O NN9 % ] */BK$6$<$<$> . 5yy!4i@&&u- .mm)'#2,r)E+=>Q=RRSU%S)) 1 1i<6O  #((* +a /$%78H &(:(A(A(C&J--|nD"b D%,a)C 8OC % %=&> 'y7)<( ( ;CsF c ddlm} tdgdfd} i| ||dd| ||dd | ||d d } t} |D]} t j | s*t j | st j| r)| t j| | | j<ktd t| d t|}| jD]\}}td}td}| jD]\}}||D]\}}}t||sdj!|j#j%}dj!t'j(d|D}|||j+||||j+|t-|d|||t-|d|||y)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)NumpyDocStringrG)rrarg_namecX|r|durtd|d|d|duriS||||iS)NTz The 'exclude_z-' argument can be set only when the 'include_z' argument is True.F) TypeError)rrrB section_nameArgss r3 _create_argsz2assert_docstring_consistency.._create_argsNsV wd*z*$:%8:  e Id7GX>??r5rrattrs AttributesreturnsReturnszDAll 'objects' must be one of: function, class or descriptor, got a: rc ttSrrrrar5r3rz.assert_docstring_consistency..n T):r5c ttSrrMrar5r3rz.assert_docstring_consistency..orNr5rc3<K|]}|jywr)rrs r3rz/assert_docstring_consistency..us7V 7Vrr+)r9r*)r8N)numpydoc.docscraperArdictrr isfunctionisclassgetdocr-rDr*rrrrrPrrr from_iterablerOr?)objectsinclude_paramsexclude_params include_attrs exclude_attrsinclude_returnsexclude_returnsr8r9rArG section_args objects_docr2r7r6rG type_items desc_itemsobj_nameobj_docrtype_defdescrFs @r3assert_docstring_consistencyrfsZ2 f@ AD@ ~~x N }mWl K I NL &K   $ $S )!!#&s#(6w~~c7J(KK %s)A'  G I%++-  !:;  !:; !,!2!2!4 A Hg-4W-= A) 8T' 48"xx(8(>(>(@AH88E$7$77VQU7V$VWDy)(3::8Dy)$/66x@ A A !   %   !     3  ) r5ctjd\}}tj| t |d5}|j |j ddddtj|g}tjtjtjtjd}tjj!} tj"j||dg|d<|t&|d} tjj)d } | r| | d d <|| d < t+|fi| } | j3d} t5j6|| r|d k(rd} nd|} | d| }t9| tj<|y#1swYOxYw#t$$r||d<YwxYw#t,$r,} t/d | j0j3dzd} ~ wwxYw#t:$r,} t/d| j0j3dzd} ~ wwxYw#tj<|wxYw)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)suffixwbzutf-8Nz.. PYTHONPATH)cwdstderrenvCOVERAGE_PROCESS_STARTrmtimeoutzscript errored with output: %s.+zExpected no outputz%The output was not supposed to match z$, got the following output instead: z!script timeout, output so far: %s)rmkstemprcloseopenwriteencoder: executablernormpathrPdirnamesklearn__file__rcopypathsepKeyErrorr rrrrToutputdecoder/r0rrunlink) source_codepatternrofd source_filefcmdrkrmrH coverage_rcoute expectationr s r3r$r$s$&&.DEOB HHRL' +t $ 1 GGK&&w/ 0 1~~{+kk"''"**W-=-=">EFjjoo $ " c,6G0H IC s;jjnn%=> 6AF5M2 3#y  "31&1 **W%Cyy#&d?"6K$I'"UK(M)McWU$W--' +M 1 1 $ #C  $& "58PP  4qxxw7OO   +s H;!F*BH; 'F78H; G AH*F4/H;7GH;GH; H'G;;HH H8 'H33H88H;;Ic$|dk(r2| t|Stj||jS|dk(r;| t |St tj||jS|dk(rtj||S|dvrNt j d|}|j|||d }||D]}||jd ||<|S|d k(rt j d |} tj|} | jd k(r | dddfn| } |(t| jd D cgc]} d|  }} t|D cic]\} } | | dd| f} } } | jj| }|Rt|jD]:\}}||vs |j!|||j#|j%}<|S|dk(rot j d|}|j||d}|@|D];}|j'|j)|j+|j,}=|S|dk(r*t j d|}|j/||S|dk(r(t j d |} | j1|S|dk(r)t j d|}|j/|S|dk(r*t j d|}|j3||S|dk(rt5|d|d Sd|vrt6j8j;|stj<|}|dvr!t6j8j?||S|dk(r!t6j8jA||S|dk(r!t6j8jC||S|dk(r!t6j8jE||Syycc} wcc} } w)aConvert 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 rN)rltuplearray)pandas dataframer) minversionF)columnsrlr{r(pyarrowr,colpolarsrow)schemaorientseries pyarrow_array polars_series)rrslicerrv)rv sparse_csrsparse_csr_array sparse_cscsparse_csc_array)#rrjasarraytolistrpytest importorskip DataFrameastypendimrshape enumerateTable from_pydict column_names set_columncolumndictionary_encode with_columnsrcast CategoricalSeriesrIndexrrurvrw atleast_2d csr_matrix csr_array csc_matrix csc_array) containerconstructor_name columns_namerlrcategorical_feature_namespdrcol_nameparr rQr|col_idxpls r3_convert_containerrsD6! = ? "::iu5<<> > W $ =# #IU;BBDE E W $zz)511 4 4  j AiUQVW $ 05 G#)(#3#:#::#Fx  G Y &  z B 9%"'**/agu  /4U[[^/DE!c!IELE1:<1HIgaeAqDk!II%%d+ $ 0%.v/B/B%C !88#..6==+B+T+T+VF   X %  j Ai UK $ 05 T,,RVVH-=-B-B2>>-RS T X %  j Ayy%y00 _ ,  z Bxx "" _ ,  j Ayy y** W $  j Axx x// W $Yq\9Q<00 % %yy!!),  i0I 7 799'' '? ? !3 399&&y&> >  -99'' '? ? !3 399&&y&> >4 &?FIs  P*P ct||||S)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_typematchmay_passrhs r3raisesr4sJ $eXw ??r5ceZdZdZdZy)rct|tr|n|g|_t|tr|gn||_||_||_d|_y)NF)r)rexpected_exc_typesrmatchesrrhraised_and_matched)r@rrrrhs r3rAz_Raises.__init__^sN+X6 #$  #-UC"8we    "'r5c5|jry|jxsd|j}t|t fd|jDs#|jt|jy|j s|jxs4dj dj|j t}t fd|j Ds t|d|_ y)NTzDid not raise: c36K|]}t|ywr)r+)r expected_typers r3rz#_Raises.__exit__..ts   x / sFzIThe error message should contain one of the following patterns: {} Got {}rc3\K|]#}tj|t%ywr)r/r0r)rr exc_values r3rz#_Raises.__exit__..s REryyI7Rs),) rrhrranyrr/rPrr)r@rr_rhs `` r3r]z_Raises.__exit__is  }},,UODddlm}|||j|S)Nr)accuracy_score)sklearn.metricsrr)r@rr~rs r3scorezMinimalClassifier.scores2aa11r5c FtdtddtdS)N classifierTrequiredestimator_typeclassifier_tagsregressor_tagstransformer_tags target_tags)rrrrYs r3__sklearn_tags__z"MinimalClassifier.__sklearn_tags__s&'*,!"D1   r5rT) r-r^r_r`rArrrrrrrrar5r3rrs/% % 2  r5rc>eZdZdZd dZd dZdZdZdZdZ d Z y) MinimalRegressoraMinimal 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||_yrrrs r3rAzMinimalRegressor.__init__rr5cd|jiSrrrs r3rzMinimalRegressor.get_paramsrr5c P|jD]\}}t||||Srrrs r3rzMinimalRegressor.set_paramsrr5cft||\}}d|_tj||_|SNT)r" is_fitted_rjmean_meanr@rr~s r3rzMinimalRegressor.fits,A1WWQZ  r5ct|t|}tj|jdf|j zS)Nr)r)r!r rjonesrr)r@rs r3rzMinimalRegressor.predicts5 Nwwaggaj]+djj88r5c>ddlm}|||j|S)Nr)r2_score)rrr)r@rr~rs r3rzMinimalRegressor.scores,4<<?++r5c FtddtdtdS)N regressorTrr)rrrrYs r3rz!MinimalRegressor.__sklearn_tags__s%& (?!"D1   r5rr ) r-r^r_r`rArrrrrrrar5r3r r s*%  9 ,  r5r cDeZdZdZd dZd dZdZd dZd dZd dZ d Z y) MinimalTransformeraMinimal 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||_yrrrs r3rAzMinimalTransformer.__init__rr5cd|jiSrrrs r3rzMinimalTransformer.get_paramsrr5c P|jD]\}}t||||Srrrs r3rzMinimalTransformer.set_paramsrr5c*t|d|_|Sr)r rrs r3rzMinimalTransformer.fitsA r5c2t|t|}|Sr)r!r rs r3 transformzMinimalTransformer.transform s Nr5cF|j||j||Sr)rr"rs r3 fit_transformz MinimalTransformer.fit_transformsxx1~''1--r5c FtdddttdS)N transformerFrr)rrrrYs r3rz#MinimalTransformer.__sklearn_tags__s&( ,."E2   r5rr ) r-r^r_r`rArrrr"r$rrar5r3rrs*%   . r5rc tj|}t j jd t dddlm }||jd}|dk(r4|dk(r/|jjjs t d |dk(rY|d k(rTt jd d k7r t d |jjjs t d|S|dk(r6ddl}|jj"j%dk(r t d|S#ttf$rt |dwxYw)Nz/ is not installed: not checking array_api inputSCIPY_ARRAY_APIz8SCIPY_ARRAY_API is not set: not checking array_api inputr) get_namespacer,torchcudaz2PyTorch test requires cuda, which is not availablempsPYTORCH_ENABLE_MPS_FALLBACK1zHSkipping 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_moduleModuleNotFoundErrorrr#rrr"sklearn.externals.array_api_compatr)rbackendsr+is_builtgetenvr,r/runtimegetDeviceCount)array_namespacedevice array_modr)xpr/s r3_array_api_for_testsr=sQ ++O<  zz~~'(0QRR@ y((+ ,B7" f    ))+KLL G #% 992 3s : {{'')*  I F " 99   + + - 2LM M IO  - N O   s D22EctGdd}|dt|dt|dt|ddt|ddt|dd t|dd t|dd t|dd t|dd t|ddt|ddt|ddtg S)Nc@eZdZUded<dZeed<eZeeed<dZ y)4_get_warnings_filters_info_list..WarningInfozwarnings._ActionKindactionrbr r(c|jjdk(r|jj}n/|jjd|jj}|jd|jd|S)Nbuiltinsrr)r(r^r-rAr r?s r3to_filterwarning_strzI_get_warnings_filters_info_list..WarningInfo.to_filterwarning_strQsh}}'':5==11"mm667q9O9O8PQkk]!DLL>8*= =r5N) r-r^r___annotations__r rr,r(r*rDrar5r3 WarningInfor@Ks%&&")$w-) >r5rFrr'rDz%pkg_resources is deprecated as an APIr 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.utcfromtimestampzast.Num is deprecatedzAttribute n is deprecatedzast.Str is deprecatedzAttribute s is deprecatedz0.+scattermapbox.+deprecated.+scattermap.+instead)rDeprecationWarning FutureWarningr)rFs r3_get_warnings_filters_info_listrJJs  > > > G&89Gm4G&?@  ;'  7'   (    C'   8'   5@R   9DV  5@R   9DV  F' }C Cr5c\t}|Dcgc]}|jc}Scc}wr)rJrD)warning_filters_info_list warning_infos r3get_pytest_filterwarning_linesrNs6 ? A6   ))+  s)ct}|D]8}tj|j|j|j :y)NrG)rJr8filterwarningsrAr r()warnings_filters_info_listrMs r3turn_warnings_into_errorsrRsC!@!B2     ((!**  r5)NgTrbT)rdg& .>rb)r)F)rF)NN)rp<)NNNN)NFN)ur`r contextlibrr0rros.pathrrr/rr:rr1unittestr8 collectionsrrcollections.abcr dataclassesrrrr r itertoolsr r subprocessr rrrrnumpyrjscipyru numpy.testingrrorrrrry sklearn.utilsrrrrrsklearn.utils._array_apirsklearn.utils.fixesrrrsklearn.utils.multiclassrsklearn.utils.validationr r!r"__all__caser#r,r4r1rrrARRAY_API_COMPAT_FUNCTIONALrrTrmarkskipif skip_if_32bitxfailfails_if_unstable_openblasparallelmpskip_if_no_parallel'skip_if_array_api_compat_not_configuredplatform!if_safe_multiprocessing_with_blasskip_if_no_numpydocrrrrrrrrrr(rr?rfr$rrAbstractContextManagerrrr rr=rJrNrRrar5r3rts   /$! $OO ?? B   == ! !w)2X66tOSFR' T 8 (d#"&+ KK&&y9U&VM!'!2!2+-<"3"!++,, OO  'A-/5kk.@.@ ''M/A/+0)/ (:(:  )T);)%!++,, N<-H P)),,44Pf !R J ^J Z;B " i?X%@P*j//*Z5 5 p, , ^* * Z*ZRj S# \"("'(Z  s% J C J JJJJ