Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: Clean indexing tests #37689

Merged
merged 2 commits into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ def test_iloc_mask(self):
# UserWarnings from reindex of a boolean mask
with catch_warnings(record=True):
simplefilter("ignore", UserWarning)
result = dict()
for idx in [None, "index", "locs"]:
mask = (df.nums > 2).values
if idx:
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ def test_maybe_numeric_slice(self):

result = maybe_numeric_slice(df, None, include_bool=True)
expected = pd.IndexSlice[:, ["A", "C"]]
assert all(result[1] == expected[1])
result = maybe_numeric_slice(df, [1])
expected = [1]
assert result == expected
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,9 @@ def test_loc_setitem_multiindex_slice(self):
def test_loc_getitem_slice_datetime_objs_with_datetimeindex(self):
times = date_range("2000-01-01", freq="10min", periods=100000)
ser = Series(range(100000), times)
ser.loc[datetime(1900, 1, 1) : datetime(2100, 1, 1)]
result = ser.loc[datetime(1900, 1, 1) : datetime(2100, 1, 1)]
expected = Series(range(100000), times)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant you just use expected = ser?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, changed it. Was not sure if it would be better to redefine the expected value

tm.assert_series_equal(result, expected)


class TestLocSetitemWithExpansion:
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexing/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ def test_series_partial_set(self):
# loc equiv to .reindex
expected = Series([np.nan, 0.2, np.nan], index=[3, 2, 3])
with pytest.raises(KeyError, match="with any missing labels"):
result = ser.loc[[3, 2, 3]]
ser.loc[[3, 2, 3]]

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

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

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

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

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