
    sg                     >    d dl Zd dlmZ d ZdddZd
dZddd	Zy)    N)get_namespacec                 0   t        | t        j                        s| S 	 d| j                  j                  v r| S 	 t        j                  |       }t        j                  | j                  d|i      }| j                  |      S # t
        t        f$ r Y [w xY w)zAttach unique values of y to y and return the result.

    The result is a view of y, and the metadata (unique) is not attached to y.
    unique)metadata)dtype)	
isinstancenpndarrayr   r   AttributeError	TypeErrorr   view)yr   unique_dtypes      H/var/www/html/venv/lib/python3.12/site-packages/sklearn/utils/_unique.py_attach_uniquer   	   s    
 a$qww'''H (
 YYq\F88AGGx.@AL666%% I& s   B BBF)return_tuplec                 T    t        d |D              }t        |      dk(  r| s|d   S |S )a  Attach unique values of ys to ys and return the results.

    The result is a view of y, and the metadata (unique) is not attached to y.

    IMPORTANT: The output of this function should NEVER be returned in functions.
    This is to avoid this pattern:

    .. code:: python

        y = np.array([1, 2, 3])
        y = attach_unique(y)
        y[1] = -1
        # now np.unique(y) will be different from cached_unique(y)

    Parameters
    ----------
    *ys : sequence of array-like
        Input data arrays.

    return_tuple : bool, default=False
        If True, always return a tuple even if there is only one array.

    Returns
    -------
    ys : tuple of array-like or array-like
        Input data with unique values attached.
    c              3   2   K   | ]  }t        |        y wN)r   ).0r   s     r   	<genexpr>z attach_unique.<locals>.<genexpr>8   s     .aq!.s      r   tuplelen)r   ysress      r   attach_uniquer      s/    8 .2.
.C
3x1}\1vJ    c                     	 | j                   j                  1d| j                   j                  v r| j                   j                  d   S t        | |      \  }}|j	                  |       S # t        $ r Y ,w xY w)zReturn the unique values of y.

    Use the cached values from dtype.metadata if present.

    This function does NOT cache the values in y, i.e. it doesn't change y.

    Call `attach_unique` to attach the unique values to y.
    r   xp)r   r   r   r   unique_values)r   r"   _s      r   _cached_uniquer%   >   st    77'H8H8H,H77##H-- !#EBA	  s   AA* *	A65A6r!   c                 V     t         fd|D              }t        |      dk(  r|d   S |S )a  Return the unique values of ys.

    Use the cached values from dtype.metadata if present.

    This function does NOT cache the values in y, i.e. it doesn't change y.

    Call `attach_unique` to attach the unique values to y.

    Parameters
    ----------
    *ys : sequence of array-like
        Input data arrays.

    xp : module, default=None
        Precomputed array namespace module. When passed, typically from a caller
        that has already performed inspection of its own inputs, skips array
        namespace inspection.

    Returns
    -------
    res : tuple of array-like or array-like
        Unique values of ys.
    c              3   8   K   | ]  }t        |         yw)r!   N)r%   )r   r   r"   s     r   r   z cached_unique.<locals>.<genexpr>i   s     5QqR((5s   r   r   r   )r"   r   r   s   `  r   cached_uniquer(   Q   s.    0 5"5
5C
3x1}1vJr   r   )numpyr	   sklearn.utils._array_apir   r   r   r%   r(    r   r   <module>r,      s,     2&& %* D&  r   