
    {KgZ                     J    d Z ddlZddlZddlmZ ddlmZ ddl	m
Z
 dgZddZy)	zUtilities for random sampling.    N   )check_random_state)sample_without_replacementr   c           	         t        j                   d      }t        j                   d      }t        j                   ddg      }t        t        |            D ]  }t        j                  ||         ||<   ||   j
                  j                  dk7  rt        d||   j
                  z        ||   j                  t        j                  d      ||<   |Kt        j                  ||   j                  d         }|j                  d||   j                  d   z         nt        j                  ||         }t        j                  t        j                  |      d      st        d	j                  |            |j                  d   ||   j                  d   k7  r9t        d
j                  |||   j                  d   |j                  d               d||   vr4t        j                   ||   dd      ||<   t        j                   |dd      }t#        |      }	||   j                  d   dkD  rt        j$                  ||   dk(        j'                         }
d||
   z
  }t)        | |z        }t+        | ||      }|j-                  |       ||   dk7  }||   }|t        j                  |      z  }t        j.                  |j1                         |	j3                  |            }|j-                  ||   |   |          |j5                  t        |              t7        j8                  |||f| t        |      ft(              S )a  Generate a sparse random matrix given column class distributions

    Parameters
    ----------
    n_samples : int,
        Number of samples to draw in each column.

    classes : list of size n_outputs of arrays of size (n_classes,)
        List of classes for each column.

    class_probability : list of size n_outputs of arrays of         shape (n_classes,), default=None
        Class distribution of each column. If None, uniform distribution is
        assumed.

    random_state : int, RandomState instance or None, default=None
        Controls the randomness of the sampled classes.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    random_matrix : sparse csc matrix of size (n_samples, n_outputs)

    ir   zclass dtype %s is not supportedF)copy)shaper   g      ?z2Probability array at index {0} does not sum to onezXclasses[{0}] (length {1}) and class_probability[{0}] (length {2}) have different length.g        )n_population	n_samplesrandom_state)size)dtype)arrayrangelennpasarrayr   kind
ValueErrorastypeint64emptyr	   fillisclosesumformatinsertr   flatnonzeroitemintr   extendsearchsortedcumsumuniformappendsp
csc_matrix)r   classesclass_probabilityr   dataindicesindptrjclass_prob_jrngindex_class_0	p_nonzeronnz
ind_sampleclasses_j_nonzeroclass_probability_nzclass_probability_nz_normclasses_inds                     X/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/sklearn/utils/random.py_random_choice_cscr9      s
   2 ;;sDkk#G[[qc"F3w< ZZ
+
1:  C'>AQAQQRRQZ&&rxxe&<
 $88'!**:*:1*=>La'!*"2"21"556::&7&:;Lzz"&&.4DKKAN  a GAJ$4$4Q$77$$*Fwqz''*L,>,>q,A%  GAJ71:q!4GAJ99\1c:L !.1:A"NN71:?;@@BML77Ii)+,C3&#LJ NN:& !(
a#/0A#B (<rvv$@ )% //)002CKKSK4IK KK
#45kBCc'l#k !n ==$09c'l2KSVWW    )NN)__doc__r   numpyr   scipy.sparsesparser&    r   _randomr   __all__r9    r:   r8   <module>rC      s(    $
      /'
(TXr:   