
    0Ph                     @    d dl Zd dlmZ d ZdddZd
dZddd	ZdS )    N)get_namespacec                    t          | t          j                  s| S 	 d| j        j        v r| S n# t
          t          f$ r Y nw xY wt          j        |           }t          j        | j        d|i          }|                     |          S )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      U/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/utils/_unique.py_attach_uniquer   	   s    
 a$$ qw'''H (I&    Yq\\F8AGx.@AAAL666%%%s   / AAF)return_tuplec                 r    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   4   K   | ]}t          |          V  d S N)r   ).0r   s     r   	<genexpr>z attach_unique.<locals>.<genexpr>8   s*      ..aq!!......       r   tuplelen)r   ysress      r   attach_uniquer      sA    8 ..2...
.
.C
3xx1}}\}1vJr   c                     	 | j         j         d| j         j        v r| j         j        d         S n# t          $ r Y nw xY wt          | |          \  }}|                    |           S )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.
    Nr   xp)r   r   r   r   unique_values)r   r"   _s      r   _cached_uniquer%   >   s~    7'H8H,H,H7#H--    !###EBAs   +/ 
<<r!   c                 t     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   :   K   | ]}t          |           V  dS )r!   N)r%   )r   r   r"   s     r   r   z cached_unique.<locals>.<genexpr>i   s0      55QqR(((555555r   r   r   r   )r"   r   r   s   `  r   cached_uniquer(   Q   sD    0 5555"555
5
5C
3xx1}}1vJr   r   )numpyr	   sklearn.utils._array_apir   r   r   r%   r(    r   r   <module>r,      s        2 2 2 2 2 2& & && %*     D   &        r   