o
    1فi                     @  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    W/home/test-dt/pcm-url-check/venv/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    

&