o
    ‡Å€g¬  ã                   @  sŒ   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZmZ er2ddlmZ ddd„Zddd„Zdd„ Zdd„ ZdS )z;
Boilerplate functions used in defining binary operations.
é    )Úannotations)Úwraps)ÚTYPE_CHECKINGÚCallable)Úitem_from_zerodim)Úis_matching_na)ÚABCIndexÚ	ABCSeries)ÚFÚnameÚstrÚreturnúCallable[[F], F]c                   s   d‡ fdd„}|S )z§
    Boilerplate for pandas conventions in arithmetic and comparison methods.

    Parameters
    ----------
    name : str

    Returns
    -------
    decorator
    Úmethodr
   r   c                   s
   t | ˆ ƒS )N)Ú_unpack_zerodim_and_defer)r   ©r   © úJ/var/www/html/myenv/lib/python3.10/site-packages/pandas/core/ops/common.pyÚwrapper%   s   
z)unpack_zerodim_and_defer.<locals>.wrapperN)r   r
   r   r
   r   )r   r   r   r   r   Úunpack_zerodim_and_defer   s   r   c                   s2   |  d¡ d¡}|dv ‰ tˆƒ‡ ‡fdd„ƒ}|S )aM  
    Boilerplate for pandas conventions in arithmetic and comparison methods.

    Ensure method returns NotImplemented when operating against "senior"
    classes.  Ensure zero-dimensional ndarrays are always unpacked.

    Parameters
    ----------
    method : binary method
    name : str

    Returns
    -------
    method
    Ú__>   ÚeqÚgeÚgtÚleÚltÚnec                   sN   ˆ rt | tƒrt |tƒrnt|dd ƒ}|d ur|| jkrtS t|ƒ}ˆ| |ƒS )NÚ__pandas_priority__)Ú
isinstancer   r	   Úgetattrr   ÚNotImplementedr   )ÚselfÚotherÚprio©Úis_cmpr   r   r   Ú
new_method>   s   

z-_unpack_zerodim_and_defer.<locals>.new_method)ÚremoveprefixÚremovesuffixr   )r   r   Ústripped_namer&   r   r$   r   r   +   s
   r   c                 C  s&   t |ttfƒrt| |ƒ}|S | j}|S )a  
    Find the appropriate name to pin to an operation result.  This result
    should always be either an Index or a Series.

    Parameters
    ----------
    left : {Series, Index}
    right : object

    Returns
    -------
    name : object
        Usually a string
    )r   r	   r   Ú_maybe_match_namer   )ÚleftÚrightr   r   r   r   Úget_op_result_nameQ   s
   
ÿr-   c                 C  s¤   t | dƒ}t |dƒ}|rF|rFz| j|jkr| jW S t| j|jƒr$| jW S W dS  ty<   t| j|jƒr9| j Y S Y dS  tyE   Y dS w |rK| jS |rP|jS dS )a«  
    Try to find a name to attach to the result of an operation between
    a and b.  If only one of these has a `name` attribute, return that
    name.  Otherwise return a consensus name if they match or None if
    they have different names.

    Parameters
    ----------
    a : object
    b : object

    Returns
    -------
    name : str or None

    See Also
    --------
    pandas.core.common.consensus_name_attr
    r   N)Úhasattrr   r   Ú	TypeErrorÚ
ValueError)ÚaÚbÚa_hasÚb_hasr   r   r   r*   g   s*   


þr*   N)r   r   r   r   )r   r   )Ú__doc__Ú
__future__r   Ú	functoolsr   Útypingr   r   Úpandas._libs.libr   Úpandas._libs.missingr   Úpandas.core.dtypes.genericr   r	   Úpandas._typingr
   r   r   r-   r*   r   r   r   r   Ú<module>   s    

&