
    rh                        d dl Z d dlmZ d dlZd dlZd dlmZmZmZ d dlm	Z	 d dl
mZmZ d Zd Zd Zd	 Zej"                  j%                  d
g d      d        Zej"                  j)                  e	d      d        Zd Zy)    N)ThreadPoolExecutor)config_context
get_config
set_config)_IS_WASM)Paralleldelayedc                  \   t               ddddddddddd
k(  sJ t        d       t               d	   du sJ t        d      5  t               ddddddddddd
k(  sJ 	 d d d        t               d	   du sJ t        d      5  t        d       5  t               d	   du sJ 	 d d d        t               d	   du sJ t        d      5  t               d	   du sJ t        d       5  t               d	   du sJ t        d       t               d	   du sJ 	 d d d        t               d	   du sJ 	 d d d        t               d	   du sJ 	 d d d        t               ddddddddddd
k(  sJ t        j                  t
              5  t        d       d d d        t        j                  t
              5  t        d
      j                          d d d        y # 1 sw Y   zxY w# 1 sw Y   BxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)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/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/sklearn/tests/test_config.pytest_config_contextr"      sy   <"#$''+%#(%*    &<(E111	d	+ 
|!""& "'(++/ )',). 
 
 	
 

 <(E111	d	+ 5$/ 	9<0D888	9 |O,444%0 	:<0E999d3 =!|O4=== .!|O4<<<= <0E999	: |O,444'5* <"#$''+%#(%*    
y	! t 
y	! ;.88:; ;m
 
 	9 	9= =	: 	:5 5F ; ;sx   GH
G%%%H

G>(/G2G>2H
H4H"G"%G/	*H
2G;7G>>H	H

HH"H+c                      t               d   du sJ 	 t        d      5  t               d   du sJ t               # 1 sw Y   nxY wn# t        $ r Y nw xY wt               d   du sJ y )Nr   FTr   )r   r   
ValueErrorr   r    r!   test_config_context_exceptionr%   X   s    <(E111$/ 	<0D888,	 	 	  <(E111s    A ;A A 	AAc                     t               d   du sJ t        d        t               d   du sJ t        d       t               d   du sJ t        d        t               d   du sJ t        d       t               d   du sJ t        j                  t              5  t        d       d d d        y # 1 sw Y   y xY w)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   B55B>c                     t        |       5  t        j                  |       t               d   cddd       S # 1 sw Y   yxY w)zAReturn the value of assume_finite after waiting `sleep_duration`.r   r   N)r   timesleepr   )r   sleep_durations     r!   set_assume_finiter,   s   s5    	m	4 -

>"|O,- - -s	   "9Abackend)lokymultiprocessing	threadingc                 n    g d}g d} t        | d      d t        ||      D              }|g dk(  sJ y)ao  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   N   K   | ]  \  }} t        t              ||        y w)N)r	   r,   ).0r   	sleep_durs      r!   	<genexpr>z0test_config_threadsafe_joblib.<locals>.<genexpr>   s+      0$M9 	#!"=)<0s   #%N)r   zip)r-   assume_finitessleep_durationsitemss       r!   test_config_threadsafe_joblibr@   z   sF     0N*O/HWQ/ 0(+NO(L0 E
 ....r    zcannot start threads)reasonc                      g d} g d}t        d      5 }|j                  t        | |      D cg c]  }| }}ddd       g dk(  sJ yc c}w # 1 sw Y   xY w)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_threadsaferG      sp     0N*O		* 
a %% 1>?S
 
 

 ....

 
s   A	AAAAc                    | j                  t        j                  j                  j                  dd       t        j                  t        d      5  t        d      5  	 ddd       ddd       t        j                  t        d      5  t        d       ddd       y# 1 sw Y   BxY w# 1 sw Y   FxY w# 1 sw Y   yxY w)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_scipyrR      s    0066xP	{*I	J t4 		 
{*I	J ,d+, ,	 	 , ,s0   B-B! B-B9!B*	&B--B69C)r)   concurrent.futuresr   r   rL   r   r   r   sklearn.utils.fixesr   sklearn.utils.parallelr   r	   r"   r%   r'   r,   markparametrizer@   xfailrG   rR   r   r    r!   <module>rY      s     1   : : ( 4I;X2+ - $LM/ N/$ 8$:;/ </"	,r    