@@ -70,19 +70,17 @@ def test_copy_and_deepcopy(self, indices):
70
70
def test_constructor_regular (self , indices ):
71
71
tm .assert_contains_all (indices , indices )
72
72
73
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
74
- def test_constructor_casting (self , indices ):
73
+ def test_constructor_casting (self , string_index ):
75
74
# casting
76
- arr = np .array (indices )
75
+ arr = np .array (string_index )
77
76
new_index = Index (arr )
78
77
tm .assert_contains_all (arr , new_index )
79
- tm .assert_index_equal (indices , new_index )
78
+ tm .assert_index_equal (string_index , new_index )
80
79
81
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
82
- def test_constructor_copy (self , indices ):
80
+ def test_constructor_copy (self , string_index ):
83
81
# copy
84
82
# index = self.create_index()
85
- arr = np .array (indices )
83
+ arr = np .array (string_index )
86
84
new_index = Index (arr , copy = True , name = "name" )
87
85
assert isinstance (new_index , Index )
88
86
assert new_index .name == "name"
@@ -629,17 +627,16 @@ def test_nanosecond_index_access(self):
629
627
expected_ts = np_datetime64_compat ("2013-01-01 00:00:00.000000050+0000" , "ns" )
630
628
assert first_value == x [Timestamp (expected_ts )]
631
629
632
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
633
- def test_booleanindex (self , indices ):
634
- bool_index = np .ones (len (indices ), dtype = bool )
630
+ def test_booleanindex (self , string_index ):
631
+ bool_index = np .ones (len (string_index ), dtype = bool )
635
632
bool_index [5 :30 :2 ] = False
636
633
637
- sub_index = indices [bool_index ]
634
+ sub_index = string_index [bool_index ]
638
635
639
636
for i , val in enumerate (sub_index ):
640
637
assert sub_index .get_loc (val ) == i
641
638
642
- sub_index = indices [list (bool_index )]
639
+ sub_index = string_index [list (bool_index )]
643
640
for i , val in enumerate (sub_index ):
644
641
assert sub_index .get_loc (val ) == i
645
642
@@ -671,10 +668,9 @@ def test_empty_fancy_raises(self, indices):
671
668
with pytest .raises (IndexError , match = msg ):
672
669
indices [empty_farr ]
673
670
674
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
675
- def test_intersection (self , indices , sort ):
676
- first = indices [:20 ]
677
- second = indices [:10 ]
671
+ def test_intersection (self , string_index , sort ):
672
+ first = string_index [:20 ]
673
+ second = string_index [:10 ]
678
674
intersect = first .intersection (second , sort = sort )
679
675
if sort is None :
680
676
tm .assert_index_equal (intersect , second .sort_values ())
@@ -703,16 +699,15 @@ def test_intersection_name_preservation(self, index2, keeps_name, sort):
703
699
assert result .name == expected .name
704
700
tm .assert_index_equal (result , expected )
705
701
706
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
707
702
@pytest .mark .parametrize (
708
703
"first_name,second_name,expected_name" ,
709
704
[("A" , "A" , "A" ), ("A" , "B" , None ), (None , "B" , None )],
710
705
)
711
706
def test_intersection_name_preservation2 (
712
- self , indices , first_name , second_name , expected_name , sort
707
+ self , string_index , first_name , second_name , expected_name , sort
713
708
):
714
- first = indices [5 :20 ]
715
- second = indices [:10 ]
709
+ first = string_index [5 :20 ]
710
+ second = string_index [:10 ]
716
711
first .name = first_name
717
712
second .name = second_name
718
713
intersect = first .intersection (second , sort = sort )
@@ -782,11 +777,10 @@ def test_chained_union(self, sort):
782
777
expected = j1 .union (j2 , sort = sort ).union (j3 , sort = sort )
783
778
tm .assert_index_equal (union , expected )
784
779
785
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
786
- def test_union (self , indices , sort ):
787
- first = indices [5 :20 ]
788
- second = indices [:10 ]
789
- everything = indices [:20 ]
780
+ def test_union (self , string_index , sort ):
781
+ first = string_index [5 :20 ]
782
+ second = string_index [:10 ]
783
+ everything = string_index [:20 ]
790
784
791
785
union = first .union (second , sort = sort )
792
786
if sort is None :
@@ -820,22 +814,20 @@ def test_union_sort_special_true(self, slice_):
820
814
tm .assert_index_equal (result , expected )
821
815
822
816
@pytest .mark .parametrize ("klass" , [np .array , Series , list ])
823
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
824
- def test_union_from_iterables (self , indices , klass , sort ):
817
+ def test_union_from_iterables (self , string_index , klass , sort ):
825
818
# GH 10149
826
- first = indices [5 :20 ]
827
- second = indices [:10 ]
828
- everything = indices [:20 ]
819
+ first = string_index [5 :20 ]
820
+ second = string_index [:10 ]
821
+ everything = string_index [:20 ]
829
822
830
823
case = klass (second .values )
831
824
result = first .union (case , sort = sort )
832
825
if sort is None :
833
826
tm .assert_index_equal (result , everything .sort_values ())
834
827
assert tm .equalContents (result , everything )
835
828
836
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
837
- def test_union_identity (self , indices , sort ):
838
- first = indices [5 :20 ]
829
+ def test_union_identity (self , string_index , sort ):
830
+ first = string_index [5 :20 ]
839
831
840
832
union = first .union (first , sort = sort )
841
833
# i.e. identity is not preserved when sort is True
@@ -1004,12 +996,13 @@ def test_append_empty_preserve_name(self, name, expected):
1004
996
result = left .append (right )
1005
997
assert result .name == expected
1006
998
1007
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
1008
999
@pytest .mark .parametrize ("second_name,expected" , [(None , None ), ("name" , "name" )])
1009
- def test_difference_name_preservation (self , indices , second_name , expected , sort ):
1010
- first = indices [5 :20 ]
1011
- second = indices [:10 ]
1012
- answer = indices [10 :20 ]
1000
+ def test_difference_name_preservation (
1001
+ self , string_index , second_name , expected , sort
1002
+ ):
1003
+ first = string_index [5 :20 ]
1004
+ second = string_index [:10 ]
1005
+ answer = string_index [10 :20 ]
1013
1006
1014
1007
first .name = "name"
1015
1008
second .name = second_name
@@ -1022,31 +1015,28 @@ def test_difference_name_preservation(self, indices, second_name, expected, sort
1022
1015
else :
1023
1016
assert result .name == expected
1024
1017
1025
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
1026
- def test_difference_empty_arg (self , indices , sort ):
1027
- first = indices [5 :20 ]
1018
+ def test_difference_empty_arg (self , string_index , sort ):
1019
+ first = string_index [5 :20 ]
1028
1020
first .name = "name"
1029
1021
result = first .difference ([], sort )
1030
1022
1031
1023
assert tm .equalContents (result , first )
1032
1024
assert result .name == first .name
1033
1025
1034
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
1035
- def test_difference_identity (self , indices , sort ):
1036
- first = indices [5 :20 ]
1026
+ def test_difference_identity (self , string_index , sort ):
1027
+ first = string_index [5 :20 ]
1037
1028
first .name = "name"
1038
1029
result = first .difference (first , sort )
1039
1030
1040
1031
assert len (result ) == 0
1041
1032
assert result .name == first .name
1042
1033
1043
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
1044
- def test_difference_sort (self , indices , sort ):
1045
- first = indices [5 :20 ]
1046
- second = indices [:10 ]
1034
+ def test_difference_sort (self , string_index , sort ):
1035
+ first = string_index [5 :20 ]
1036
+ second = string_index [:10 ]
1047
1037
1048
1038
result = first .difference (second , sort )
1049
- expected = indices [10 :20 ]
1039
+ expected = string_index [10 :20 ]
1050
1040
1051
1041
if sort is None :
1052
1042
expected = expected .sort_values ()
@@ -1866,10 +1856,9 @@ def test_boolean_cmp(self, values):
1866
1856
1867
1857
tm .assert_numpy_array_equal (result , expected )
1868
1858
1869
- @pytest .mark .parametrize ("indices" , ["string" ], indirect = True )
1870
1859
@pytest .mark .parametrize ("name,level" , [(None , 0 ), ("a" , "a" )])
1871
- def test_get_level_values (self , indices , name , level ):
1872
- expected = indices .copy ()
1860
+ def test_get_level_values (self , string_index , name , level ):
1861
+ expected = string_index .copy ()
1873
1862
if name :
1874
1863
expected .name = name
1875
1864
0 commit comments