3
®ybc  ã               @   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   úB/tmp/pip-install-4cy230dp/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 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Ú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__Znumpyr   r   Zpandasr   r   r   Zpandas._testingZ_testingr   r   r   r   r   r   r   r   Ú<module>   s   

