
    {Kg[+                        d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlZd dlZd dlZd dlmZ d dlmZ d dlmZmZ d d	lmZ d d
lmZmZmZmZmZmZmZm Z m!Z!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z(m)Z)m*Z*m+Z+  e*ejX                         e*e      k  r e-dejX                   de d      e+ e*d      k\  Z.ej^                  d        Z0d Z1eeeeeeee e!e"d
Z2e.re1e2d<   ejf                  ji                   ejj                  dd      dk7  d      Z6 ej^                   ejn                  ejp                  e6      ejr                  g      d        Z:d Z; e;e      Z< e;e      Z= e;e      Z> e;e      Z? e;e      Z@ e;e      ZA e;e      ZB e;e       ZC e;e!      ZD e;e"      ZE ej^                  e1      ZFd ZG ej^                  d !      d"        ZHd# ZIej^                  d$        ZJej^                  d%        ZKy)&    N)suppress)wraps)environ)SkipTest)DoctestItem)threadpool_limits)config_context
set_config)PYTEST_MIN_VERSION)
fetch_20newsgroupsfetch_20newsgroups_vectorizedfetch_california_housingfetch_covtypefetch_kddcup99fetch_lfw_pairsfetch_lfw_peoplefetch_olivetti_faces
fetch_rcv1fetch_species_distributions)random_seed)get_pytest_filterwarning_lines)	_IS_32BITnp_base_versionparse_version
sp_versionz/Your version of pytest is too old. Got version z, you should have pytest >= z installed.z1.10c               #   V   K   t        d      5  d ddd       y# 1 sw Y   yxY ww)zEnable SLEP006 for all tests.T)enable_metadata_routingN)r	        T/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/sklearn/conftest.pyenable_slep006r!   /   s      
	5 
6	5	5s   )	)&)c                      t         r2t        j                  dd      dk(  } | st        d      	 dd l}ddlm} nddlm}  |d	      S # t
        $ r t        d      w xY w)
