o
    Thc                     @   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        )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_ind r6   T/home/air/segue/gpt/backup/venv/lib/python3.10/site-packages/sklearn/utils/random.py_random_choice_csc   s\   

	
r8   )NN)__doc__r   numpyr   scipy.sparsesparser$    r   _randomr   __all__r8   r6   r6   r6   r7   <module>   s    