@@ -365,18 +365,14 @@ def test_dt64arr_timestamp_equality(self, box_with_array):
365
365
class TestDatetimeIndexComparisons :
366
366
367
367
# TODO: moved from tests.indexes.test_base; parametrize and de-duplicate
368
- @pytest .mark .parametrize (
369
- "op" ,
370
- [operator .eq , operator .ne , operator .gt , operator .lt , operator .ge , operator .le ],
371
- )
372
- def test_comparators (self , op ):
368
+ def test_comparators (self , comparison_op ):
373
369
index = tm .makeDateIndex (100 )
374
370
element = index [len (index ) // 2 ]
375
371
element = Timestamp (element ).to_datetime64 ()
376
372
377
373
arr = np .array (index )
378
- arr_result = op (arr , element )
379
- index_result = op (index , element )
374
+ arr_result = comparison_op (arr , element )
375
+ index_result = comparison_op (index , element )
380
376
381
377
assert isinstance (index_result , np .ndarray )
382
378
tm .assert_numpy_array_equal (arr_result , index_result )
@@ -554,12 +550,9 @@ def test_dti_cmp_nat_behaves_like_float_cmp_nan(self):
554
550
expected = np .array ([True , True , False , True , True , True ])
555
551
tm .assert_numpy_array_equal (result , expected )
556
552
557
- @pytest .mark .parametrize (
558
- "op" ,
559
- [operator .eq , operator .ne , operator .gt , operator .ge , operator .lt , operator .le ],
560
- )
561
- def test_comparison_tzawareness_compat (self , op , box_with_array ):
553
+ def test_comparison_tzawareness_compat (self , comparison_op , box_with_array ):
562
554
# GH#18162
555
+ op = comparison_op
563
556
box = box_with_array
564
557
565
558
dr = date_range ("2016-01-01" , periods = 6 )
@@ -606,12 +599,10 @@ def test_comparison_tzawareness_compat(self, op, box_with_array):
606
599
assert np .all (np .array (tolist (dz ), dtype = object ) == dz )
607
600
assert np .all (dz == np .array (tolist (dz ), dtype = object ))
608
601
609
- @pytest .mark .parametrize (
610
- "op" ,
611
- [operator .eq , operator .ne , operator .gt , operator .ge , operator .lt , operator .le ],
612
- )
613
- def test_comparison_tzawareness_compat_scalars (self , op , box_with_array ):
602
+ def test_comparison_tzawareness_compat_scalars (self , comparison_op , box_with_array ):
614
603
# GH#18162
604
+ op = comparison_op
605
+
615
606
dr = date_range ("2016-01-01" , periods = 6 )
616
607
dz = dr .tz_localize ("US/Pacific" )
617
608
@@ -638,10 +629,6 @@ def test_comparison_tzawareness_compat_scalars(self, op, box_with_array):
638
629
with pytest .raises (TypeError , match = msg ):
639
630
op (ts , dz )
640
631
641
- @pytest .mark .parametrize (
642
- "op" ,
643
- [operator .eq , operator .ne , operator .gt , operator .ge , operator .lt , operator .le ],
644
- )
645
632
@pytest .mark .parametrize (
646
633
"other" ,
647
634
[datetime (2016 , 1 , 1 ), Timestamp ("2016-01-01" ), np .datetime64 ("2016-01-01" )],
@@ -652,8 +639,9 @@ def test_comparison_tzawareness_compat_scalars(self, op, box_with_array):
652
639
@pytest .mark .filterwarnings ("ignore:elementwise comp:DeprecationWarning" )
653
640
@pytest .mark .filterwarnings ("ignore:Converting timezone-aware:FutureWarning" )
654
641
def test_scalar_comparison_tzawareness (
655
- self , op , other , tz_aware_fixture , box_with_array
642
+ self , comparison_op , other , tz_aware_fixture , box_with_array
656
643
):
644
+ op = comparison_op
657
645
box = box_with_array
658
646
tz = tz_aware_fixture
659
647
dti = date_range ("2016-01-01" , periods = 2 , tz = tz )
@@ -680,13 +668,11 @@ def test_scalar_comparison_tzawareness(
680
668
with pytest .raises (TypeError , match = msg ):
681
669
op (other , dtarr )
682
670
683
- @pytest .mark .parametrize (
684
- "op" ,
685
- [operator .eq , operator .ne , operator .gt , operator .ge , operator .lt , operator .le ],
686
- )
687
- def test_nat_comparison_tzawareness (self , op ):
671
+ def test_nat_comparison_tzawareness (self , comparison_op ):
688
672
# GH#19276
689
673
# tzaware DatetimeIndex should not raise when compared to NaT
674
+ op = comparison_op
675
+
690
676
dti = DatetimeIndex (
691
677
["2014-01-01" , NaT , "2014-03-01" , NaT , "2014-05-01" , "2014-07-01" ]
692
678
)
0 commit comments