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

TST/REF: finish collecting sample tests #37470

Merged
merged 1 commit into from
Oct 29, 2020

Conversation

jbrockmendel
Copy link
Member

Parametrizes a few tests from the frame.methods.test_sample file, splits up giant tests from the generic file.

Copy link
Member

@ivanovmg ivanovmg left a comment

Choose a reason for hiding this comment

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

It is mainly a move? Anyway, couple of comments.

Comment on lines +158 to +163
@pytest.mark.parametrize("klass", [Series, DataFrame])
def test_sample_random_state(self, func_str, arg, klass):
# GH#32503
obj = DataFrame({"col1": range(10, 20), "col2": range(20, 30)})
if klass is Series:
obj = obj["col1"]
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to have obj explicitly parametrized without performing checks inside the test method?

@pytest.mark.parametrize("obj", [Series(...), DataFrame({...})])

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 find this cleaner, also smaller memory footprint because constructing outside gets done at test collection time instead of test runtime

Copy link
Member

Choose a reason for hiding this comment

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

OK, understood. Thank you for clarification on the footprint!

Comment on lines +168 to +174
@pytest.mark.parametrize("klass", [Series, DataFrame])
def test_sample_upsampling_without_replacement(self, klass):
# GH#27451

obj = DataFrame({"A": list("abc")})
if klass is Series:
obj = obj["A"]
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Comment on lines +257 to +259
with pytest.raises(ValueError):
ser = Series(range(10))
ser.sample(n=1, axis=1)
Copy link
Member

Choose a reason for hiding this comment

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

Test is related to Series, contradicts the comment on top of this class.

Copy link
Member Author

Choose a reason for hiding this comment

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

yah, there's further work to be done splitting these up

@jreback jreback added this to the 1.2 milestone Oct 29, 2020
@jreback jreback added the Testing pandas testing functions or related to the test suite label Oct 29, 2020
@jreback jreback merged commit 72acb78 into pandas-dev:master Oct 29, 2020
@jreback
Copy link
Contributor

jreback commented Oct 29, 2020

thanks, just a note before you go all in on moving the generic tests. we ought to consider just splitting these back to series/dataframe. yes now they are essentiallly in 2 places, but we already have a ton like this. the original reason for generic was to also test panel, well that's over so something to consider.

@jbrockmendel jbrockmendel deleted the tst-sample branch October 29, 2020 01:58
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
ukarroum pushed a commit to ukarroum/pandas that referenced this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants