
    {Kg                         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mZmZ d Zd Zd Zd	 Zd
 ZddZd Zd Zy)    N)assert_array_almost_equal)comb_our_rand_r_py)_random_choice_cscsample_without_replacementc                  z    t        j                  t              5  t        ddd       d d d        y # 1 sw Y   y xY w)N      unknown)pytestraises
ValueErrorr        c/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/sklearn/utils/tests/test_random.py1test_invalid_sample_without_replacement_algorithmr      s&    	z	""1a3 
#	"	"s   1:c                  h    d} | D ]*  	 dfd	}t        |       t        |       t        |       , y )N)autotracking_selectionreservoir_samplingpoolc                 "    t        | ||      S )N)methodrandom_stater   )n_population	n_samplesr   ms      r   !sample_without_replacement_methodzUtest_sample_without_replacement_algorithms.<locals>.sample_without_replacement_method   s     .i r   )N)check_edge_case_of_sample_intcheck_sample_intcheck_sample_int_distribution)methodsr    r   s     @r   *test_sample_without_replacement_algorithmsr%      s9    JG 37	 	&&GH:;%&GH r   c                 |   t        j                  t              5   | dd       d d d        t        j                  t              5   | dd       d d d         | dd      j                  dk(  sJ  | dd      j                  dk(  sJ  | dd      j                  dk(  sJ  | dd      j                  dk(  sJ t        j                  t              5   | dd       d d d        t        j                  t              5   | dd       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   MxY w# 1 sw Y   y xY w)Nr         )r   )r'   r
   )r   r   r   shaper   s    r   r!   r!   $   s   	z	""1a( 
#	z	""1a( 
# &a+11T999%a+11T999 &a+11T999%a+11T999 
z	""2q) 
#	z	""1b) 
#	"# 
#	"	"	" 
#	"	"	"s/   
D
D
D&;
D2DD#&D/2D;c                 4   d}t        |dz         D ]d  } | ||      }t        |      |k(  sJ t        j                  |      }t        j                  |      |k(  sJ t        j
                  ||k        rdJ  t        j                   | dd            dk(  sJ y )Nd   r'   r   )rangelennpuniquesizeall)r   r   r   sr0   s        r   r"   r"   ;   s    
 L<!+,	&|Y?1v"""1wwv)+++vvf|+,,, - 77-a34999r   c           
          d}d}t        |      D ]a  }t        ||d      }i }t        |      D ]'  }d |t         | ||            <   t        |      |k(  s' G t	        dt        |      d|d       y )N
   '  T)exactz.number of combinations != number of expected (z != ))r-   r   	frozensetr.   AssertionError)r   r   n_trialsr   
n_expectedoutputis          r   r#   r#   M   s    
 L H<(	 ,	>
xA 97iPQR 6{j( ! !v;
,  )r   c                    t        j                  ddg      t        j                  g d      g}t        j                  ddg      t        j                  g d      g}t        | |||      }t        j                  |      sJ t        t        |            D ]_  }t        j                  |j                  |      j                         j                               t        |       z  }t        ||   |d       a ddgddgg}t        j                  ddg      t        j                  g d      g}t        | ||	      }t        j                  |      sJ t        t        |            D ]_  }t        j                  |j                  |      j                         j                               t        |       z  }t        ||   |d       a t        j                  ddg      t        j                  g d      g}t        j                  d
dg      t        j                  g d      g}t        | |||      }t        j                  |      sJ t        t        |            D ]d  }t        j                  |j                  |      j                         j                         t        ||               | z  }t        ||   |d       f dgdgg}t        j                  d
dg      t        j                  dg      g}t        | ||	      }t        j                  |      sJ t        t        |            D ]V  }t        j                  |j                  |      j                         j                               | z  }t        ||   |d       X y )Nr   r'   r   r'   r(         ?333333?皙?g333333?)decimalr(   )r   rA   rA   )r   classesr                 ?)rG   rH   rG   )	minlength)r/   arrayr   spissparser-   r.   bincountgetcoltoarrayravelfloatr   )r   r   rF   class_probabilitiesgotkps          r   test_random_choice_cscrV   m   s   xxA)!45G88S#J//1JK
Y1Dl
SC;;s3w< KK

1--/55785;KK!"5a"8!QG !
 1v1vG88S#J/:K1LM
W<C ;;s3w< KK

1--/55785;KK!"5a"8!QG !
 xxA)!45G88S#J//1JK
Y1Dl
SC;;s3w< KK

1%%'--/3?RST?U;V  	
 	""5a"8!QG ! sQCjG88S#J/3%A
W<C ;;s3w< KK

1--/55789D!"5a"8!QG !r   c                     t        j                  ddg      t        j                  g d      g} t        j                  ddg      t        j                  g d      g}t        j                  t              5  t        d| |d       d d d        t        j                  ddg      t        j                  g d	      g} t        j                  ddg      t        j                  g d      g}t        j                  t              5  t        d| |d       d d d        t        j                  d
dg      t        j                  g d      g} t        j                  ddg      t        j                  g d      g}t        j                  t              5  t        d| |d       d d d        t        j                  ddg      t        j                  g d      g} t        j                  ddg      t        j                  g d      g}t        j                  t              5  t        d| |d       d d d        y # 1 sw Y   xY w# 1 sw Y   0xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nr   r'   )r   r'   r(      rA   rB   r   a1)zrZ   2g@rD   )rD   g?g"@r@   rC   )r/   rJ   r   r   r   r   )rF   rR   s     r   test_random_choice_csc_errorsr]      s   xxA,!78G88S#J//1JK	z	"1g':A> 
# xxc
#RXXo%>?G88S#J//1JK	z	"1g':A> 
# xxc
#RXXo%>?G88S#J//1JK	z	"1g':A> 
# xxA)!45G88S#J//1JK	z	"1g':A> 
#	"% 
#	" 
#	" 
#	" 
#	"s0   6H2H?II2H<?I	II!c                  D    dt        d      k(  sJ dt        d      k(  sJ y )Ni=(i=Ki!  r   r   r   r   r   test_our_rand_rr_      s(    z2222^A&&&&r   )r6      )numpyr/   r   scipy.sparsesparserK   numpy.testingr   scipy.specialr   sklearn.utils._randomr   sklearn.utils.randomr   r   r   r%   r!   r"   r#   rV   r]   r_   r   r   r   <module>rh      sF       3  0 O4
I"*.:$@4Hn?4'r   