o
    tBh                     @   sF   d Z ddlZddlmZ ddlmZ G dd dZdd Zd	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
    N)environ)Randomc                   @   s   e Zd ZdddZdS )
XDistHooksreturnNc                 C   s   |j d}||jd< d S )Nrandom_seeds)config	getoptionworkerinput)selfnoder    r   p/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/sklearn/tests/random_seed.pypytest_configure_node   s   z XDistHooks.pytest_configure_node)r   N)__name__
__module____qualname__r   r   r   r   r   r      s    r   c                    s  | j dr| j t  ttd}td}t| dr(d| j	v r(| j	d  nL|d u r0dg nD|dkr<t
 |g n8|dkrC| n1d	|v r\|d	\}}ttt|t|d
  nt|g t dk smt dkrttd|  | j_G  fd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                       s    e Zd Zej ddd ZdS )z0pytest_configure.<locals>.GlobalRandomSeedPlugin)paramsc                 s   s    |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
   requestr   r   r   global_random_seed8   s   zCpytest_configure.<locals>.GlobalRandomSeedPlugin.global_random_seedN)r   r   r   pytestfixturer   r   r   r   r   GlobalRandomSeedPlugin7   s    
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   r!   r   pytest_configure   s2   

r5   c                 C   s0   t 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(   r0   r   )r   r2   r   r   r   pytest_report_headerI   s   
r7   )	__doc__r   osr   randomr   r   r5   r7   r   r   r   r   <module>   s    
2