
    -i                         S SK r S SKJr  S SKrS SKrS SKJrJrJr  S SKJ	r	  S SK
JrJr  S rS rS rS	 r\R"                  R%                  S
/ SQ5      S 5       r\R"                  R)                  \	SS9S 5       rS rg)    N)ThreadPoolExecutor)config_context
get_config
set_config)_IS_WASM)Paralleldelayedc                     [        5       SSSSSSSSSSS.
:X  d   e[        SS9  [        5       S	   SL d   e[        SS9   [        5       SSSSSSSSSSS.
:X  d   e S S S 5        [        5       S	   SL d   e[        SS9   [        S S9   [        5       S	   SL d   e S S S 5        [        5       S	   SL d   e[        SS9   [        5       S	   SL d   e[        S S9   [        5       S	   SL d   e[        SS9  [        5       S	   SL d   e S S S 5        [        5       S	   SL d   e S S S 5        [        5       S	   SL d   e S S S 5        [        5       SSSSSSSSSSS.
:X  d   e[        R                  " [
        5         [        S5        S S S 5        [        R                  " [
        5         [        SS
9R                  5         S S S 5        g ! , (       d  f       GNx= f! , (       d  f       GNI= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g = f)NFi   Tdiagram   default)
assume_finiteworking_memoryprint_changed_onlydisplayarray_api_dispatchpairwise_dist_chunk_sizeenable_cython_pairwise_disttransform_outputenable_metadata_routingskip_parameter_validationr   r   do_something_else)r   r   r   pytestraises	TypeError	__enter__     L/var/www/html/venv/lib/python3.13/site-packages/sklearn/tests/test_config.pytest_config_contextr"      sF   <"#$''+%#(%*    &<(E111	d	+|!""& "'(++/ )',). 
 
 	
 
 
, <(E111	d	+$/<0D888 0 |O,444%0<0E999d3!|O4=== .!|O4<<< 4 <0E999 1 |O,444' 
,* <"#$''+%#(%*    
y	!t 
" 
y	!.88: 
"	!m 
,	+  0/ 43 10 
,	+F 
"	! 
"	!sx    G 
H
G #HH.G2H'H?H%-H6
G 
G/	*H2
H <H
H	H
H"%
H36
Ic                      [        5       S   SL d   e [        SS9   [        5       S   SL d   e[        5       e! , (       d  f       O= f! [         a     Of = f[        5       S   SL d   eg )Nr   FTr   )r   r   
ValueErrorr   r    r!   test_config_context_exceptionr%   X   sr    <(E111$/<0D888, 0/  <(E111s&   	A :
AA A 
AAc                  z   [        5       S   SL d   e[        S S9  [        5       S   SL d   e[        SS9  [        5       S   SL d   e[        S S9  [        5       S   SL d   e[        SS9  [        5       S   SL d   e[        R                  " [        5         [        SS9  S S S 5        g ! , (       d  f       g = f)Nr   Fr   Tr   )r   r   r   r   r   r   r    r!   test_set_configr'   c   s    <(E111T"<(E111T"<(D000T"<(D000U#<(E111 
y	!T* 
"	!	!s   
B,,
B:c                     [        U S9   [        R                  " U5        [        5       S   sSSS5        $ ! , (       d  f       g= f)zAReturn the value of assume_finite after waiting `sleep_duration`.r   r   N)r   timesleepr   )r   sleep_durations     r!   set_assume_finiter,   s   s,    	m	4

>"|O, 
5	4	4s	   #7
Abackend)lokymultiprocessing	threadingc                 h    / SQn/ SQn[        U SS9" S [        X5       5       5      nU/ SQ:X  d   eg)a[  Test that the global config is threadsafe with all joblib backends.
Two jobs are spawned and sets assume_finite to two different values.
When the job with a duration 0.1s completes, the assume_finite value
should be the same as the value passed to the function. In other words,
it is not influenced by the other job setting assume_finite to True.
FTFT皙?皙?r4   r5      )r-   n_jobsc              3   P   #    U  H  u  p[        [        5      " X5      v   M     g 7f)N)r	   r,   ).0r   	sleep_durs      r!   	<genexpr>0test_config_threadsafe_joblib.<locals>.<genexpr>   s(      0(L$M 	!"=<<(Ls   $&N)r   zip)r-   assume_finitessleep_durationsitemss       r!   test_config_threadsafe_joblibrA   z   sB     0N*OWQ/ 0(+N(L0 E
 ....r    zcannot start threads)reasonc                      / SQn / SQn[        SS9 nUR                  [        X5       Vs/ s H  nUPM     nnSSS5        W/ SQ:X  d   egs  snf ! , (       d  f       N= f)zUses threads directly to test that the global config does not change
between threads. Same test as `test_config_threadsafe_joblib` but with
`ThreadPoolExecutor`.r2   r3   r6   )max_workersN)r   mapr,   )r>   r?   eoutputr@   s        r!   test_config_threadsaferH      sj     0N*O		*a %% 1>S
S S 	 
 
+ ....
 
+	*s   AAAA
Ac                    U R                  [        R                  R                  R                  SS5        [
        R                  " [        SS9   [        SS9    SSS5        SSS5        [
        R                  " [        SS9   [        SS9  SSS5        g! , (       d  f       NB= f! , (       d  f       NK= f! , (       d  f       g= f)z!Check error when SciPy is too old__version__z1.13.0zSciPy must be 1.14.0 or newer)matchT)r   N)
setattrsklearnutils
_array_apiscipyr   r   ImportErrorr   r   )monkeypatchs    r!   *test_config_array_api_dispatch_error_scipyrS      s    0066xP	{*I	Jt4 5 
K 
{*I	Jd+ 
K	J 54 
K	J 
K	Js0   
B(BB(
B9
B%	!B((
B69
C)r)   concurrent.futuresr   r   rM   r   r   r   sklearn.utils.fixesr   sklearn.utils.parallelr   r	   r"   r%   r'   r,   markparametrizerA   xfailrH   rS   r   r    r!   <module>rZ      s     1   : : ( 4I;X2+ - $LM/ N/$ 8$:;/ </"	,r    