-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST/REF: finish collecting sample tests #37470
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
Conversation
There was a problem hiding this 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.
@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"] |
There was a problem hiding this comment.
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({...})])
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
@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"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
with pytest.raises(ValueError): | ||
ser = Series(range(10)) | ||
ser.sample(n=1, axis=1) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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. |
Parametrizes a few tests from the frame.methods.test_sample file, splits up giant tests from the generic file.