B @` @sbdZddlZddlZddlmZmZmZmZ ddl m Z ddl mZd ddZddZd d ZdS) z) Assertion helpers for arithmetic tests. N) DataFrameIndexSeriesarray) PandasArrayc Cstjt|d||WdQRXtjt|d||WdQRXtjt|d||WdQRXtjt|d||WdQRXdS)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)pytestraises TypeError)leftrightmsgrB/tmp/pip-unpacked-wheel-q9tj5l6a/pandas/tests/arithmetic/common.pyassert_invalid_addsub_type s rcCsF|tkst|trtS|tks(t|tr,tS|tks>t|trBtS|S)z? Given two box-types, find the one that takes priority )r isinstancerr)boxZvectorrrrget_upcast_box src Cs|ttgkr|ntj}dd}|||k}|tj|jtjd}t|||||k}t|||||k}t|||||k}t||d ddddd g}t j t |d ||kWd QRXt j t |d ||kWd QRXt j t |d ||kWd QRXt j t |d ||kWd QRXt j t |d ||kWd QRXt j t |d ||kWd QRXt j t |d ||kWd QRXt j t |d ||kWd QRXd 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} cSst|tr|jS|S)N)rrZ_ndarray)xrrrxbox2<s z(assert_invalid_comparison..xbox2)Zdtype|zInvalid comparison betweenzCannot compare typeznot supported betweenzinvalid type promotionzThe DTypes and do not have a common DType. For example they cannot be stored in a single array unless the dtype is `object`.)rN) rpd_arraynprzerosshapeZbool_tmZ assert_equaljoinrr r )r r rZxboxrresultexpectedr rrrassert_invalid_comparison-sB       r)N)__doc__ZnumpyrrZpandasrrrrrZpandas._testingZ_testingrZpandas.core.arraysrrrrrrrrs