a
    é´«j³  ã                   @  sB   d dl mZ d dlmZ d dlZer0d dlmZ G dd„ dƒZdS )é    )Úannotations)ÚTYPE_CHECKINGN)ÚNDFramec                   @  s”   e Zd ZU dZdhZded< ddddœd	d
„Zeddœdd„ƒZej	dddœdd„ƒZddœdd„Z
dddœdd„Zddœdd„Zddœdd„ZdS )Ú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]Ú_keysr   ÚboolÚNone)Úobjr   Úreturnc                C  s   || _ t |¡| _d S ©N)Ú_allows_duplicate_labelsÚweakrefÚrefÚ_obj)Úselfr
   r   © r   úP/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/pandas/core/flags.pyÚ__init__3   s    zFlags.__init__)r   c                 C  s   | 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   r   r   r   r   7   s    zFlags.allows_duplicate_labels)Úvaluer   c                 C  sB   t |ƒ}|  ¡ }|d u r tdƒ‚|s8|jD ]}| ¡  q*|| _d S )Nz$This flag's object has been deleted.)r   r   Ú
ValueErrorZaxesZ_maybe_check_uniquer   )r   r   r
   Úaxr   r   r   r   W   s    

Ústr)Úkeyc                 C  s   || j vrt|ƒ‚t| |ƒS r   )r   ÚKeyErrorÚgetattr)r   r   r   r   r   Ú__getitem__d   s    
zFlags.__getitem__)r   r   c                 C  s0   || j vr td|› d| j › �ƒ‚t| ||ƒ d S )NzUnknown flag z. Must be one of )r   r   Úsetattr)r   r   r   r   r   r   Ú__setitem__j   s    
zFlags.__setitem__c                 C  s   d| j › d�S )Nz<Flags(allows_duplicate_labels=z)>)r   r   r   r   r   Ú__repr__o   s    zFlags.__repr__c                 C  s   t |t| ƒƒr| j|jkS dS )NF)Ú
isinstanceÚtyper   )r   Úotherr   r   r   Ú__eq__r   s    zFlags.__eq__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   Úpropertyr   Úsetterr   r   r    r$   r   r   r   r   r   
   s   
&r   )Ú
__future__r   Útypingr   r   Zpandas.core.genericr   r   r   r   r   r   Ú<module>   s
   