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: res/exp and GH references in frame tests #22730

Merged
merged 14 commits into from
Oct 8, 2018

Conversation

h-vetinari
Copy link
Contributor

@h-vetinari h-vetinari commented Sep 17, 2018

EDIT2: reverted import-related clean-up due to #22730 (comment)

EDIT: after review by @WillAyd, the fixturization was split out to #22735, #22736 and #22738. Now contains only the following clean-ups, also for #22733:

Original post below. [END EDIT]

I split the commits per module, and (where possible) into fixturizing and cleaning up the imports. Other notes:

  • For test_apply, I added an another often-used fixture
  • In translating the quasi-fixtures from TestData to conftest in TST/CLN: break up & parametrize tests for df.set_index #22236, I sorted the dtypes for the columns of mixed_float_frame and mixed_int_frame, which turns out to have been a mistake. This is reverted here to be a true translation of the attribute of TestData. Otherwise, tests in the newly fixturized test_arithmetic.py would fail.

En passant, I also unified GH issue references.

@pep8speaks
Copy link

Hello @h-vetinari! Thanks for submitting the PR.

@h-vetinari
Copy link
Contributor Author

Can't figure out ATM why pytest cannot find some of the fixtures. Everything works fine locally...

@h-vetinari
Copy link
Contributor Author

I reverted the changes in test_api for now, because I couldn't get SharedWithSparse to work for tests/sparse/frame/test_frame.py, even with a new conftest.py there. It's nevertheless interesting that some builds (https://travis-ci.org/pandas-dev/pandas/jobs/429371967, https://circleci.com/gh/pandas-dev/pandas/20582) worked out. Not sure if those jobs are skipping sparse tests...?

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

There's quite a few orthogonal changes mixed in here which I don't necessarily disagree with but as always it's much easier to logically separate the changes being made. Please keep this one focused on just implementing fixtures.

Cleaning up name-spacing and comments are fine but if you want to do them should be done in separate PRs dedicated to that task. If you can remove from this change will take another look

@@ -70,9 +82,10 @@ def mixed_float_frame():
Columns are ['A', 'B', 'C', 'D'].
"""
df = DataFrame(tm.getSeriesData())
df.A = df.A.astype('float16')
df.A = df.A.astype('float32')
Copy link
Member

Choose a reason for hiding this comment

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

What's the reasoning for changing these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See OP:

In translating the quasi-fixtures from TestData to conftest in #22236, I sorted the dtypes for the columns of mixed_float_frame and mixed_int_frame, which turns out to have been a mistake. This is reverted here to be a true translation of the attribute of TestData. Otherwise, tests in the newly fixturized test_arithmetic.py would fail.

@@ -356,7 +356,7 @@ def test_axis_aliases(self):
assert_series_equal(result, expected)

def test_class_axis(self):
# https://github.com/pandas-dev/pandas/issues/18147
# GH 18147
Copy link
Member

Choose a reason for hiding this comment

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

Generally still ask that you try to minimize your changes as much as possible. Obviously changing comments isn't going to affect any of the code base but it still makes the diffs of your PRs unnecessarily larger, which makes reviews more difficult.

You should always look for logical separation points for smaller PRs, i.e. if you really want to clean up these comments then make a separate PR for that rather than bundling here. For this change please revert this file to master

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO these are trivial changes that don't get done otherwise, and what's more I did get asked to do this in several PRs, so I just do it preemptively.

However, I separated the commits between fixturizing and import-cleaning, so you can review the separate commits (almost) as separate PRs.

result = df.apply(lambda x: x, axis=1)
assert_frame_equal(result, df)
tm.assert_frame_equal(result, df)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as before - I like the explicit namespacing and agree it would be good to make that consistent in this module, but better done in a separate, contained PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above as well:

IMO these are trivial changes that don't get done otherwise, [...] However, I separated the commits between fixturizing and import-cleaning, so you can review the separate commits (almost) as separate PRs.

@WillAyd WillAyd added Testing pandas testing functions or related to the test suite Clean labels Sep 17, 2018
Copy link
Contributor Author

@h-vetinari h-vetinari left a comment

Choose a reason for hiding this comment

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

Thanks for the review. I separated the commits into clearly distinct parts for easier reviewing.

@@ -70,9 +82,10 @@ def mixed_float_frame():
Columns are ['A', 'B', 'C', 'D'].
"""
df = DataFrame(tm.getSeriesData())
df.A = df.A.astype('float16')
df.A = df.A.astype('float32')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See OP:

In translating the quasi-fixtures from TestData to conftest in #22236, I sorted the dtypes for the columns of mixed_float_frame and mixed_int_frame, which turns out to have been a mistake. This is reverted here to be a true translation of the attribute of TestData. Otherwise, tests in the newly fixturized test_arithmetic.py would fail.

@@ -356,7 +356,7 @@ def test_axis_aliases(self):
assert_series_equal(result, expected)

def test_class_axis(self):
# https://github.com/pandas-dev/pandas/issues/18147
# GH 18147
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO these are trivial changes that don't get done otherwise, and what's more I did get asked to do this in several PRs, so I just do it preemptively.

However, I separated the commits between fixturizing and import-cleaning, so you can review the separate commits (almost) as separate PRs.

result = df.apply(lambda x: x, axis=1)
assert_frame_equal(result, df)
tm.assert_frame_equal(result, df)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above as well:

IMO these are trivial changes that don't get done otherwise, [...] However, I separated the commits between fixturizing and import-cleaning, so you can review the separate commits (almost) as separate PRs.

@WillAyd
Copy link
Member

WillAyd commented Sep 17, 2018

Even if things were done in separate commits it's still makes things harder than it needs to be to have to step through them, especially as changes / edits get made over time. Again if you could do away with anything not directly relevant to "fixturization" would be very helpful and can take another look after that

@h-vetinari
Copy link
Contributor Author

@WillAyd It's something I'll take into account for future PRs. I make best-effort attempts considering the information I've gotten so far; your review contradicts that somewhat. Nevertheless, I've (grudgingly) split off #22735 and #22736.

@jreback
Copy link
Contributor

jreback commented Sep 17, 2018

as a general rule when changing tests

change only tests (no code)
if moving things - separate PR, don’t mix moving and changing

smaller is better - test changes have to be carefully scrutinized to make sure things are not breaking

@h-vetinari
Copy link
Contributor Author

@jreback

Now as small and focused as possible after split into #22735 #22736 #22738. Will keep this PR around for doing the import clean-ups after merge.

@codecov
Copy link

codecov bot commented Sep 23, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@66c2e5f). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #22730   +/-   ##
=========================================
  Coverage          ?   92.18%           
