Skip to content

TST: Removed import of itertools #32364

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

Conversation

ShaharNaveh
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @MomIsBestFriend generally lgtm ex datetime import.

@@ -1,7 +1,6 @@
import builtins
import datetime as dt
import datetime
Copy link
Member

Choose a reason for hiding this comment

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

can you separate this change into another PR for discussion. (keep this PR as removing itertools)

The reason is that we only have 7 occurrences of import datetime as dt in the codebase and there is some discrepancy between which datetime of datetime.datetime is aliased as dt

The more common pattern is like from datetime import date, datetime, time, timedelta, tzinfo

probably best with these cleanups, is to pick one type of change at a time.

Copy link
Member

Choose a reason for hiding this comment

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

probably best with these cleanups, is to pick one type of change at a time.

and then after appropriate discussion can apply the changes across the complete codebase.

@simonjayhawkins simonjayhawkins added Clean Code Style Code style, linting, code_checks labels Feb 29, 2020
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

a few minor nits, not blockers.

@@ -1296,36 +1307,32 @@ def __eq__(self, other):
# --------------------------------


def test_size(df):
grouped = df.groupby(["A", "B"])
@pytest.mark.parametrize("group_key", ["A", "B", ["A", "B"]])
Copy link
Member

Choose a reason for hiding this comment

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

I think you could just call this by to mirror the parameter name.

grouped = df.groupby(["A", "B"])
@pytest.mark.parametrize("group_key", ["A", "B", ["A", "B"]])
def test_size(df, group_key):
grouped = df.groupby(group_key)
Copy link
Member

Choose a reason for hiding this comment

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

maybe

Suggested change
grouped = df.groupby(group_key)
grouped = df.groupby(by=by)

if you think the parameterisation is not clear.

result = grouped.size()
for key, group in grouped:
assert result[key] == len(group)
@pytest.mark.parametrize("key", ["A", "B", ["A", "B"]])
Copy link
Member

Choose a reason for hiding this comment

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

again use by or be consistent between the two tests.

for key, group in grouped:
assert result[key] == len(group)
@pytest.mark.parametrize("key", ["A", "B", ["A", "B"]])
@pytest.mark.parametrize("sort", [True, False])
Copy link
Member

Choose a reason for hiding this comment

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

This brings the total number of sort parameterizations for [True, False] to 12. so maybe now worth considering creating a fixture for this. (as a follow-up)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that is already a fixture for sort but it's only for [None, False] IIRC.

Copy link
Member

Choose a reason for hiding this comment

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

we can use different fixtures with the same name. The fixture used depends on the directory structure.

we have the relevant fixture in pandas\tests\reshape\test_concat.py, so just needs to be moved.

The sort fixture in pandas\tests\indexes\conftest.py has a caution note. maybe worth adding something like that.

BUT, if you do this, do in a follow-up, not here.

@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Mar 5, 2020
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @MomIsBestFriend lgtm pending green

@simonjayhawkins simonjayhawkins merged commit 8f51c99 into pandas-dev:master Mar 7, 2020
@simonjayhawkins
Copy link
Member

Thanks @MomIsBestFriend

@ShaharNaveh ShaharNaveh deleted the TST-redundent-itertools branch March 7, 2020 12:09
@simonjayhawkins simonjayhawkins mentioned this pull request Mar 7, 2020
5 tasks
SeeminSyed pushed a commit to CSCD01-team01/pandas that referenced this pull request Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants