o
    g
                     @   sx   d Z ddlZddlZddlmZmZmZmZ ddl	m
Z ddlmZmZ dddZddd	ZddefddZdd ZdS )z)
Assertion helpers for arithmetic tests.
    N)	DataFrameIndexSeriesarray)BooleanArrayNumpyExtensionArray
cannot addc                 C   sr   t jt|d | |  W d   n1 sw   Y  t jt|d ||   W d   dS 1 s2w   Y  dS )z
    Helper to assert that left and right cannot be added.

    Parameters
    ----------
    left : object
    right : object
    msg : str, default "cannot add"
    matchNpytestraises	TypeErrorleftrightmsg r   `/var/www/html/ecg_monitoring/venv/lib/python3.10/site-packages/pandas/tests/arithmetic/common.pyassert_cannot_add   s   


"r   c                 C   s   t jt|d | |  W d   n1 sw   Y  t jt|d ||   W d   n1 s1w   Y  t jt|d | |  W d   n1 sLw   Y  t jt|d ||   W d   dS 1 shw   Y  dS )z
    Helper to assert that left and right can be neither added nor subtracted.

    Parameters
    ----------
    left : object
    right : object
    msg : str or None, default None
    r	   Nr   r   r   r   r   assert_invalid_addsub_type$   s   




"r   Fis_cmpc                 C   sl   t | ts
t |trtS t | tst |tr"|r t | tr tjS tS t | ts,t |tr3|r1tjS tS tjS )z
    Get the box to use for 'expected' in an arithmetic or comparison operation.

    Parameters
    left : Any
    right : Any
    is_cmp : bool, default False
        Whether the operation is a comparison method.
    )
isinstancer   r   r   npr   tmto_array)r   r   r   r   r   r   get_upcast_box8   s   r   c           	      C   s  |t tfvr|ntj}dd }|}t|t rt| trtj}|| |k}|tj|jtjd}t	|| ||| k}t	||| || |k}t	||  ||| k}t	|||  d
g d}tjt|d | |k  W d   n1 s|w   Y  tjt|d | |k W d   n1 sw   Y  tjt|d | |k W d   n1 sw   Y  tjt|d | |k W d   n1 sw   Y  tjt|d || k  W d   n1 sw   Y  tjt|d || k W d   n	1 sw   Y  tjt|d || k W d   n	1 s w   Y  tjt|d || k W d   dS 1 s=w   Y  dS )a  
    Assert that comparison operations with mismatched types behave correctly.

    Parameters
    ----------
    left : np.ndarray, ExtensionArray, Index, or Series
    right : object
    box : {pd.DataFrame, pd.Series, pd.Index, pd.array, tm.to_array}
    c                 S   s(   t | tr| jS t | tr| tS | S N)r   r   _ndarrayr   astypebool)xr   r   r   xbox2`   s
   


z(assert_invalid_comparison.<locals>.xbox2)dtype|)zInvalid comparison betweenzCannot compare typeznot supported betweenzinvalid type promotionzThe DTypes <class 'numpy.dtype\[datetime64\]'> and <class 'numpy.dtype\[int64\]'> do not have a common DType. For example they cannot be stored in a single array unless the dtype is `object`.r	   N)r   r   r   r   r   zerosshapebool_r   assert_equaljoinr   r   r   )	r   r   boxxboxr"   rev_boxresultexpectedr   r   r   r   assert_invalid_comparisonQ   sR   







$r/   )r   r   )F)__doc__numpyr   r   pandasr   r   r   r   pandas._testing_testingr   pandas.core.arraysr   r   r   r   r    r   r/   r   r   r   r   <module>   s    