NSKLEARN_SKIP_NETWORK_TESTS101test is enabled when SKLEARN_SKIP_NETWORK_TESTS=0r   z#test requires pooch to be installed)faceT)gray)	scipy_datasets_require_networkr   getr   poochImportErrorscipy.datasetsr'   
scipy.misc)run_network_testsr+   r'   s      r    raccoon_face_or_skipr0   6   se    %#KK(DcJcQ NOO	B 	(#T?  	B@AA	Bs   A A)
fetch_20newsgroups_fxt!fetch_20newsgroups_vectorized_fxtfetch_california_housing_fxtfetch_covtype_fxtfetch_kddcup99_fxtfetch_lfw_pairs_fxtfetch_lfw_people_fxtfetch_olivetti_faces_fxtfetch_rcv1_fxtfetch_species_distributions_fxtraccoon_face_fxtSKLEARN_RUN_FLOAT32_TESTSr%   r$   z:Set SKLEARN_RUN_FLOAT32_TESTS=1 to run float32 dtype testsreason)marks)paramsc              #   (   K   | j                    y wN)param)requests    r    global_dtyperE   `   s     
--s   c                      t        j                  dd      dk(  t                fd       t        j                  fd      S )zAFetch dataset (download if missing and requested by environment).r#   r$   r%   c                      |d<   	  | i |S # t         $ r.}t        |      dk7  r t        j                  d       Y d }~y d }~ww xY w)Ndownload_if_missingz1Data not found and `download_if_missing` is Falser&   )OSErrorstrpytestskip)argskwargserH   fs      r    wrappedz_fetch_fixture.<locals>.wrappedi   sV    (;$%	Md%f%% 	M1vLLKKKLL	Ms    	A$AAc                       S rB   r   )rQ   s   r    <lambda>z _fetch_fixture.<locals>.<lambda>s   s    'r   )r   r*   r   rK   fixture)rP   rH   rQ   s   `@@r    _fetch_fixturerU   e   sC    !++&BCHCO
1XM M >>/**r   c                    t        j                  dd      dk(  }t        j                  j	                  d      }t        t              }t               }|D ]  }t        |t              rAd|j                  v r3|j                  j                  d      d   }| d	}t        |g      |z  }	n't        |d
      sat        |j                        }
|
|z  }	|	s~|r||	z  }|j                  |        t        j                  dd      }|dk(  r.|r,|D ]'  }t        t              5  t        |           ddd       ) |D ]g  }|j                  j!                  d      st#        j$                         dk(  s7t        j                  j'                  d      }|j                  |       i d}	 ddl}t,        rd}d}n#t.        j"                  j1                  d      rd}d}t2        t5        d      k  rd}d}t6        t5        d      k  rd}d}|D ]$  }t        |t              si |j8                  _        & |rYt        j                  j	                        }|D ]4  }t        |t              s|j                  dk7  s$|j                  |       6 	 ddl}d}|sHt        j                  j	                  d      }|D ]"  }|j                  dv s|j                  |       $ yy# 1 sw Y   xY w# t*        $ r d}d}Y Mw xY w# t*        $ r d}Y yw xY w)zCalled after collect is completed.

    Parameters
    ----------
    config : pytest config
    items : list of collected items
    r#   r$   r%   r&   r=   fetch_._fxtfixturenamesPYTEST_XDIST_WORKERgw0NGradientBoostingClassifieraarch64zKknow failure. See https://github.com/scikit-learn/scikit-learn/issues/17797Fr   Tz*matplotlib is required to run the doctestsz;doctest are only run when the default numpy int is 64 bits.win32z\doctests are not run for Windows because numpy arrays repr is inconsistent across platforms.2z6Due to NEP 51 numpy scalar repr has changed in numpy 2z1.14z2Scipy sparse matrix repr has changed in scipy 1.14zsklearn._config.config_contextzpillow (or PIL) not installed!)z/sklearn.feature_extraction.image.PatchExtractorz3sklearn.feature_extraction.image.extract_patches_2d)r   r*   rK   markrL   setdataset_fetchers
isinstancer   namesplithasattrr[   
add_markerr   r   endswithplatformmachinexfail
matplotlibr,   r   sys
startswithr   r   r   dtestglobsPIL)configitemsr/   skip_networkdataset_features_setdatasets_to_downloaditemfetcher_function_namedataset_fetchers_keydataset_to_fetchitem_fixtures	worker_idrf   markerskip_doctestsrn   r>   skip_markerrs   pillow_installeds                       r    pytest_collection_modifyitemsr      s     $@#F#M;;##B $ L /05dK(X-B$(IIOOC$8$<!&;%<D#A "$8#9:=QQ~. 1 12M,/CC $44  OOL)% . 159IE/(D(# &( $# )  II;<  "i/[[&&P ' F OOF#  M>
 N		 	 	)5 	 s++ JM&))E
 dK(!DJJ  kk&&f&5D$,
 99 @@OOK0 ! kk&&.N&ODyy   ,  M $#(  >=>^  ! !s0   K&K' 	K; K$	'K87K8;L	L	function)scopec               #      K   t        j                  d      } | j                  d       |  | j                  d       yw)a/  Setup and teardown fixture for matplotlib.

    This fixture checks if we can import matplotlib. If not, the tests will be
    skipped. Otherwise, we close the figures before and after running the
    functions.

    Returns
    -------
    pyplot : module
        The ``matplotlib.pyplot`` module.
    zmatplotlib.pyplotallN)rK   importorskipclose)pyplots    r    r   r      s6        !45F
LL
L
LLs   =?c                    	 dd l }|j                  d       t        j                  d      }t        j                  d      }|t        |t        |      z  d      }t        |       | j                  j                  d      s| j                  j                  t               t        j                  dd	      d	k7  r"t               D ]  }| j                  d
|        y y # t        $ r Y w xY w)Nr   aggT)only_physical_coresPYTEST_XDIST_WORKER_COUNT   zsklearn.tests.random_seedSKLEARN_WARNINGS_AS_ERRORSr%   filterwarnings)rn   user,   joblib	cpu_countr   r*   maxintr   pluginmanager	haspluginregisterr   r   addinivalue_line)rt   rn   allowed_parallelismxdist_worker_countlines        r    pytest_configurer     s    u !**tD %@A% ""5=O9P"PRST)* ))*EF%%k2{{/5< 34D##$4d; 5	 =  s   C 	C)(C)c                 ^    t         j                  fd}| j                  t         d|       y)z!Pretend pandas was not installed.c                 :    | dk(  r
t                | g|i |S )Npandas)r,   )rf   rM   rN   import_origs      r    mocked_importz,hide_available_pandas.<locals>.mocked_import5  s(    8-41$1&11r   
__import__N)builtinsr   setattr)monkeypatchr   r   s     @r    hide_available_pandasr   0  s)     %%K2
 ,>r   c               #   D   K   t        d       d t        d       yw)z?Set `print_changed_only` to False for the duration of the test.F)print_changed_onlyNT)r
   r   r   r    print_changed_only_falser   =  s      %(	$'s    )Lr   rk   ro   
contextlibr   	functoolsr   osr   unittestr   r   numpynprK   _pytest.doctestr   threadpoolctlr   sklearnr	   r
   sklearn._min_dependenciesr   sklearn.datasetsr   r   r   r   r   r   r   r   r   r   sklearn.testsr   sklearn.utils._testingr   sklearn.utils.fixesr   r   r   r   __version__r,   r)   rT   r!   r0   rd   rb   skipifr*   _SKIP32_MARKrC   float32float64rE   rU   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r   r   r   r   r   r   r   r    <module>r      sU     
        ' + . 8   & A  ##$}5G'HH

9&:L:L9M N""4!5[	B 
 ",}V/D!D   ( 1)F$<&(*, 4 'B  "+?'({{!!GKK+S1S8G "  RZZ|DbjjQR S+$ ((:; $23P$Q !-.FG "=1 #N3 $_5 %&67 )*>? 
+"01L"M !6>>"67 y-x j! "$<: 	? 	? ( (r   