zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
U
¬ý°dã@sxdZddlZddlZddlmZmZmZmZddl    m
Z ddl m Z mZddd„Zddd    „Zded œd d „Zdd„ZdS)z)
Assertion helpers for arithmetic tests.
éN)Ú    DataFrameÚIndexÚSeriesÚarray)Ú BooleanArrayÚ PandasArrayú
cannot addc    CsHtjt|d||W5QRXtjt|d||W5QRXdS)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úUd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/arithmetic/common.pyÚassert_cannot_adds
rc    CsŒtjt|d||W5QRXtjt|d||W5QRXtjt|d||W5QRXtjt|d||W5QRXdS)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 rrrrÚassert_invalid_addsub_type$s
rF)Úis_cmpcCslt|tƒst|tƒrtSt|tƒs,t|tƒrD|r@t|tƒr@tjStSt|tƒsXt|tƒrf|rbtjStStjS)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.
    )Ú
isinstancerrrÚnprÚtmZto_array)rrrrrrÚget_upcast_box8s rc        Csæ|ttfkr|ntj}dd„}|}t|tƒr<t|tƒr<tj}|||kƒ}|tj|jtjdƒ}t     ||¡|||kƒ}t     |||ƒ¡|||kƒ}t     ||¡|||kƒ}t     |||ƒ¡d 
ddddd    g¡}t j t |d
||kW5QRXt j t |d
||kW5QRXt j t |d
||kW5QRXt j t |d
||kW5QRXt j t |d
||kW5QRXt j t |d
||kW5QRXt j t |d
||kW5QRXt j t |d
||kW5QRXd 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}
    cSs(t|tƒr|jSt|tƒr$| t¡S|S)N)rrZ_ndarrayrZastypeÚbool)ÚxrrrÚxbox2`s
 
 
 
z(assert_invalid_comparison.<locals>.xbox2)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)rrrrrÚzerosÚshapeZbool_rZ assert_equalÚjoinr r r)    rrZboxZxboxrZrev_boxÚresultÚexpectedrrrrÚassert_invalid_comparisonQsL       ùÿr%)r)N)F)Ú__doc__Únumpyrr ZpandasrrrrZpandas._testingZ_testingrZpandas.core.arraysrrrrrrr%rrrrÚ<module>s