
    i                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZmZmZ ddlmZmZ erdd	lmZ dd
lmZ ddZddZd Zd Zy)z;
Boilerplate functions used in defining binary operations.
    )annotations)wraps)TYPE_CHECKING)item_from_zerodim)is_matching_na)ABCExtensionArrayABCIndex	ABCSeries)ensure_wrapped_if_datetimelikesanitize_array)Callable)Fc                     d fd}|S )z
    Boilerplate for pandas conventions in arithmetic and comparison methods.

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

    Returns
    -------
    decorator
    c                    t        |       S )N)_unpack_zerodim_and_defer)methodnames    S/app/cer_product_mecsu/.venv/lib/python3.12/site-packages/pandas/core/ops/common.pywrapperz)unpack_zerodim_and_defer.<locals>.wrapper+   s    (66    )r   r   returnr    )r   r   s   ` r   unpack_zerodim_and_deferr      s    7 Nr   c                X     |j                  d      dv t                f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
    _)orxorandrorrxorrandc                    t        |dd       }||| j                  kD  rt        S t        |      }t	        | t
              r)t	        |t              rst        |d       }t        |      } | |      S )N__pandas_priority__)	getattrr#   NotImplementedr   
isinstancer   listr   r   )selfotherprio
is_logicalr   s      r   
new_methodz-_unpack_zerodim_and_defer.<locals>.new_methodC   ss    u3T:d...%%!%(t./5$' #5$/E259EdE""r   )stripr   )r   r   r,   r+   s   `  @r   r   r   1   s6      C$OOJ
6]# #* r   c                f    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   s      r   get_op_result_namer2   \   s6     %)X./ u- K yyKr   c                   t        | d      }t        |d      }|rU|rS	 | j                  |j                  k(  r| j                  S t        | j                  |j                        r| j                  S y|r| j                  S |r|j                  S y# t        $ r1 t        | j                  |j                        r| j                  cY S Y yt        $ r Y yw xY w)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_hass       r   r/   r/   r   s    ( AvEAvE	vvvv/vv 
vv	vv  	affaff-vv 		s   $B +B 5CCCN)r   strr   zCallable[[F], F])r   r   r   r;   r   r   )__doc__
__future__r   	functoolsr   typingr   pandas._libs.libr   pandas._libs.missingr   pandas.core.dtypes.genericr   r	   r
   pandas.core.constructionr   r   collections.abcr   pandas._typingr   r   r   r2   r/   r   r   r   <module>rF      sJ    #    . / 
 ( &(V,+r   