a
    j=ic                     @   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edddZdd ZdS )z)
Assertion helpers for arithmetic tests.
    N)	DataFrameIndexSeriesarray)BooleanArrayPandasArray
cannot addc                 C   sp   t jt|d | |  W d   n1 s,0    Y  t jt|d ||   W d   n1 sb0    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   o/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/pandas/tests/arithmetic/common.pyassert_cannot_add   s    
&r   c                 C   s   t jt|d | |  W d   n1 s,0    Y  t jt|d ||   W d   n1 sb0    Y  t jt|d | |  W d   n1 s0    Y  t jt|d ||   W d   n1 s0    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rD|r@t | tr@tjS tS t | tsXt |trf|rbt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   tmZ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 s0    Y  tjt|d | |k W d   n1 s00    Y  tjt|d | |k W d   n1 sh0    Y  tjt|d | |k W d   n1 s0    Y  tjt|d || k  W d   n1 s0    Y  tjt|d || k W d   n1 s0    Y  tjt|d || k W d   n1 sH0    Y  tjt|d || k W d   n1 s0    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   Z_ndarrayr   Zastypebool)xr   r   r   xbox2`   s
    


z(assert_invalid_comparison.<locals>.xbox2)Z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   ZzerosshapeZbool_r   Zassert_equaljoinr   r   r   )	r   r   boxZxboxr   Zrev_boxresultexpectedr   r   r   r   assert_invalid_comparisonQ   sB    &((((((r%   )r   )N)F)__doc__numpyr   r   Zpandasr   r   r   r   Zpandas._testingZ_testingr   Zpandas.core.arraysr   r   r   r   r   r   r%   r   r   r   r   <module>   s   