=========================================
  Files             ?      169           
  Lines             ?    50830           
  Branches          ?        0           
=========================================
  Hits              ?    46860           
  Misses            ?     3970           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.6% <ø> (?)
#single 42.37% <ø> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66c2e5f...ca36942. Read the comment docs.

@h-vetinari h-vetinari changed the title TST/CLN: Fixturize frame tests CLN: imports etc. in frame tests Sep 23, 2018
@h-vetinari
Copy link
Contributor Author

h-vetinari commented Sep 23, 2018

This is now based on #22733, #22735, #22736 and #22738. The commits are nice and modular so reviewing should be easy (once the remaining two PRs are merged).

@jreback
Copy link
Contributor

jreback commented Sep 23, 2018

Before we do any more of this

Replace instances of pd. with direct imports (from review #21899 (comment)):
don’t import pd, directly import instead

Replace direct use of assert_...equal with the tm.assert..._equal
(from review #21899 (comment)):
use tm; don’t import assert_series_equal

I would like alint rule to see what is what (and basically list the offenders as exclusions for now).

We have been changing things like this for a long time and I think we somtimes change them back (e.g. to use the imports of assert_*, rather than tm., and to use the pd.* rather than the direct imports.

Please remove these for now (or split out to a separate PR).

@h-vetinari
Copy link
Contributor Author

@jreback

I would like alint rule to see what is what (and basically list the offenders as exclusions for now).

There just needs to be a clear directive - also to write a lint rule. Furthermore, as far as I can tell from the test modules I've seen, almost all would fail both versions of that lint rule.

@jreback
Copy link
Contributor

jreback commented Sep 23, 2018

There just needs to be a clear directive - also to write a lint rule. Furthermore, as far as I can tell from the test modules I've seen, almost all would fail both versions of that lint rule.

of course, but that is exactly the point. let's see which iway is more common, then have a lint rule to enforce it, rather than ad-hoc conversions (which has been the policy up till now).

@h-vetinari
Copy link
Contributor Author

of course, but that is exactly the point. let's see which iway is more common, then have a lint rule to enforce it, rather than ad-hoc conversions (which has been the policy up till now).

Fair enough, but that's above my pay grade. Reverting the import-related commits.

@jreback
Copy link
Contributor

jreback commented Sep 25, 2018

can you limit the scope of this PR as it seems to overlap greating with your other one on test_analytics. I prefer PR's that change 1 thing generally; these will be reviewed an merged much faster that longer complicated ones.

@h-vetinari
Copy link
Contributor Author

@jreback

can you limit the scope of this PR as it seems to overlap greating with your other one on test_analytics.

See OP and #22730 (comment):

[...] fixturization was split out to #22735, #22736 and #22738. Now contains only the following clean-ups, also for #22733:

Better to review the parts for test_analytics and test_arithmetic after #22733 and #22736.

@h-vetinari
Copy link
Contributor Author

@WillAyd @jreback @gfyoung

Ready again to review. Also, did someone maybe change (reduce?) my GH privileges. I can't merge fixed conflicts anymore, and can't comment on a PR without simultaneously closing it.

@h-vetinari h-vetinari closed this Oct 7, 2018
@h-vetinari h-vetinari reopened this Oct 7, 2018
@jreback
Copy link
Contributor

jreback commented Oct 7, 2018

Ready again to review. Also, did someone maybe change (reduce?) my GH privileges. I can't merge fixed conflicts anymore, and can't comment on a PR without simultaneously closing it.

hah, not possible.

I can't merge fixed conflicts anymore,

what does this mean?

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

tiny issue, ping on green.

# GH PR #22298
df = pd.DataFrame(np.random.normal(size=(10, 2)))
# GH 22298
df = pd. DataFrame(np.random.normal(size=(10, 2)))
Copy link
Contributor

Choose a reason for hiding this comment

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

space added here

@jreback jreback added this to the 0.24.0 milestone Oct 7, 2018
@h-vetinari
Copy link
Contributor Author

I can't merge fixed conflicts anymore,
what does this mean?

I fixed the merge conflict in the github UI, but there was no button to actually merge them. I've already restarted my browser and everything, but my "comment" button has gone (leaving only "close and comment"). Really annoying.

@h-vetinari h-vetinari closed this Oct 7, 2018
@h-vetinari h-vetinari reopened this Oct 7, 2018
@h-vetinari
Copy link
Contributor Author

I can't merge fixed conflicts anymore,

what does this mean?

I fixed the merge conflict in the github UI, but there was no button to actually merge them. I've already restarted my browser and everything, but my "comment" button has gone (leaving only "close and comment"). Really annoying.

EDIT: and also, I can't edit posts anymore.

@h-vetinari h-vetinari closed this Oct 7, 2018
@h-vetinari h-vetinari reopened this Oct 7, 2018
@jreback
Copy link
Contributor

jreback commented Oct 7, 2018

@h-vetinari I am surprised you use the github UI to do anything. I have no idea what controls are on that, generally much better to use the command line.

@jreback
Copy link
Contributor

jreback commented Oct 7, 2018

lgtm. @WillAyd merge when satisfied.

@h-vetinari
Copy link
Contributor Author

@h-vetinari I am surprised you use the github UI to do anything. I have no idea what controls are on that, generally much better to use the command line.

For tiny conflicts (handful of lines) it's quicker for me. Rest I do manually or in IDE. However, you might wanna click on a SHA hash in one of these threads sometimes, especially if there's many commits - it allows you to easily browse through the commits one by one (which is how I split up #22733).

@h-vetinari h-vetinari closed this Oct 7, 2018
@h-vetinari h-vetinari reopened this Oct 7, 2018
@WillAyd WillAyd merged commit b0a2667 into pandas-dev:master Oct 8, 2018
@WillAyd
Copy link
Member

WillAyd commented Oct 8, 2018

thanks @h-vetinari !

@h-vetinari h-vetinari deleted the fixturize_frame_tests_1 branch October 8, 2018 17:09
tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants