Skip to content

CLN: Remove some duplicated tests and parametrize #39960

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

Merged
merged 4 commits into from
Feb 22, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented Feb 21, 2021

  • Ensure all linting tests pass, see here for how to run them

There were a few duplicates from the ix removal

@phofl phofl added Clean Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite labels Feb 21, 2021
@@ -35,28 +35,12 @@


class TestiLoc(Base):
def test_iloc_getitem_int(self):
@pytest.mark.parametrize("key", [2, -1, [0, 1, 2]])
def test_iloc_getitem_int(self, key):
Copy link
Member

Choose a reason for hiding this comment

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

rename since it is no longer just int keys?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -762,7 +756,8 @@ def test_loc_coercion(self):
result = df.iloc[3:]
tm.assert_series_equal(result.dtypes, expected)

def test_setitem_new_key_tz(self):
@pytest.mark.parametrize("indexer", [tm.setitem, tm.loc])
Copy link
Member

Choose a reason for hiding this comment

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

fixture for this is indexer_sl

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, did not know that

timedelta_range(start="1 day", end="2 days", freq="1H"),
],
)
def test_loc_getitem_label_slice_period(self, ix):
Copy link
Member

Choose a reason for hiding this comment

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

rename to not period-specific?

is there a corresponding dt64 test that should be rolled into this?

call it index instead of ix?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -507,30 +507,22 @@ def test_floating_misc(self):
# label based slicing
result1 = s[1.0:3.0]
result2 = s.loc[1.0:3.0]
result3 = s.loc[1.0:3.0]
Copy link
Member

Choose a reason for hiding this comment

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

not necessarily for this PR, but i think this test can be parametrized over indexer_sl

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good point. Was too focused on the duplicates :)

@@ -498,122 +498,72 @@ def test_floating_index_doc_example(self):
assert s.loc[3] == 2
assert s.iloc[3] == 3

def test_floating_misc(self):
@pytest.mark.parametrize("indexer_sl", [tm.getitem, tm.loc])
Copy link
Member

Choose a reason for hiding this comment

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

you dont need to parametrize since indexer_sl is a fixture

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, did not get that :(

@@ -762,7 +756,8 @@ def test_loc_coercion(self):
result = df.iloc[3:]
tm.assert_series_equal(result.dtypes, expected)

def test_setitem_new_key_tz(self):
@pytest.mark.parametrize("indexer_sl", [tm.setitem, tm.loc])
Copy link
Member

Choose a reason for hiding this comment

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

ditto, indexer_sl is a fixture

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@jbrockmendel
Copy link
Member

couple comments, ping on green

@phofl
Copy link
Member Author

phofl commented Feb 22, 2021

ping @jbrockmendel green

@jbrockmendel jbrockmendel merged commit 2f73c7a into pandas-dev:master Feb 22, 2021
@jbrockmendel
Copy link
Member

thanks @phofl

@phofl phofl deleted the CLN_loc_tests branch February 22, 2021 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants