
    Owg                    H    d dl mZ d dlmZ d dlZerd dlmZ  G d d      Zy)    )annotations)TYPE_CHECKINGN)NDFramec                      e Zd ZU dZdhZded<   ddZedd       Zej                  dd       ZddZ
dd	Zdd
ZddZy)Flagsa  
    Flags that apply to pandas objects.

    Parameters
    ----------
    obj : Series or DataFrame
        The object these flags are associated with.
    allows_duplicate_labels : bool, default True
        Whether to allow duplicate labels in this object. By default,
        duplicate labels are permitted. Setting this to ``False`` will
        cause an :class:`errors.DuplicateLabelError` to be raised when
        `index` (or columns for DataFrame) is not unique, or any
        subsequent operation on introduces duplicates.
        See :ref:`duplicates.disallow` for more.

        .. warning::

           This is an experimental feature. Currently, many methods fail to
           propagate the ``allows_duplicate_labels`` value. In future versions
           it is expected that every method taking or returning one or more
           DataFrame or Series objects will propagate ``allows_duplicate_labels``.

    Examples
    --------
    Attributes can be set in two ways:

    >>> df = pd.DataFrame()
    >>> df.flags
    <Flags(allows_duplicate_labels=True)>
    >>> df.flags.allows_duplicate_labels = False
    >>> df.flags
    <Flags(allows_duplicate_labels=False)>

    >>> df.flags['allows_duplicate_labels'] = True
    >>> df.flags
    <Flags(allows_duplicate_labels=True)>
    allows_duplicate_labelszset[str]_keysc               F    || _         t        j                  |      | _        y N)_allows_duplicate_labelsweakrefref_obj)selfobjr   s      H/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/core/flags.py__init__zFlags.__init__3   s    (?%KK$	    c                    | j                   S )a  
        Whether this object allows duplicate labels.

        Setting ``allows_duplicate_labels=False`` ensures that the
        index (and columns of a DataFrame) are unique. Most methods
        that accept and return a Series or DataFrame will propagate
        the value of ``allows_duplicate_labels``.

        See :ref:`duplicates` for more.

        See Also
        --------
        DataFrame.attrs : Set global metadata on this object.
        DataFrame.set_flags : Set global flags on this object.

        Examples
        --------
        >>> df = pd.DataFrame({"A": [1, 2]}, index=['a', 'a'])
        >>> df.flags.allows_duplicate_labels
        True
        >>> df.flags.allows_duplicate_labels = False
        Traceback (most recent call last):
            ...
        pandas.errors.DuplicateLabelError: Index has duplicates.
              positions
        label
        a        [0, 1]
        )r   r   s    r   r   zFlags.allows_duplicate_labels7   s    < ,,,r   c                    t        |      }| j                         }|t        d      |s!|j                  D ]  }|j	                           || _        y )Nz$This flag's object has been deleted.)boolr   
ValueErroraxes_maybe_check_uniquer   )r   valuer   axs       r   r   zFlags.allows_duplicate_labelsW   sS    Uiik;CDDhh )&&() ).%r   c                L    || j                   vrt        |      t        | |      S r   )r	   KeyErrorgetattr)r   keys     r   __getitem__zFlags.__getitem__d   s%    djj 3-tS!!r   c                p    || j                   vrt        d| d| j                          t        | ||       y )NzUnknown flag z. Must be one of )r	   r   setattr)r   r!   r   s      r   __setitem__zFlags.__setitem__j   s7    djj }SE1B4::,OPPc5!r   c                "    d| j                    dS )Nz<Flags(allows_duplicate_labels=z)>)r   r   s    r   __repr__zFlags.__repr__o   s    01M1M0NbQQr   c                `    t        |t        |             r| j                  |j                  k(  S y)NF)
isinstancetyper   )r   others     r   __eq__zFlags.__eq__r   s*    eT$Z(//53P3PPPr   N)r   r   r   r   returnNone)r-   r   )r   r   r-   r.   )r!   str)r!   r/   r-   r.   )r-   r/   )__name__
__module____qualname____doc__r	   __annotations__r   propertyr   setterr"   r%   r'   r,    r   r   r   r   
   s_    $L 11E81% - -> ##
. $
.""
Rr   r   )
__future__r   typingr   r   pandas.core.genericr   r   r7   r   r   <module>r;      s     "   +k kr   