o
    ic                     @   sL   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dZdS )
zUtilities for random sampling.    N   )check_random_state)sample_without_replacementr   c                 C   s,  t  d}t  d}t  ddg}tt|D ]}t|| ||< || jjdkr3td|| j || jtj	dd||< |du r[tj
|| jd d}|d|| jd   nt|| }tt|d	srtd
||jd || jd krtd||| jd |jd d|| vrt|| dd||< t|dd}t|}	|| jd dkrt|| dk }
d||
  }t| | }t| ||d}|| || dk}|| }|t| }t| |	j|d}||| | |  |t| qtj|||f| t|ftd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)copyN)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        )Zn_population	n_samplesrandom_state)size)dtype)arrayrangelennpZasarrayr   kind
ValueErrorZastypeZint64emptyr   fillisclosesumformatinsertr   Zflatnonzeroitemintr   extendZsearchsortedZcumsumuniformappendspZ
csc_matrix)r   classesZclass_probabilityr	   dataindicesZindptrjZclass_prob_jrngZindex_class_0Z	p_nonzeroZnnzZ
ind_sampleZclasses_j_nonzeroZclass_probability_nzZclass_probability_nz_normZclasses_ind r#   c/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/sklearn/utils/random.py_random_choice_csc   s\   

	
r%   )NN)__doc__r   numpyr   Zscipy.sparsesparser    r   _randomr   __all__r%   r#   r#   r#   r$   <module>   s    