3
pdc                 @   sP   d Z ddlZddlZddlmZmZmZ ddlj	Z
d
ddZdd Zdd	 ZdS )z)
Assertion helpers for arithmetic tests.
    N)	DataFrameIndexSeriesc             C   s   t jt|d | |  W dQ R X t jt|d ||   W dQ R X t jt|d | |  W dQ R X t jt|d ||   W dQ R X 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
    )matchN)pytestraises	TypeError)leftrightmsg r   @/tmp/pip-build-7vycvbft/pandas/pandas/tests/arithmetic/common.pyassert_invalid_addsub_type   s    
r   c             C   sF   | t kst|t rt S | tks(t|tr,tS | tks>t|trBtS | S )z?
    Given two box-types, find the one that takes priority
    )r   
isinstancer   r   )boxZvectorr   r   r   get_upcast_box   s    r   c          :   C   s  |t k	r|ntj}| |k}|tj|jtjd}tj|| || k}tj|| | |k}tj||  || k}tj||  djdddddg}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}
    )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   nparrayzerosshapeZbool_tmZassert_equaljoinr   r   r   )r	   r
   r   Zxboxresultexpectedr   r   r   r   assert_invalid_comparison,   s@    r   )N)__doc__numpyr   r   Zpandasr   r   r   Zpandas._testingZ_testingr   r   r   r   r   r   r   r   <module>   s   

