11from typing import assert_type
22
3+ import numpy as np
34import pandas as pd
45
56from tests import check
@@ -11,94 +12,85 @@ def test_add_py_scalar() -> None:
1112 """Test pd.Series[int] + Python native scalars"""
1213 i , f , c = 1 , 1.0 , 1j
1314
14- check (assert_type (left + i , "pd.Series[int]" ), pd .Series , int )
15- # check(assert_type(left + f, "pd.Series[float]"), pd.Series, float )
16- # check(assert_type(left + c, "pd.Series[complex]"), pd.Series, complex )
15+ check (assert_type (left + i , "pd.Series[int]" ), pd .Series , np . int64 )
16+ check (assert_type (left + f , "pd.Series[float]" ), pd .Series , np . float64 )
17+ check (assert_type (left + c , "pd.Series[complex]" ), pd .Series , np . complex128 )
1718
18- check (assert_type (i + left , "pd.Series[int]" ), pd .Series , int )
19- # check(assert_type(f + left, "pd.Series[float]"), pd.Series, float )
20- # check(assert_type(c + left, "pd.Series[complex]"), pd.Series, complex )
19+ check (assert_type (i + left , "pd.Series[int]" ), pd .Series , np . int64 )
20+ check (assert_type (f + left , "pd.Series[float]" ), pd .Series , np . float64 )
21+ check (assert_type (c + left , "pd.Series[complex]" ), pd .Series , np . complex128 )
2122
22- check (assert_type (left .add (i ), "pd.Series[int]" ), pd .Series , int )
23- # check(assert_type(left.add(f), "pd.Series[float]"), pd.Series, float )
24- # check(assert_type(left.add(c), "pd.Series[complex]"), pd.Series, complex )
23+ check (assert_type (left .add (i ), "pd.Series[int]" ), pd .Series , np . int64 )
24+ check (assert_type (left .add (f ), "pd.Series[float]" ), pd .Series , np . float64 )
25+ check (assert_type (left .add (c ), "pd.Series[complex]" ), pd .Series , np . complex128 )
2526
26- check (assert_type (left .radd (i ), "pd.Series[int]" ), pd .Series , int )
27-
28-
29- # check(assert_type(left.radd(f), "pd.Series[float]"), pd.Series, float)
30- # check(assert_type(left.radd(c), "pd.Series[complex]"), pd.Series, complex)
27+ check (assert_type (left .radd (i ), "pd.Series[int]" ), pd .Series , np .int64 )
28+ check (assert_type (left .radd (f ), "pd.Series[float]" ), pd .Series , np .float64 )
29+ check (assert_type (left .radd (c ), "pd.Series[complex]" ), pd .Series , np .complex128 )
3130
3231
3332def test_add_py_sequence () -> None :
3433 """Test pd.Series[int] + Python native sequence"""
3534 i , f , c = [2 , 3 , 5 ], [1.0 , 2.0 , 3.0 ], [1j , 1j , 4j ]
3635
37- check (assert_type (left + i , "pd.Series[int]" ), pd .Series , int )
38- # check(assert_type(left + f, "pd.Series[float]"), pd.Series, float)
39- # check(assert_type(left + c, "pd.Series[complex]"), pd.Series, complex)
40-
41- # check(assert_type(i + left, "pd.Series[int]"), pd.Series, int)
42- # check(assert_type(f + left, "pd.Series[float]"), pd.Series, float)
43- # check(assert_type(c + left, "pd.Series[complex]"), pd.Series, complex)
36+ check (assert_type (left + i , "pd.Series[int]" ), pd .Series , np .int64 )
37+ check (assert_type (left + f , "pd.Series[float]" ), pd .Series , np .float64 )
38+ check (assert_type (left + c , "pd.Series[complex]" ), pd .Series , np .complex128 )
4439
45- check (assert_type (left .add (i ), "pd.Series[int]" ), pd .Series , int )
40+ check (assert_type (i + left , "pd.Series[int]" ), pd .Series , np .int64 )
41+ check (assert_type (f + left , "pd.Series[float]" ), pd .Series , np .float64 )
42+ check (assert_type (c + left , "pd.Series[complex]" ), pd .Series , np .complex128 )
4643
44+ check (assert_type (left .add (i ), "pd.Series[int]" ), pd .Series , np .int64 )
45+ check (assert_type (left .add (f ), "pd.Series[float]" ), pd .Series , np .float64 )
46+ check (assert_type (left .add (c ), "pd.Series[complex]" ), pd .Series , np .complex128 )
4747
48- # check(assert_type(left.add(f), "pd.Series[float]"), pd.Series, float)
49- # check(assert_type(left.add(c), "pd.Series[complex]"), pd.Series, complex)
48+ check (assert_type (left .radd (i ), "pd.Series[int]" ), pd .Series , np .int64 )
49+ check (assert_type (left .radd (f ), "pd.Series[float]" ), pd .Series , np .float64 )
50+ check (assert_type (left .radd (c ), "pd.Series[complex]" ), pd .Series , np .complex128 )
5051
51- # check(assert_type(left.radd(i), "pd.Series[int]"), pd.Series, int)
52- # check(assert_type(left.radd(f), "pd.Series[int]"), pd.Series, int)
53- # check(assert_type(left.radd(c), "pd.Series[complex]"), pd.Series, complex)
5452
53+ def test_add_numpy_array () -> None :
54+ """Test pd.Series[int] + numpy array"""
55+ i = np .array ([2 , 3 , 5 ], np .int64 )
56+ f = np .array ([1.0 , 2.0 , 3.0 ], np .float64 )
57+ c = np .array ([1.1j , 2.2j , 4.1j ], np .complex128 )
5558
56- # def test_add_numpy_array() -> None:
57- # """Test pd.Series[int] + numpy array"""
58- # i = np.array([2, 3, 5], np.int64)
59- # f = np.array([1.0, 2.0, 3.0], np.float64)
60- # c = np.array([1.1j, 2.2j, 4.1j], np.complex64)
59+ check (assert_type (left + i , "pd.Series[int]" ), pd .Series , np .int64 )
60+ check (assert_type (left + f , "pd.Series[float]" ), pd .Series , np .float64 )
61+ check (assert_type (left + c , "pd.Series[complex]" ), pd .Series , np .complex128 )
6162
62- # check(assert_type(left + i , "pd.Series[int]"), pd.Series, int )
63- # check(assert_type(left + f , "pd.Series[float]"), pd.Series, float )
64- # check(assert_type(left + c , "pd.Series[complex]"), pd.Series, complex )
63+ # check(assert_type(i + l , "pd.Series[int]"), pd.Series, np.int64 )
64+ # check(assert_type(f + l , "pd.Series[float]"), pd.Series, np.float64 )
65+ # check(assert_type(c + l , "pd.Series[complex]"), pd.Series, np.complex128 )
6566
66- # # check(assert_type(i + l , "pd.Series[int]"), pd.Series, int )
67- # # check(assert_type(f + l , "pd.Series[float]"), pd.Series, float )
68- # # check(assert_type(c + l , "pd.Series[complex]"), pd.Series, complex )
67+ check (assert_type (left . add ( i ) , "pd.Series[int]" ), pd .Series , np . int64 )
68+ check (assert_type (left . add ( f ) , "pd.Series[float]" ), pd .Series , np . float64 )
69+ check (assert_type (left . add ( c ) , "pd.Series[complex]" ), pd .Series , np . complex128 )
6970
70- # check(assert_type(left.add(i), "pd.Series[int]"), pd.Series, int)
71- # check(assert_type(left.add(f), "pd.Series[float]"), pd.Series, float)
72- # check(assert_type(left.add(c), "pd.Series[complex]"), pd.Series, complex)
73-
74- # check(assert_type(left.radd(i), "pd.Series[int]"), pd.Series, int)
75- # check(assert_type(left.radd(f), "pd.Series[float]"), pd.Series, float)
76- # check(assert_type(left.radd(c), "pd.Series[complex]"), pd.Series, complex)
71+ check (assert_type (left .radd (i ), "pd.Series[int]" ), pd .Series , np .int64 )
72+ check (assert_type (left .radd (f ), "pd.Series[float]" ), pd .Series , np .float64 )
73+ check (assert_type (left .radd (c ), "pd.Series[complex]" ), pd .Series , np .complex128 )
7774
7875
7976def test_add_pd_series () -> None :
8077 """Test pd.Series[int] + pandas series"""
8178 i = pd .Series ([2 , 3 , 5 ])
82- # f = pd.Series([1.0, 2.0, 3.0])
83- # c = pd.Series([1.1j, 2.2j, 4.1j])
84-
85- check (assert_type (left + i , "pd.Series[int]" ), pd .Series , int )
86- # check(assert_type(left + f, "pd.Series[float]"), pd.Series, float)
87- # check(assert_type(left + c, "pd.Series[complex]"), pd.Series, complex)
88-
89- # check(
90- # assert_type(i + left, pd.Series), "pd.Series[int]"), pd.Series, int)
91- # check(
92- # assert_type(f + left, "pd.Series[float]"), pd.Series, float)
93- # check(
94- # assert_type(c + left, pd.Series), "pd.Series[complex]"), pd.Series, complex)
79+ f = pd .Series ([1.0 , 2.0 , 3.0 ])
80+ c = pd .Series ([1.1j , 2.2j , 4.1j ])
9581
96- check (assert_type (left . add ( i ) , "pd.Series[int]" ), pd .Series , int )
97- # check(assert_type(left.add(f) , "pd.Series[float]"), pd.Series, float )
98- # check(assert_type(left.add(c) , "pd.Series[complex]"), pd.Series, complex )
82+ check (assert_type (left + i , "pd.Series[int]" ), pd .Series , np . int64 )
83+ check (assert_type (left + f , "pd.Series[float]" ), pd .Series , np . float64 )
84+ check (assert_type (left + c , "pd.Series[complex]" ), pd .Series , np . complex128 )
9985
100- check (assert_type (left .radd (i ), "pd.Series[int]" ), pd .Series , int )
86+ check (assert_type (i + left , "pd.Series[int]" ), pd .Series , np .int64 )
87+ check (assert_type (f + left , "pd.Series[float]" ), pd .Series , np .float64 )
88+ check (assert_type (c + left , "pd.Series[complex]" ), pd .Series , np .complex128 )
10189
90+ check (assert_type (left .add (i ), "pd.Series[int]" ), pd .Series , np .int64 )
91+ check (assert_type (left .add (f ), "pd.Series[float]" ), pd .Series , np .float64 )
92+ check (assert_type (left .add (c ), "pd.Series[complex]" ), pd .Series , np .complex128 )
10293
103- # check(assert_type(left.radd(f), "pd.Series[float]"), pd.Series, float)
104- # check(assert_type(left.radd(c), "pd.Series[complex]"), pd.Series, complex)
94+ check (assert_type (left .radd (i ), "pd.Series[int]" ), pd .Series , np .int64 )
95+ check (assert_type (left .radd (f ), "pd.Series[float]" ), pd .Series , np .float64 )
96+ check (assert_type (left .radd (c ), "pd.Series[complex]" ), pd .Series , np .complex128 )
0 commit comments