
    -i>                        S SK r S SKJr  S SKJr  S SKrSSKJr  SSK	J
r
Jr  S r\" \
" \SSS	S
9/\
" \SSS	S
9/\
" \S SS	S
9/S.SS9S S.S j5       r\" \
" \SSS	S
9/\
" \SSS	S
9/\
" \SSS	S
9S/S.SS9SS.S j5       rSSS.S jrg)    N)islice)Integral   )
get_config   )Intervalvalidate_paramsc              #   R   #     [        [        X5      5      nU(       a  Uv   OgM#  7f)zvChunk generator, ``gen`` into lists of length ``chunksize``. The last
chunk may have a length less than ``chunksize``.N)listr   )gen	chunksizechunks      J/var/www/html/venv/lib/python3.13/site-packages/sklearn/utils/_chunking.pychunk_generatorr      s)      VC+,K s   %'left)closed)n
batch_sizemin_batch_sizeT)prefer_skip_nested_validation)r   c             #      #    Sn[        [        X-  5      5       H   nX1-   nXR-   U :  a  M  [        X55      v   UnM"     X0:  a  [        X05      v   gg7f)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      s_     Z E3q'( !#E ) yEo s   AA)r   n_packs	n_samples)r    c             #      #    Sn[        U5       H>  nX-  nX@U-  :  a  US-  nUS:  d  M  X5-   nUb  [        X&5      n[        X6S5      v   UnM@     g7f)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   se     \ E'N'k!aKFA:.C$))D))E #s
   &A'A)
max_n_rowsworking_memoryc                    Uc  [        5       S   n[        US-  U -  5      nUb  [        X15      nUS:  a4  [        R                  " SU[
        R                  " U S-  5      4-  5        SnU$ )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rwwy6'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#HafEF
 #' 23 --` xD89Xq$v>?xD@$G
 #' .2 00f /34 &r0   