Skip to content

Commit 68e5b4c

Browse files
authored
CLN: Clean indexing tests (#37689)
1 parent 84bee25 commit 68e5b4c

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

pandas/tests/indexing/test_iloc.py

-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ def test_iloc_mask(self):
615615
# UserWarnings from reindex of a boolean mask
616616
with catch_warnings(record=True):
617617
simplefilter("ignore", UserWarning)
618-
result = dict()
619618
for idx in [None, "index", "locs"]:
620619
mask = (df.nums > 2).values
621620
if idx:

pandas/tests/indexing/test_indexing.py

+1
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ def test_maybe_numeric_slice(self):
843843

844844
result = maybe_numeric_slice(df, None, include_bool=True)
845845
expected = pd.IndexSlice[:, ["A", "C"]]
846+
assert all(result[1] == expected[1])
846847
result = maybe_numeric_slice(df, [1])
847848
expected = [1]
848849
assert result == expected

pandas/tests/indexing/test_loc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,8 @@ def test_loc_setitem_multiindex_slice(self):
11911191
def test_loc_getitem_slice_datetime_objs_with_datetimeindex(self):
11921192
times = date_range("2000-01-01", freq="10min", periods=100000)
11931193
ser = Series(range(100000), times)
1194-
ser.loc[datetime(1900, 1, 1) : datetime(2100, 1, 1)]
1194+
result = ser.loc[datetime(1900, 1, 1) : datetime(2100, 1, 1)]
1195+
tm.assert_series_equal(result, ser)
11951196

11961197

11971198
class TestLocSetitemWithExpansion:

pandas/tests/indexing/test_partial.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ def test_series_partial_set(self):
185185
# loc equiv to .reindex
186186
expected = Series([np.nan, 0.2, np.nan], index=[3, 2, 3])
187187
with pytest.raises(KeyError, match="with any missing labels"):
188-
result = ser.loc[[3, 2, 3]]
188+
ser.loc[[3, 2, 3]]
189189

190190
result = ser.reindex([3, 2, 3])
191191
tm.assert_series_equal(result, expected, check_index_type=True)
192192

193193
expected = Series([np.nan, 0.2, np.nan, np.nan], index=[3, 2, 3, "x"])
194194
with pytest.raises(KeyError, match="with any missing labels"):
195-
result = ser.loc[[3, 2, 3, "x"]]
195+
ser.loc[[3, 2, 3, "x"]]
196196

197197
result = ser.reindex([3, 2, 3, "x"])
198198
tm.assert_series_equal(result, expected, check_index_type=True)
@@ -203,7 +203,7 @@ def test_series_partial_set(self):
203203

204204
expected = Series([0.2, 0.2, np.nan, 0.1], index=[2, 2, "x", 1])
205205
with pytest.raises(KeyError, match="with any missing labels"):
206-
result = ser.loc[[2, 2, "x", 1]]
206+
ser.loc[[2, 2, "x", 1]]
207207

208208
result = ser.reindex([2, 2, "x", 1])
209209
tm.assert_series_equal(result, expected, check_index_type=True)

0 commit comments

Comments
 (0)