43
43
from pandas .tests .arithmetic .common import (
44
44
assert_invalid_addsub_type ,
45
45
assert_invalid_comparison ,
46
- get_expected_box ,
47
46
get_upcast_box ,
48
47
)
49
48
@@ -60,12 +59,12 @@ def test_compare_zerodim(self, tz_naive_fixture, box_with_array):
60
59
# Test comparison with zero-dimensional array is unboxed
61
60
tz = tz_naive_fixture
62
61
box = box_with_array
63
- xbox = get_expected_box (box )
64
62
dti = date_range ("20130101" , periods = 3 , tz = tz )
65
63
66
64
other = np .array (dti .to_numpy ()[0 ])
67
65
68
66
dtarr = tm .box_expected (dti , box )
67
+ xbox = get_upcast_box (dtarr , other , True )
69
68
result = dtarr <= other
70
69
expected = np .array ([True , False , False ])
71
70
expected = tm .box_expected (expected , xbox )
@@ -147,12 +146,12 @@ def test_dt64arr_nat_comparison(self, tz_naive_fixture, box_with_array):
147
146
# GH#22242, GH#22163 DataFrame considered NaT == ts incorrectly
148
147
tz = tz_naive_fixture
149
148
box = box_with_array
150
- xbox = get_expected_box (box )
151
149
152
150
ts = Timestamp .now (tz )
153
151
ser = Series ([ts , NaT ])
154
152
155
153
obj = tm .box_expected (ser , box )
154
+ xbox = get_upcast_box (obj , ts , True )
156
155
157
156
expected = Series ([True , False ], dtype = np .bool_ )
158
157
expected = tm .box_expected (expected , xbox )
@@ -244,10 +243,9 @@ def test_nat_comparisons_scalar(self, dtype, data, box_with_array):
244
243
# on older numpys (since they check object identity)
245
244
return
246
245
247
- xbox = get_expected_box (box )
248
-
249
246
left = Series (data , dtype = dtype )
250
247
left = tm .box_expected (left , box )
248
+ xbox = get_upcast_box (left , NaT , True )
251
249
252
250
expected = [False , False , False ]
253
251
expected = tm .box_expected (expected , xbox )
@@ -323,10 +321,10 @@ def test_timestamp_compare_series(self, left, right):
323
321
324
322
def test_dt64arr_timestamp_equality (self , box_with_array ):
325
323
# GH#11034
326
- xbox = get_expected_box (box_with_array )
327
324
328
325
ser = Series ([Timestamp ("2000-01-29 01:59:00" ), Timestamp ("2000-01-30" ), NaT ])
329
326
ser = tm .box_expected (ser , box_with_array )
327
+ xbox = get_upcast_box (ser , ser , True )
330
328
331
329
result = ser != ser
332
330
expected = tm .box_expected ([False , False , True ], xbox )
@@ -417,13 +415,12 @@ def test_dti_cmp_nat(self, dtype, box_with_array):
417
415
# on older numpys (since they check object identity)
418
416
return
419
417
420
- xbox = get_expected_box (box_with_array )
421
-
422
418
left = DatetimeIndex ([Timestamp ("2011-01-01" ), NaT , Timestamp ("2011-01-03" )])
423
419
right = DatetimeIndex ([NaT , NaT , Timestamp ("2011-01-03" )])
424
420
425
421
left = tm .box_expected (left , box_with_array )
426
422
right = tm .box_expected (right , box_with_array )
423
+ xbox = get_upcast_box (left , right , True )
427
424
428
425
lhs , rhs = left , right
429
426
if dtype is object :
@@ -642,12 +639,11 @@ def test_scalar_comparison_tzawareness(
642
639
self , comparison_op , other , tz_aware_fixture , box_with_array
643
640
):
644
641
op = comparison_op
645
- box = box_with_array
646
642
tz = tz_aware_fixture
647
643
dti = date_range ("2016-01-01" , periods = 2 , tz = tz )
648
- xbox = get_expected_box (box )
649
644
650
645
dtarr = tm .box_expected (dti , box_with_array )
646
+ xbox = get_upcast_box (dtarr , other , True )
651
647
if op in [operator .eq , operator .ne ]:
652
648
exbool = op is operator .ne
653
649
expected = np .array ([exbool , exbool ], dtype = bool )
@@ -2421,14 +2417,13 @@ def test_dti_addsub_offset_arraylike(
2421
2417
self , tz_naive_fixture , names , op , index_or_series
2422
2418
):
2423
2419
# GH#18849, GH#19744
2424
- box = pd .Index
2425
2420
other_box = index_or_series
2426
2421
2427
2422
tz = tz_naive_fixture
2428
2423
dti = date_range ("2017-01-01" , periods = 2 , tz = tz , name = names [0 ])
2429
2424
other = other_box ([pd .offsets .MonthEnd (), pd .offsets .Day (n = 2 )], name = names [1 ])
2430
2425
2431
- xbox = get_upcast_box (box , other )
2426
+ xbox = get_upcast_box (dti , other )
2432
2427
2433
2428
with tm .assert_produces_warning (PerformanceWarning ):
2434
2429
res = op (dti , other )
@@ -2448,7 +2443,7 @@ def test_dti_addsub_object_arraylike(
2448
2443
dti = date_range ("2017-01-01" , periods = 2 , tz = tz )
2449
2444
dtarr = tm .box_expected (dti , box_with_array )
2450
2445
other = other_box ([pd .offsets .MonthEnd (), Timedelta (days = 4 )])
2451
- xbox = get_upcast_box (box_with_array , other )
2446
+ xbox = get_upcast_box (dtarr , other )
2452
2447
2453
2448
expected = DatetimeIndex (["2017-01-31" , "2017-01-06" ], tz = tz_naive_fixture )
2454
2449
expected = tm .box_expected (expected , xbox )
0 commit comments