Ë
    ÷Q(h>  ã            
       ó>  — d dl Z d dlmZ d dlmZ d dlZddlmZ ddl	m
Z
mZ d„ Z e e
eddd	¬
«      g e
eddd	¬
«      g e
ed dd	¬
«      gdœd¬«      d dœd„«       Z e e
eddd	¬
«      g e
eddd	¬
«      g e
eddd	¬
«      dgdœd¬«      ddœd„«       Zdddœd„Zy)é    N)Úislice)ÚIntegralé   )Ú
get_configé   )ÚIntervalÚvalidate_paramsc              #   óH   K  — 	 t        t        | |«      «      }|r|–— nyŒ­w)zzChunk generator, ``gen`` into lists of length ``chunksize``. The last
    chunk may have a length less than ``chunksize``.N)Úlistr   )ÚgenÚ	chunksizeÚchunks      úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sklearn/utils/_chunking.pyÚchunk_generatorr      s,   è ø€ ð Ü”V˜C Ó+Ó,ˆÙØ‹Kàð ùs   ‚ "Úleft)Úclosed)ÚnÚ
batch_sizeÚmin_batch_sizeT)Úprefer_skip_nested_validation)r   c             #   ó¬   K  — d}t        t        | |z  «      «      D ]   }||z   }||z   | kD  rŒt        ||«      –— |}Œ" || k  rt        || «      –— yy­w)a,  Generator to create slices containing `batch_size` elements from 0 to `n`.

    The last slice may contain less than `batch_size` elements, when
    `batch_size` does not divide `n`.

    Parameters
    ----------
    n : int
        Size of the sequence.
    batch_size : int
        Number of elements in each batch.
    min_batch_size : int, default=0
        Minimum number of elements in each batch.

    Yields
    ------
    slice of `batch_size` elements

    See Also
    --------
    gen_even_slices: Generator to create n_packs slices going up to n.

    Examples
    --------
    >>> from sklearn.utils import gen_batches
    >>> list(gen_batches(7, 3))
    [slice(0, 3, None), slice(3, 6, None), slice(6, 7, None)]
    >>> list(gen_batches(6, 3))
    [slice(0, 3, None), slice(3, 6, None)]
    >>> list(gen_batches(2, 3))
    [slice(0, 2, None)]
    >>> list(gen_batches(7, 3, min_batch_size=0))
    [slice(0, 3, None), slice(3, 6, None), slice(6, 7, None)]
    >>> list(gen_batches(7, 3, min_batch_size=2))
    [slice(0, 3, None), slice(3, 7, None)]
    r   N)ÚrangeÚintÚslice)r   r   r   ÚstartÚ_Úends         r   Úgen_batchesr      sq   è ø€ ðZ €EÜ”3�q˜J‘Ó'Ó(ò ˆØ�jÑ ˆØ�Ñ !Ò#ØÜ�E˜3ÓÒØ‰ðð ˆq‚yÜ�E˜1‹oÓð ùs   ‚AA)r   Ún_packsÚ	n_samples)r    c             #   ó¨   K  — d}t        |«      D ]>  }| |z  }|| |z  k  r|dz  }|dkD  sŒ||z   }|�t        ||«      }t        ||d«      –— |}Œ@ y­w)aº  Generator to create `n_packs` evenly spaced slices going up to `n`.

    If `n_packs` does not divide `n`, except for the first `n % n_packs`
    slices, remaining slices may contain fewer elements.

    Parameters
    ----------
    n : int
        Size of the sequence.
    n_packs : int
        Number of slices to generate.
    n_samples : int, default=None
        Number of samples. Pass `n_samples` when the slices are to be used for
        sparse matrix indexing; slicing off-the-end raises an exception, while
        it works for NumPy arrays.

    Yields
    ------
    `slice` representing a set of indices from 0 to n.

    See Also
    --------
    gen_batches: Generator to create slices containing batch_size elements
        from 0 to n.

    Examples
    --------
    >>> from sklearn.utils import gen_even_slices
    >>> list(gen_even_slices(10, 1))
    [slice(0, 10, None)]
    >>> list(gen_even_slices(10, 10))
    [slice(0, 1, None), slice(1, 2, None), ..., slice(9, 10, None)]
    >>> list(gen_even_slices(10, 5))
    [slice(0, 2, None), slice(2, 4, None), ..., slice(8, 10, None)]
    >>> list(gen_even_slices(10, 3))
    [slice(0, 4, None), slice(4, 7, None), slice(7, 10, None)]
    r   r   N)r   Úminr   )r   r   r    r   Úpack_numÚthis_nr   s          r   Úgen_even_slicesr%   Q   su   è ø€ ð\ €EÜ˜'“Nò 	ˆØ�g‘ˆØ�a˜'‘kÒ!Ø�a‰KˆFØ�A‹:Ø˜&‘.ˆCØÐ$Ü˜) SÓ)�Ü˜˜s DÓ)Ò)Ø‰Eñ	ùs
   ‚(A«'A)Ú
max_n_rowsÚworking_memoryc                óÐ   — |€t        «       d   }t        |dz  | z  «      }|�t        ||«      }|dk  r2t        j                  d|t        j                  | dz  «      fz  «       d}|S )aØ  Calculate how many rows can be processed within `working_memory`.

    Parameters
    ----------
    row_bytes : int
        The expected number of bytes of memory that will be consumed
        during the processing of each row.
    max_n_rows : int, default=None
        The maximum return value.
    working_memory : int or float, default=None
        The number of rows to fit inside this number of MiB will be
        returned. When None (default), the value of
        ``sklearn.get_config()['working_memory']`` is used.

    Returns
    -------
    int
        The number of rows which can be processed within `working_memory`.

    Warns
    -----
    Issues a UserWarning if `row_bytes exceeds `working_memory` MiB.
    r'   i   r   zOCould not adhere to working_memory config. Currently %.0fMiB, %.0fMiB required.g      °>)r   r   r"   ÚwarningsÚwarnÚnpÚceil)Ú	row_bytesr&   r'   Úchunk_n_rowss       r   Úget_chunk_n_rowsr/   Œ   s~   € ð2 ÐÜ#›Ð&6Ñ7ˆä�~¨Ñ/°9Ñ<Ó=€LØÐÜ˜<¨Ó4ˆØ�aÒÜ�‰ð3àœrŸw™w y°6Ñ'9Ó:Ð;ñ<ô	
ð
 ˆØÐó    )r)   Ú	itertoolsr   Únumbersr   Únumpyr+   Ú_configr   Ú_param_validationr   r	   r   r   r%   r/   © r0   r   ú<module>r7      sä   ðó Ý Ý ã å  ß 8òñ á�x  D°Ô8Ð9Ù ¨!¨T¸&ÔAÐBÙ# H¨a°¸fÔEÐFñð
 #'ôð 23ó -óð-ñ` á�x  D°Ô8Ð9Ù˜X q¨$°vÔ>Ð?Ù˜x¨¨D¸Ô@À$ÐGñð
 #'ôð .2ó 0óð0ðf /3À4õ &r0   