3
���hc � @ sP d Z ddlZddlZddlmZmZmZ ddlj Z
d
dd�Zdd� Zdd � Z
dS )z)
Assertion helpers for arithmetic tests.
� N)� DataFrame�Index�Seriesc C s� t jt|d�� | | W dQ R X t jt|d�� || W dQ R X t jt|d�� | | W dQ R X t jt|d�� || W dQ R X dS )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
)�matchN)�pytest�raises� TypeError)�left�right�msg� r �@/tmp/pip-build-5_djhm0z/pandas/pandas/tests/arithmetic/common.py�assert_invalid_addsub_type s
r c C sF | t kst|t �rt S | tks(t|t�r,tS | tks>t|t�rBtS | S )z?
Given two box-types, find the one that takes priority
)r �
isinstancer r )�boxZvectorr r r
�get_upcast_box s r c : C s� |t k r|ntj}| |k}|tj|jtjd��}tj||� || k}tj||� | |k}tj|| � || k}tj|| � djdddddg�}t j
t|d�� | |k W d Q R X t j
t|d�� | |k W d Q R X t j
t|d�� | |k W d Q R X t j
t|d�� | |k W d Q R X t j
t|d�� || k W d Q R X t j
t|d�� || k W d Q R X t j
t|d�� || k W d Q R X t j
t|d�� || k W d Q R X d S )
z�
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, tm.to_array}
)Zdtype�|zInvalid comparison betweenzCannot compare typeznot supported betweenzinvalid type promotionz�The 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 �np�array�zeros�shapeZbool_�tmZassert_equal�joinr r r )r r
r Zxbox�result�expectedr r r r
�assert_invalid_comparison, s@
r )N)�__doc__Znumpyr r Zpandasr r r Zpandas._testingZ_testingr r r r r r r r
�<module> s
|