
    Ug                     P    d Z ddlmZ ddlmZ ddlZ G d d          Zd Zd ZdS )	az  global_random_seed fixture

The goal of this fixture is to prevent tests that use it to be sensitive
to a specific seed value while still being deterministic by default.

See the documentation for the SKLEARN_TESTS_GLOBAL_RANDOM_SEED
variable for insrtuctions on how to use this fixture.

https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed
    )environ)RandomNc                       e Zd ZddZdS )
XDistHooksreturnNc                 N    |j                             d          }||j        d<   d S )Nrandom_seeds)config	getoptionworkerinput)selfnoder	   s      X/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/sklearn/tests/random_seed.pypytest_configure_nodez XDistHooks.pytest_configure_node   s*    {,,^<<+7(((    )r   N)__name__
__module____qualname__r    r   r   r   r      s(        8 8 8 8 8 8r   r   c                 ^   | j                             d          r&| j                             t                                 t	          t          d                    }t          j        d          }t          | d          rd| j	        v r| j	        d         n|dgn|dk    r#t                                          |          gn|dk    r|nd	|v rS|                    d	          \  }}t	          t          t          |          t          |          d
z                       nt          |          gt                    dk     st                    dk    rt!          d|           | j        _         G fdd          }| j                              |                       d S )Nxdistd    SKLEARN_TESTS_GLOBAL_RANDOM_SEEDr   r	   *   anyall-   r   c   zThe value(s) of the environment variable SKLEARN_TESTS_GLOBAL_RANDOM_SEED must be in the range [0, 99] (or 'any' or 'all'), got: c                   D    e Zd Z ej                   d             ZdS )0pytest_configure.<locals>.GlobalRandomSeedPlugin)paramsc              3      K   |j         V  dS )a  Fixture to ask for a random yet controllable random seed.

            All tests that use this fixture accept the contract that they should
            deterministically pass for any seed value from 0 to 99 included.

            See the documentation for the SKLEARN_TESTS_GLOBAL_RANDOM_SEED
            variable for insrtuctions on how to use this fixture.

            https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed
            N)param)r   requests     r   global_random_seedzCpytest_configure.<locals>.GlobalRandomSeedPlugin.global_random_seed:   s       -r   N)r   r   r   pytestfixturer&   )r	   s   r   GlobalRandomSeedPluginr!   9   s>        	|	,	,	,	  	  
-	,	  	  	 r   r)   )pluginmanager	haspluginregisterr   listranger   gethasattrr   r   choicesplitintminmax
ValueErroroptionr	   )r
   RANDOM_SEED_RANGErandom_seed_varstartstopr)   r	   s         @r   pytest_configurer<      s   %%g.. 4%%jll333U3ZZ((k"DEEOv}%% .F<N*N*N).9		 t	E	!	!(9::;	E	!	!(/!!)//44KE4c%jj#d))a- @ @AALL001L|q  C$5$5$:$:?-<? ?  
 ".FM                    !!"8"8":":;;;;;r   c                 l    t          j        d          }|dk    rdd| j        j        d          ddgS d S )Nr   r   zCTo reproduce this test run, set the following environment variable:z&    SKLEARN_TESTS_GLOBAL_RANDOM_SEED="r   "z]See: https://scikit-learn.org/dev/computing/parallelism.html#sklearn-tests-global-random-seed)r   r/   r7   r	   )r
   r9   s     r   pytest_report_headerr?   K   sP    k"DEEO%QUV]5OPQ5RUUU4	
 	
  r   )	__doc__osr   randomr   r'   r   r<   r?   r   r   r   <module>rC      s   	 	             8 8 8 8 8 8 8 8/< /< /<d

 

 

 

 

r   