17
17
18
18
from .test_floats import gen_obj
19
19
20
-
21
- def getitem (x ):
22
- return x
23
-
24
-
25
- def setitem (x ):
26
- return x
27
-
28
-
29
- def loc (x ):
30
- return x .loc
31
-
32
-
33
- def iloc (x ):
34
- return x .iloc
35
-
36
-
37
20
# ------------------------------------------------------------------------
38
21
# Indexing test cases
39
22
@@ -72,7 +55,7 @@ def test_setitem_ndarray_1d(self):
72
55
with pytest .raises (ValueError , match = msg ):
73
56
df [2 :5 ] = np .arange (1 , 4 ) * 1j
74
57
75
- @pytest .mark .parametrize ("idxr" , [getitem , loc , iloc ])
58
+ @pytest .mark .parametrize ("idxr" , [tm . getitem , tm . loc , tm . iloc ])
76
59
def test_getitem_ndarray_3d (self , index , frame_or_series , idxr ):
77
60
# GH 25567
78
61
obj = gen_obj (frame_or_series , index )
@@ -95,7 +78,7 @@ def test_getitem_ndarray_3d(self, index, frame_or_series, idxr):
95
78
with tm .assert_produces_warning (DeprecationWarning , check_stacklevel = False ):
96
79
idxr [nd3 ]
97
80
98
- @pytest .mark .parametrize ("indexer" , [setitem , loc , iloc ])
81
+ @pytest .mark .parametrize ("indexer" , [tm . setitem , tm . loc , tm . iloc ])
99
82
def test_setitem_ndarray_3d (self , index , frame_or_series , indexer ):
100
83
# GH 25567
101
84
obj = gen_obj (frame_or_series , index )
@@ -297,7 +280,7 @@ def test_dups_fancy_indexing2(self):
297
280
result = df .loc [[1 , 2 ], ["a" , "b" ]]
298
281
tm .assert_frame_equal (result , expected )
299
282
300
- @pytest .mark .parametrize ("case" , [getitem , loc ])
283
+ @pytest .mark .parametrize ("case" , [tm . getitem , tm . loc ])
301
284
def test_duplicate_int_indexing (self , case ):
302
285
# GH 17347
303
286
s = Series (range (3 ), index = [1 , 1 , 3 ])
@@ -592,7 +575,7 @@ def test_astype_assignment(self):
592
575
expected = DataFrame ({"A" : [1 , 2 , 3 , 4 ]})
593
576
tm .assert_frame_equal (df , expected )
594
577
595
- @pytest .mark .parametrize ("indexer" , [getitem , loc ])
578
+ @pytest .mark .parametrize ("indexer" , [tm . getitem , tm . loc ])
596
579
def test_index_type_coercion (self , indexer ):
597
580
598
581
# GH 11836
@@ -965,7 +948,7 @@ def test_none_coercion_mixed_dtypes(self):
965
948
966
949
967
950
class TestDatetimelikeCoercion :
968
- @pytest .mark .parametrize ("indexer" , [setitem , loc , iloc ])
951
+ @pytest .mark .parametrize ("indexer" , [tm . setitem , tm . loc , tm . iloc ])
969
952
def test_setitem_dt64_string_scalar (self , tz_naive_fixture , indexer ):
970
953
# dispatching _can_hold_element to underling DatetimeArray
971
954
tz = tz_naive_fixture
@@ -991,12 +974,12 @@ def test_setitem_dt64_string_scalar(self, tz_naive_fixture, indexer):
991
974
@pytest .mark .parametrize (
992
975
"key" , [[0 , 1 ], slice (0 , 2 ), np .array ([True , True , False ])]
993
976
)
994
- @pytest .mark .parametrize ("indexer" , [setitem , loc , iloc ])
977
+ @pytest .mark .parametrize ("indexer" , [tm . setitem , tm . loc , tm . iloc ])
995
978
def test_setitem_dt64_string_values (self , tz_naive_fixture , indexer , key , box ):
996
979
# dispatching _can_hold_element to underling DatetimeArray
997
980
tz = tz_naive_fixture
998
981
999
- if isinstance (key , slice ) and indexer is loc :
982
+ if isinstance (key , slice ) and indexer is tm . loc :
1000
983
key = slice (0 , 1 )
1001
984
1002
985
dti = date_range ("2016-01-01" , periods = 3 , tz = tz )
@@ -1017,7 +1000,7 @@ def test_setitem_dt64_string_values(self, tz_naive_fixture, indexer, key, box):
1017
1000
assert ser ._values is values
1018
1001
1019
1002
@pytest .mark .parametrize ("scalar" , ["3 Days" , offsets .Hour (4 )])
1020
- @pytest .mark .parametrize ("indexer" , [setitem , loc , iloc ])
1003
+ @pytest .mark .parametrize ("indexer" , [tm . setitem , tm . loc , tm . iloc ])
1021
1004
def test_setitem_td64_scalar (self , indexer , scalar ):
1022
1005
# dispatching _can_hold_element to underling TimedeltaArray
1023
1006
tdi = timedelta_range ("1 Day" , periods = 3 )
@@ -1033,10 +1016,10 @@ def test_setitem_td64_scalar(self, indexer, scalar):
1033
1016
@pytest .mark .parametrize (
1034
1017
"key" , [[0 , 1 ], slice (0 , 2 ), np .array ([True , True , False ])]
1035
1018
)
1036
- @pytest .mark .parametrize ("indexer" , [setitem , loc , iloc ])
1019
+ @pytest .mark .parametrize ("indexer" , [tm . setitem , tm . loc , tm . iloc ])
1037
1020
def test_setitem_td64_string_values (self , indexer , key , box ):
1038
1021
# dispatching _can_hold_element to underling TimedeltaArray
1039
- if isinstance (key , slice ) and indexer is loc :
1022
+ if isinstance (key , slice ) and indexer is tm . loc :
1040
1023
key = slice (0 , 1 )
1041
1024
1042
1025
tdi = timedelta_range ("1 Day" , periods = 3 )
0 commit comments