o
    Û­j
  ã                   @   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defdd„Zdd„ ZdS )z)
Assertion helpers for arithmetic tests.
é    N)Ú	DataFrameÚIndexÚSeriesÚarray)ÚBooleanArrayÚNumpyExtensionArrayú
cannot addc                 C   sr   t jt|d�� | |  W d  ƒ n1 sw   Y  t jt|d�� ||   W d  ƒ dS 1 s2w   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   ú[/var/www/html/CropPilot/venv/lib/python3.10/site-packages/pandas/tests/arithmetic/common.pyÚassert_cannot_add   s   

ÿ
"ÿr   c                 C   sÞ   t jt|d�� | |  W d  ƒ n1 sw   Y  t jt|d�� ||   W d  ƒ n1 s1w   Y  t jt|d�� | |  W d  ƒ n1 sLw   Y  t jt|d�� ||   W d  ƒ dS 1 shw   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ƒr"|r t | tƒr tjS tS t | tƒs,t |tƒr3|r1t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   ÚtmÚ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 s|w   Y  tjt|d�� | |k W d  ƒ n1 s—w   Y  tjt|d�� | |k W d  ƒ n1 s²w   Y  tjt|d�� | |k W d  ƒ n1 sÍw   Y  tjt|d�� || k  W d  ƒ n1 sèw   Y  tjt|d�� || k W d  ƒ n	1 �sw   Y  tjt|d�� || k W d  ƒ n	1 �s w   Y  tjt|d�� || k W d  ƒ dS 1 �s=w   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   Ú_ndarrayr   ÚastypeÚbool)Úxr   r   r   Úxbox2`   s
   


z(assert_invalid_comparison.<locals>.xbox2)Ú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   r   r   r   r   ÚzerosÚshapeÚbool_r   Úassert_equalÚjoinr   r   r   )	r   r   ÚboxÚxboxr"   Úrev_boxÚresultÚexpectedr   r   r   r   Úassert_invalid_comparisonQ   sR   ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
ÿ
$ÿr/   )r   r   )F)Ú__doc__Únumpyr   r   Úpandasr   r   r   r   Úpandas._testingÚ_testingr   Úpandas.core.arraysr   r   r   r   r    r   r/   r   r   r   r   Ú<module>   s    

