-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: Added regression test case #31536
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ce26841
TST: Added regression test case
fe01b37
Skipping test if running on 32-bit platform
2680f0b
Merge remote-tracking branch 'upstream/master' into TST-reg-boolean
a699369
Removed "skipif" on 32-bit platforms
69fb424
Replaced "pytest.skip" with "pytest.xfail"
b38f9e6
Lint issues
1f3d34f
Merge remote-tracking branch 'upstream/master' into TST-reg-boolean
da31af0
Added more params to paramaterize
f97720d
Make use of the normal pattern
3f7875c
Merge remote-tracking branch 'upstream/master' into TST-reg-boolean
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1305,3 +1305,35 @@ def test_dataframe_div_silenced(): | |
) | ||
with tm.assert_produces_warning(None): | ||
pdf1.div(pdf2, fill_value=0) | ||
|
||
|
||
class TestNumericArraylikeArithmeticWithBool: | ||
@pytest.mark.parametrize("num", [complex(1), np.int64(1), 1, 1.0]) | ||
def test_array_like_bool_and_num_op_coerce( | ||
self, num, all_arithmetic_functions, box_with_array | ||
): | ||
# https://github.com/pandas-dev/pandas/issues/18549 | ||
op = all_arithmetic_functions | ||
|
||
if op.__name__ in [ | ||
"floordiv", | ||
"mod", | ||
"mul", | ||
"pow", | ||
"rfloordiv", | ||
"rpow", | ||
"rmod", | ||
"rmul", | ||
"rtruediv", | ||
"truediv", | ||
]: | ||
pytest.xfail("Arithmetic operation is not supported") | ||
|
||
bool_box = [True] | ||
expected = [op(num, num)] | ||
|
||
bool_box = tm.box_expected(bool_box, box_with_array) | ||
expected = tm.box_expected(expected, box_with_array) | ||
|
||
tm.assert_equal(expected, op(bool_box, num)) | ||
tm.assert_equal(expected, op(num, bool_box)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick, the pattern we usually use is:
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is this not supported as in "not meaningful and so never will be supported" or as in "we havent gotten around to it yet so the behavior is wrong"? only the latter should be xfail
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 am not sure, maybe @jorisvandenbossche knows?
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's hard to see what the test is actually testing, but I would think something like this?
but that doesn't fail, though.
But I agree with @jbrockmendel: if there are cases that it raises an error purposefully, we should test that and not xfail.
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 am not able to test this without having
if/else
statement in the code, which is not really a pattern we want in our tests (I think), Any thought on how to write this test case?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.
The if/else might be fine, but in this if block, you can do a pytest.raises instead of xfail?
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.
Trying to test the actual errors, will result in having a test case that looks somewhat like this:
This looks sloppy, and not really readable, any thoughts?
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.
That looks fine to me in general (have some comments on some details, but that will be easier to add when this is in the diff)