ó
    Ñ]jöj  ã            
       ó�  • S SK r S SKrS SKrS SKJr  S SKJrJr  S SKr	S SK
Jr  S SKJrJrJrJr  S SKJrJrJr  S SKJrJr  S SKJr  S S	KJr  S S
KJrJrJrJ r J!r!J"r"  S r#S r$S r%S r&S r'S%S jr(S S.S jr)SSS.S jr*S r+S r,S r-\" S/\" \ R\                  SSSS9S/S// SQSS/S .SS!9SSSSSS .S" j5       r/SSS#.S$ jr0g)&é    N)ÚUserList)ÚcompressÚislice)Úissparse)Ú_is_numpy_namespaceÚget_namespaceÚget_namespace_and_deviceÚmove_to)Úis_pandas_dfÚis_polars_df_or_seriesÚis_pyarrow_data)ÚIntervalÚvalidate_params)Ú_approximate_mode)ÚPYARROW_VERSION_BELOW_17)Ú_check_sample_weightÚ_is_arraylike_not_scalarÚ_use_interchange_protocolÚcheck_arrayÚcheck_consistent_lengthÚcheck_random_statec                 ó¢  • [        U 5      u  pEnU(       aÚ  [        US5      (       a  [        XUS9nO+[        U[        [
        45      (       a  OUR                  XS9n[        US5      (       a‚  UR                  UR                  S5      (       a  UR                  XUS9$ UR                  UR                  S5      (       a0  UR                  U R                  U   US9nUR                  XU   US9$ [        U 5      (       a  US:X  a  [        R                  " U5      n[        U[        5      (       a  [        U5      nUS:X  a  XS	4   $ U S
S
2U4   $ )zAIndex an array or scipy.sparse consistently across NumPy version.Úshape)ÚxpÚdevice)r   ÚdtypeÚintegral©ÚaxisÚboolr   .N)r	   Úhasattrr
   Ú
isinstanceÚintÚsliceÚasarrayÚisdtyper   ÚtakeÚaranger   r   ÚnpÚtupleÚlist)ÚarrayÚkeyÚ	key_dtyper   r   Úis_array_apiÚdevice_Úindicess           ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sklearn/utils/_indexing.pyÚ_array_indexingr3   %   s#  € ä 8¸Ó ?Ñ€B�gÞÜ�3˜× Ñ Ü˜#¨WÑ5‰CÜ˜œc¤5˜\×*Ñ*ð à—*‘*˜S�*Ð1ˆCä�3˜× Ñ Ø�z‰z˜#Ÿ)™) Z×0Ñ0Ø—w‘w˜u°�wÐ5Ð5Ø—‘˜CŸI™I v×.Ñ.ð Ÿ)™) E§K¡K°Ñ$5¸g˜)ÐF�Ø—w‘w˜u¨c¡l¸�wÐ>Ð>ä�‡�˜9¨Ó.Ü�jŠj˜‹oˆÜ�#”u×ÑÜ�3‹iˆØ" a›iˆ5�c�‰?Ð:¨U²1°c°6©]Ð:ó    c                 ó<  • [        U5      (       a  [        R                  " U5      nUS:X  a?  [        U[        5      (       d*  [        R
                  " U5      (       d  U R                  XS9$ US:X  a  U R                  OU R                  nU(       a	  USS2U4   $ XA   $ )z%Index a pandas dataframe or a series.r#   r   N)	r   r)   r%   r"   r$   Úisscalarr'   ÚilocÚloc)ÚXr-   r.   r   Úindexers        r2   Ú_pandas_indexingr;   B   s~   € ä ×$Ñ$Ü�jŠj˜‹oˆà�EÓ¤:¨c´5×#9Ñ#9¼R¿[º[È×=MÑ=Mð �v‰v�cˆvÐ%Ð%ð &¨Ó.�!—&’&°A·E±EˆÞ"&ˆw’q˜#�v‰Ð8¨G©LÐ8r4   c                 óÒ   • [         R                  " U5      (       d  [        U[        5      (       a  X   $ US:X  a  [	        [        X5      5      $ U Vs/ s H  o0U   PM	     sn$ s  snf )zIndex a Python list.r    )r)   r6   r"   r$   r+   r   )r9   r-   r.   Úidxs       r2   Ú_list_indexingr>   Q   sV   € ä	‡{‚{�3×Ñœ: c¬5×1Ñ1à‰vˆØ�FÓä”H˜QÓ$Ó%Ð%á!Ó"šc�sˆcŒF™cÑ"Ð"ùÒ"s   ÁA$c                 óþ  • [        U[        R                  5      (       a  UR                  5       nO;[        R                  " U5      (       d   [        U[
        5      (       d  [        U5      nUS:X  a	  U SS2U4   $ US:X  a  U R                  U5      $ X   n[        R                  " U5      (       aL  [        U R                  5      S:X  a3  [        R                  S   nUR                  UR                  S5      5      $ U$ )z#Index a polars dataframe or series.é   Nr    é   Úpolarsr   )r"   r)   ÚndarrayÚtolistr6   r$   r+   ÚfilterÚlenr   ÚsysÚmodulesÚSeriesÚrow)r9   r-   r.   r   Ú	X_indexedÚpls         r2   Ú_polars_indexingrM   ]   sÆ   € ô �#”r—z‘z×"Ñ"à�j‰j‹l‰Ü�kŠk˜#×Ñ¤*¨S´%×"8Ñ"8Ü�3‹iˆàˆqƒyð ’�C�‰yÐà�FÓà�x‰x˜‹}Ðð ‘€IÜ	‡{‚{�3×ÑœC §¡›L¨AÓ-ô �[‰[˜Ñ"ˆØ�y‰y˜Ÿ™ qÓ)Ó*Ð*ØÐr4   c                 ó   • [         R                  " U5      n[        U[        5      (       aÌ  [        UR                  [
        5      (       aN  U R                  R                  UR                  5      nU R                  R                  UR                  5      S-   nO+UR                  (       d  SOUR                  nUR                  nUR                  (       d  SOUR                  n[        [        XVU5      5      nUS:X  a£  US:X  a9  [        U[        5      (       d$  [         R                  " U5      R                  5       nUS:X  a5  [         R                  " U5      R                  5       S   R                  5       nU(       a  U R                  U5      $ U R!                  U5      $ U(       a'  [#        U S5      (       a  U/nO=X   R%                  5       $ [        U[        5      (       d  [         R                  " U5      nUS:X  aX  [&        (       a;  SSKn[        XR*                  5      (       d  UR-                  XR/                  5       S9nU R1                  U5      n	OU R3                  U5      n	U(       a^  [5        [7        U SS/5      5      S:X  aC  [8        R:                  S	   n
U
R-                  U	R=                  5       S   R?                  5       5      $ U	$ )
zIndex a pyarrow data.r@   r   r#   r    r   N)ÚtyperA   Úpyarrow) r)   r6   r"   r$   ÚstopÚstrÚcolumn_namesÚindexÚstartÚstepr+   Úranger%   rD   ÚnonzeroÚcolumnÚselectr!   Úas_pyr   rP   ÚBooleanArrayr,   Úbool_rE   r'   rF   ÚgetattrrG   rH   Ú	to_pylistÚvalues)r9   r-   r.   r   Ú
scalar_keyrU   rQ   rV   rP   rK   Úpas              r2   Ú_pyarrow_indexingrc   z   s  € ä—’˜SÓ!€JÜ�#”u×ÑÜ�c—h‘h¤×$Ñ$Ø—N‘N×(Ñ(¨¯©Ó3ˆEØ—>‘>×'Ñ'¨¯©Ó1°AÑ5‰Dà ŸYŸY‘A¨C¯I©IˆEØ—8‘8ˆDØŸŸ‰q c§h¡hˆÜ”5˜ dÓ+Ó,ˆàˆqƒyà˜Ó¤j°´d×&;Ñ&;ä—*’*˜S“/×(Ñ(Ó*ˆCØ˜ÓÜ—*’*˜S“/×)Ñ)Ó+¨AÑ.×5Ñ5Ó7ˆCæØ—8‘8˜C“=Ð à�x‰x˜‹}Ðö Ü�1�g×Ñà�%‰Cà‘6—<‘<“>Ð!Ü˜œT×"Ñ"Ü�jŠj˜‹oˆà�FÓ÷ $Ò#Ûä˜c×#7Ñ#7×8Ñ8Ø—m‘m C¯m©m«o�mÐ>�à—H‘H˜S“M‰	ð —F‘F˜3“Kˆ	æ”cœ' ! W¨q¨cÓ2Ó3°qÓ8ô �[‰[˜Ñ#ˆØ�x‰x˜	×+Ñ+Ó-¨aÑ0×7Ñ7Ó9Ó:Ð:ØÐr4   Tc                 ó–  • Sn[         S[        S[        S[        R                  S0nSSSSSSS.nU c  g[        U [        UR                  5       5      5      (       a   U[        U 5         $ [        U [        5      (       at  U(       d  [        S5      eU R                  c  U R                  c  g[        U R                  5      n[        U R                  5      nUb  Ub  XV:w  a  [        U5      eUb  U$ U$ [        U [         [        ["        45      (       aX  [%        U 5      nU Vs1 s H  n[        U5      iM     n	nU	(       d  g['        U	5      S:w  a  [        U5      eU	R)                  5       $ [+        U S	5      (       aŒ  [-        U 5      u  p«U(       a_  [/        U
5      (       dO  U
R1                  U R2                  S5      (       a  gU
R1                  U R2                  S
5      (       a  g[        U5      e X@R2                  R4                     $ [        U5      e! [         a    [        U5      ef = fs  snf ! [         a    [        U5      ef = f)aG  Determine the data type of key.

Parameters
----------
key : scalar, slice or array-like
    The key from which we want to infer the data type.

accept_slice : bool, default=True
    Whether or not to raise an error if the key is a slice.

Returns
-------
dtype : {'int', 'str', 'bool', None}
    Returns the data type of key.
z~No valid specification of the columns. Only a scalar, list or slice of all integers or all strings, or boolean mask is allowedr#   rR   r    )ÚiÚuÚbÚOÚUÚSNzBOnly array-like or scalar are supported. A Python slice was given.r@   r   r   )r#   rR   r    r)   r]   r"   r*   ÚkeysrO   ÚKeyErrorÚ
ValueErrorr$   Ú	TypeErrorrU   rQ   Ú_determine_key_typer+   r   ÚsetrF   Úpopr!   r   r   r&   r   Úkind)r-   Úaccept_sliceÚerr_msgÚdtype_to_strÚarray_dtype_to_strÚkey_start_typeÚkey_stop_typeÚ
unique_keyÚeltÚkey_typer   r/   s               r2   ro   ro   µ   s'  € ð"	ð ô ˜¤ U¬D°&¼"¿(¹(ÀFÐK€LàØØØØØñÐð �{ØÜ�#”u˜\×.Ñ.Ó0Ó1×2Ñ2ð	&Ø¤ S£	Ñ*Ð*ô �#”u×ÑÞÜØTóð ð �9‰9Ñ §¡Ñ!1ØÜ,¨S¯Y©YÓ7ˆÜ+¨C¯H©HÓ5ˆØÑ%¨-Ñ*CØÓ.Ü  Ó)Ð)ØÑ%Ø!Ð!ØÐô �#œœe¤XÐ.×/Ñ/Ü˜“Xˆ
Ù8BÓCº
°Ô'¨Ö,¹
ˆÐCÞØÜˆx‹=˜AÓÜ˜WÓ%Ð%Ø�|‰|‹~ÐÜˆs�G×ÑÜ(¨Ó-Ñˆö Ô 3°B× 7Ñ 7Ø�z‰z˜#Ÿ)™) V×,Ñ,ØØ—‘˜CŸI™I z×2Ñ2Øä  Ó)Ð)ð*Ø)¯)©)¯.©.Ñ9Ð9ô �WÓ
ÐøôY ó 	&Ü˜WÓ%Ð%ð	&üò* Døô* ó *Ü  Ó)Ð)ð*ús   ÁH Ä#H-Ç1H2 ÈH*È2Ir   c                ó  • Uc  U $ US;  a  [        SR                  U5      5      e[        U5      nUS:X  a  US:X  a  [        SU S35      eUS:X  a   [        U [        5      (       a  [        S5      eUS:X  a8  [        [        U S	S/5      5      =nS
:w  a  [        S[        U 5       SU S35      eUS:X  a1  US:X  a+  [        U 5      (       d  [        U 5      (       d  [        S5      e[        U S5      (       a
  [        XX2S9$ [        U 5      (       a
  [        XX2S9$ [        U 5      (       a
  [        XX2S9$ [        U 5      (       a  [         R"                  " S[$        S9e[        U S	5      (       a
  ['        XX2S9$ [)        XU5      $ )a¬  Return rows, items or columns of X using indices.

.. warning::

    This utility is documented, but **private**. This means that
    backward compatibility might be broken without any deprecation
    cycle.

Parameters
----------
X : array-like, sparse-matrix, list, pandas.DataFrame, pandas.Series
    Data from which to sample rows, items or columns. `list` are only
    supported when `axis=0`.
indices : bool, int, str, slice, array-like
    - If `axis=0`, boolean and integer array-like, integer slice,
      and scalar integer are supported.
    - If `axis=1`:
        - to select a single column, `indices` can be of `int` type for
          all `X` types and `str` only for dataframe. The selected subset
          will be 1D, unless `X` is a sparse matrix in which case it will
          be 2D.
        - to select multiples columns, `indices` can be one of the
          following: `list`, `array`, `slice`. The type used in
          these containers can be one of the following: `int`, 'bool' and
          `str`. However, `str` is only supported when `X` is a dataframe.
          The selected subset will be 2D.
axis : int, default=0
    The axis along which `X` will be subsampled. `axis=0` will select
    rows while `axis=1` will select columns.

Returns
-------
subset
    Subset of X on axis 0 or 1.

Notes
-----
CSR, CSC, and LIL sparse matrices are supported. COO sparse matrices are
not supported.

Examples
--------
>>> import numpy as np
>>> from sklearn.utils import _safe_indexing
>>> data = np.array([[1, 2], [3, 4], [5, 6]])
>>> _safe_indexing(data, 0, axis=0)  # select the first row
array([1, 2])
>>> _safe_indexing(data, 0, axis=1)  # select the first column
array([1, 3, 5])
)r   r@   zR'axis' should be either 0 (to index rows) or 1 (to index  column). Got {} instead.r   rR   zString indexing (indices=zR) is not supported with 'axis=0'. Did you mean to use axis=1 for column selection?r@   z!axis=1 is not supported for listsr   rA   zm'X' should be a 2D NumPy array, 2D sparse matrix or dataframe when indexing the columns (i.e. 'axis=1'). Got z instead with z dimension(s).úFSpecifying the columns using strings is only supported for dataframes.r7   r   z¾A data object with support for the dataframe interchange protocolwas passed, but scikit-learn does currently not know how to handle this kind of data. Some array/list indexing will be tried.)ÚmessageÚcategory)rm   Úformatro   r"   r+   rF   r^   rO   r   r   r!   r;   r   rM   r   rc   ÚwarningsÚwarnÚUserWarningr3   r>   )r9   r1   r   Úindices_dtypeÚndims        r2   Ú_safe_indexingr†   	  s«  € ðf �Øˆà�6ÓÜð(ß(.©¨t«ó
ð 	
ô
 (¨Ó0€Màˆqƒy�] eÓ+ÜØ'¨ yð 1?ð ?ó
ð 	
ð
 ˆqƒy”Z ¤4×(Ñ(ÜÐ<Ó=Ð=àˆqƒyœc¤'¨!¨W°q°cÓ":Ó;Ð;�dÀÓAÜðä˜“7�)˜>¨$¨¨~ð?ó
ð 	
ð 	�‹	Ø˜UÓ"Ü˜a—‘Ô$=¸a×$@Ñ$@äØTó
ð 	
ô ˆq�&×Ñô
   ¨MÑEÐEÜ	 ×	"Ñ	"Ü ¨MÑEÐEÜ	˜×	Ñ	Ü  ¨]ÑFÐFÜ	" 1×	%Ñ	%ô
 �mŠmðDô !ñ	
ð 	
ô ˆq�'×ÑÜ˜q¨=ÑDÐDä˜a¨-Ó8Ð8r4   )Úrow_indexerÚcolumn_indexerc                ó,  • Uc  [        SSS5      OUnUc  [        SSS5      OUn[        U S5      (       aI  [        R                  " 5          [        R                  " S[
        5        XR                  X#4'   SSS5        gXX#4'   g! , (       d  f       g= f)a:  Safe assignment to a numpy array, sparse matrix, or pandas dataframe.

Parameters
----------
X : {ndarray, sparse-matrix, dataframe}
    Array to be modified. It is expected to be 2-dimensional.

values : ndarray
    The values to be assigned to `X`.

row_indexer : array-like, dtype={int, bool}, default=None
    A 1-dimensional array to select the rows of interest. If `None`, all
    rows are selected.

column_indexer : array-like, dtype={int, bool}, default=None
    A 1-dimensional array to select the columns of interest. If `None`, all
    columns are selected.
Nr7   Úignore)r$   r!   r�   Úcatch_warningsÚsimplefilterÚFutureWarningr7   )r9   r`   r‡   rˆ   s       r2   Ú_safe_assignrŽ   |  s‹   € ð& .9Ñ-@”%˜˜d DÔ)Àk€Kà#1Ñ#9Œˆd�D˜$Ô¸~ð ô ˆq�&×ÑÜ×$Ò$Õ&ô ×!Ò! (¬MÔ:Ø28�F‰F�;Ð.Ñ/÷ 'Ð&ð *0ˆ+Ð
%Ò&÷ 'Õ&ús   Á+BÂ
Bc                 óÜ   •  [        [        R                  " U5      U 5      n[        R
                  " U5      R                  5       $ ! [         a  n[	        SUS-
   SU S35      UeS nAff = f)Nzall features must be in [0, r@   z] or [-z, 0])r†   r)   r(   Ú
IndexErrorrm   Ú
atleast_1drD   )r-   Ú	n_columnsr=   Úes       r2   Ú#_get_column_indices_for_bool_or_intr”   ¡  sn   € ðÜœRŸYšY yÓ1°3Ó7ˆô
 �=Š=˜Ó×$Ñ$Ó&Ð&øô	 ó ÜØ*¨9°q©=¨/¸ÀÀÈ4ÐPó
àð	ûðús   ‚ A Á
A+ÁA&Á&A+c                 óv  • [        U5      n[        U 5      (       a  [        U R                  5       X5      $ U R                  S   n[        U[        [        45      (       a	  U(       d  / $ US;   a  [        X5      $  U R                  n[        U[        5      (       a  U/nO†[        U[        5      (       af  UR                  UR                  pvUb  UR!                  U5      nUb  UR!                  U5      S-   nOUS-   n[        [#        [%        U5      Xg5      5      $ [        U5      n / nU HS  n	UR!                  U	5      n
[        U
[&        R(                  5      (       d  [        SU S35      eUR+                  U
5        MU     U$ ! [         a    [        S5      ef = f! [,         a  n[        S5      UeSnAff = f)z�Get feature column indices for input data X and key.

For accepted values of `key`, see the docstring of
:func:`_safe_indexing`.
r@   ©r    r#   r}   NzSelected columns, z, are not unique in dataframeú/A given column is not a column of the dataframe)ro   r   Ú_get_column_indices_interchangeÚ__dataframe__r   r"   r+   r*   r”   ÚcolumnsÚAttributeErrorrm   rR   r$   rU   rQ   Úget_locr   rW   ÚnumbersÚIntegralÚappendrl   )r9   r-   r.   r’   Úall_columnsrš   rU   rQ   Úcolumn_indicesÚcolÚcol_idxr“   s               r2   Ú_get_column_indicesr¤   ¬  s­  € ô $ CÓ(€IÜ  ×#Ñ#Ü.¨q¯©Ó/@À#ÓQÐQà—‘˜‘
€IÜ�#œœe�}×%Ñ%®càˆ	Ø	�oÓ	%Ü2°3ÓBÐBð	ØŸ)™)ˆKô
 �cœ3×ÑØ�e‰GÜ˜œU×#Ñ#ØŸ)™) S§X¡X�4ØÑ Ø#×+Ñ+¨EÓ2�ØÑà"×*Ñ*¨4Ó0°1Ñ4‘à  1‘}�Üœœu YÓ/°Ó=Ó>Ð>ä˜3“iˆGð	WØˆNÛ�Ø%×-Ñ-¨cÓ2�Ü! '¬7×+;Ñ+;×<Ñ<Ü$Ø,¨W¨IÐ5RÐSóð ð ×%Ñ% gÖ.ñ ð ÐøôA ó 	ÜØXóð ð	ûô: ó 	WÜÐNÓOÐUVÐVûð	Wús%   Á;F Ä'AF ÆFÆ
F8Æ'F3Æ3F8c                 ó´  • U R                  5       n[        U[        [        45      (       a	  U(       d  / $ US;   a  [	        X5      $ [        U R                  5       5      n[        U[        5      (       a�  UR                  S;  a  [        S5      eUR                  UR                  peUb  UR                  U5      nUb  UR                  U5      S-   nOUS-   n[        [        [        U5      XV5      5      $ [        R                  " U5      (       a  U/OUn U Vs/ s H  o„R                  U5      PM     sn$ s  snf ! [          a  n	[!        S5      U	eSn	A	ff = f)zBSame as _get_column_indices but for X with __dataframe__ protocol.r–   )r@   Nzkey.step must be 1 or NoneNr@   r—   )Únum_columnsr"   r+   r*   r”   rS   r$   rV   ÚNotImplementedErrorrU   rQ   rT   r   rW   r)   r6   rm   )
ÚX_interchanger-   r.   r’   rS   rU   rQ   Úselected_columnsr¢   r“   s
             r2   r˜   r˜   â  s7  € ð ×)Ñ)Ó+€Iä�#œœe�}×%Ñ%®càˆ	Ø	�oÓ	%Ü2°3ÓBÐBä˜M×6Ñ6Ó8Ó9ˆä�cœ5×!Ñ!Ø�x‰x˜yÓ(Ü)Ð*FÓGÐGØŸ)™) S§X¡X�4ØÑ Ø$×*Ñ*¨5Ó1�àÑØ#×)Ñ)¨$Ó/°!Ñ3‘à  1‘}�Üœœu YÓ/°Ó=Ó>Ð>ä$&§K¢K°×$4Ñ$4˜C™5¸#Ðð	WÙ7GÓHÒ7G°×&Ñ& sÖ+Ñ7GÑHÐHùÒHøÜó 	WÜÐNÓOÐUVÐVûð	Wús*   ÄD< ÄD7Ä4D< Ä7D< Ä<
EÅEÅEÚbooleanr@   Úleft)ÚclosedÚrandom_state)ú
array-likezsparse matrixNr®   )ÚreplaceÚ	n_samplesr­   ÚstratifyÚsample_weight)Úprefer_skip_nested_validationc           
      ó„  • Un[        U5      n[        U5      S:X  a  gUS   n[        US5      (       a  UR                  S   O
[        U5      nUc  UnOXa:”  a  U (       d  [	        SXa4-  5      e[        U6   Ub  U (       d  [        S5      eUb  Ub  [        S5      eUcy  U (       aD  Ub+  [        XG[        R                  S9nXDR                  5       -  nOSnUR                  UUUSS	9n	GOd[        R                  " U5      n	UR                  U	5        U	SU n	GO6[        US
SS9n
U
R                  S:X  aE  [        R                   " U
 Vs/ s H#  nSR#                  UR%                  S5      5      PM%     sn5      n
[        R&                  " U
SS9u  pÍUR                  S   n[        R(                  " U5      n[        R*                  " [        R,                  " USS9[        R.                  " U5      SS 5      n[1        XöU5      n/ n	[3        U5       H+  nUR                  UU   UU   U S9nU	R5                  U5        M-     UR7                  U	5      n	U Vs/ s H%  n[9        U5      (       a  UR;                  5       OUPM'     nnU Vs/ s H  n[=        UU	5      PM     nn[        U5      S:X  a  US   $ U$ s  snf s  snf s  snf )aI  Resample arrays or sparse matrices in a consistent way.

The default strategy implements one step of the bootstrapping
procedure.

Parameters
----------
*arrays : sequence of array-like of shape (n_samples,) or             (n_samples, n_outputs)
    Indexable data-structures can be arrays, lists, dataframes or scipy
    sparse matrices with consistent first dimension.

replace : bool, default=True
    Implements resampling with replacement. It must be set to True
    whenever sampling with non-uniform weights: a few data points with very large
    weights are expected to be sampled several times with probability to preserve
    the distribution induced by the weights. If False, this will implement
    (sliced) random permutations.

n_samples : int, default=None
    Number of samples to generate. If left to None this is
    automatically set to the first dimension of the arrays.
    If replace is False it should not be larger than the length of
    arrays.

random_state : int, RandomState instance or None, default=None
    Determines random number generation for shuffling
    the data.
    Pass an int for reproducible results across multiple function calls.
    See :term:`Glossary <random_state>`.

stratify : {array-like, sparse matrix} of shape (n_samples,) or             (n_samples, n_outputs), default=None
    If not None, data is split in a stratified fashion, using this as
    the class labels.

sample_weight : array-like of shape (n_samples,), default=None
    Contains weight values to be associated with each sample. Values are
    normalized to sum to one and interpreted as probability for sampling
    each data point.

    .. versionadded:: 1.7

Returns
-------
resampled_arrays : sequence of array-like of shape (n_samples,) or             (n_samples, n_outputs)
    Sequence of resampled copies of the collections. The original arrays
    are not impacted.

See Also
--------
shuffle : Shuffle arrays or sparse matrices in a consistent way.

Examples
--------
It is possible to mix sparse and dense arrays in the same run::

  >>> import numpy as np
  >>> X = np.array([[1., 0.], [2., 1.], [0., 0.]])
  >>> y = np.array([0, 1, 2])

  >>> from scipy.sparse import coo_matrix
  >>> X_sparse = coo_matrix(X)

  >>> from sklearn.utils import resample
  >>> X, X_sparse, y = resample(X, X_sparse, y, random_state=0)
  >>> X
  array([[1., 0.],
         [2., 1.],
         [1., 0.]])

  >>> X_sparse
  <Compressed Sparse Row sparse matrix of dtype 'float64'
      with 4 stored elements and shape (3, 2)>

  >>> X_sparse.toarray()
  array([[1., 0.],
         [2., 1.],
         [1., 0.]])

  >>> y
  array([0, 1, 0])

  >>> resample(y, n_samples=2, random_state=0)
  array([0, 1])

Example using stratification::

  >>> y = [0, 0, 1, 1, 1, 1, 1, 1, 1]
  >>> resample(y, n_samples=5, replace=False, stratify=y,
  ...          random_state=0)
  [1, 1, 1, 0, 1]
r   Nr   z@Cannot sample %d out of arrays with dim %d when replace is FalsezCResampling with sample_weight is only implemented for replace=True.zDResampling with sample_weight is only implemented for stratify=None.)r   T)ÚsizeÚpr¯   F)Ú	ensure_2dr   rA   Ú rR   )Úreturn_inverseÚ	mergesort)rr   éÿÿÿÿ)r¯   r@   )r   rF   r!   r   rm   r   r§   r   r)   Úfloat64ÚsumÚchoicer(   Úshuffler   r…   r,   ÚjoinÚastypeÚuniqueÚbincountÚsplitÚargsortÚcumsumr   rW   ÚextendÚpermutationr   Útocsrr†   )r¯   r°   r­   r±   r²   ÚarraysÚmax_n_samplesÚfirstr¶   r1   ÚyrJ   ÚclassesÚ	y_indicesÚ	n_classesÚclass_countsÚclass_indicesÚn_ire   Ú	indices_iÚaÚresampled_arrayss                         r2   Úresampler×     s¼  € ð` €MÜ% lÓ3€Lä
ˆ6ƒ{�aÓØà�1‰I€EÜ")¨%°×"9Ñ"9�—‘˜A’¼sÀ5»z€IàÑØ!‰Ø
Ó
#®gÜØNØÐ(ñ)ó
ð 	
ô
 ˜VÑ$àÑ ®Ü!ØQó
ð 	
ð Ñ  XÑ%9Ü!ØRó
ð 	
ð ÑÞØÑ(Ü 4Ø!´·
±
ñ!�ð "×$5Ñ$5Ó$7Ñ7‘à�Ø"×)Ñ)ØØ"ØØð	 *ð ŠGô —i’i 	Ó*ˆGØ× Ñ  Ô)Ø˜n˜}Ð-ŠGô ˜¨E¸Ñ>ˆØ�6‰6�Q‹;ô —’ÁÓCÂ¸#˜#Ÿ(™( 3§:¡:¨eÓ#4Ö5ÁÑCÓDˆAäŸYšY q¸Ñ>ÑˆØ—M‘M !Ñ$ˆ	ä—{’{ 9Ó-ˆô ŸšÜ�JŠJ�y {Ñ3´R·Y²Y¸|Ó5LÈSÈbÐ5Qó
ˆô   ¸\ÓJˆàˆä�yÖ!ˆAØ$×+Ñ+¨M¸!Ñ,<¸cÀ!¹fÈgÐ+ÐVˆIØ�N‰N˜9Ö%ñ "ð ×*Ñ*¨7Ó3ˆñ 8>Ó>²v°!œ8 AŸ;™;ˆa�g‰gŒi¨AÒ-±v€FÐ>Ù<BÓCºF°qœ q¨'Ö2¹FÐÐCÜ
ÐÓ Ó!à Ñ"Ð"àÐùò= Dùò0 ?ùÚCs   Å*J3É,J8ÊJ=)r­   r°   c                 ó   • [        USXS.6$ )a	  Shuffle arrays or sparse matrices in a consistent way.

This is a convenience alias to ``resample(*arrays, replace=False)`` to do
random permutations of the collections.

Parameters
----------
*arrays : sequence of indexable data-structures
    Indexable data-structures can be arrays, lists, dataframes or scipy
    sparse matrices with consistent first dimension.

random_state : int, RandomState instance or None, default=None
    Determines random number generation for shuffling
    the data.
    Pass an int for reproducible results across multiple function calls.
    See :term:`Glossary <random_state>`.

n_samples : int, default=None
    Number of samples to generate. If left to None this is
    automatically set to the first dimension of the arrays.  It should
    not be larger than the length of arrays.

Returns
-------
shuffled_arrays : sequence of indexable data-structures
    Sequence of shuffled copies of the collections. The original arrays
    are not impacted.

See Also
--------
resample : Resample arrays or sparse matrices in a consistent way.

Examples
--------
It is possible to mix sparse and dense arrays in the same run::

  >>> import numpy as np
  >>> X = np.array([[1., 0.], [2., 1.], [0., 0.]])
  >>> y = np.array([0, 1, 2])

  >>> from scipy.sparse import coo_matrix
  >>> X_sparse = coo_matrix(X)

  >>> from sklearn.utils import shuffle
  >>> X, X_sparse, y = shuffle(X, X_sparse, y, random_state=0)
  >>> X
  array([[0., 0.],
         [2., 1.],
         [1., 0.]])

  >>> X_sparse
  <Compressed Sparse Row sparse matrix of dtype 'float64'
      with 3 stored elements and shape (3, 2)>

  >>> X_sparse.toarray()
  array([[0., 0.],
         [2., 1.],
         [1., 0.]])

  >>> y
  array([2, 1, 0])

  >>> shuffle(y, n_samples=2, random_state=0)
  array([0, 1])
F)r¯   r°   r­   )r×   )r­   r°   rÊ   s      r2   r¿   r¿   É  s   € ôD Ø	˜¨)òð r4   )T)1r�   rG   r�   Úcollectionsr   Ú	itertoolsr   r   Únumpyr)   Úscipy.sparser   Úsklearn.utils._array_apir   r   r	   r
   Úsklearn.utils._dataframer   r   r   Úsklearn.utils._param_validationr   r   Úsklearn.utils.extmathr   Úsklearn.utils.fixesr   Úsklearn.utils.validationr   r   r   r   r   r   r3   r;   r>   rM   rc   ro   r†   rŽ   r”   r¤   r˜   rž   r×   r¿   © r4   r2   Ú<module>rä      s  ðó Û 
Û Ý  ß &ã Ý !÷ó ÷ñ ÷
 FÝ 3Ý 8÷÷ ò;ò:9ò	#òò:8ôvQðh ()õ p9ðf ,0Àõ "0òJ'ò3òlWñD à�;Ù˜w×/Ñ/°°DÀÑHÈ$ÐOØ'Ð(Ú9Ø&¨Ð-ñð #'ñ	ð ØØØØôx ó	ðx ðv #'°$ö Dr4   