-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix #16363 - Prevent visit_BinOp from accessing value on UnaryOp #25928
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
Changes from 3 commits
ef777e7
5242bef
f0e0b3d
5d6ea06
1b88337
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -608,6 +608,12 @@ def test_unary_in_array(self): | |
-False, False, ~False, +False, | ||
-37, 37, ~37, +37], dtype=np.object_)) | ||
|
||
def test_float_comparison_bin_op(self): | ||
# GH 16363 | ||
df = pd.DataFrame({'x': np.array([0], dtype=np.float32)}) | ||
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. Is this specific to float32? Read briefly through issue and seemed like it affected other things 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. @WillAyd The bug arises when one side returns a float32 and the other side is a scalar that doesn't have a 'value' attribute. 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. Does this still work if the operands are switched? i.e. 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. an you parameterize on the dtype (at least float32/float64) 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.
I will add a test with a negative value on the left. 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.
Would you like a test for float64? This particular bug was caused by code that handles float32's, so float64's were fine, but I can add a test to ensure that this does not become an issue. 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. @jreback Oh, I see now pytest's |
||
res = df.eval('x < -0.1') | ||
assert res.values == np.array([False]) | ||
|
||
def test_disallow_scalar_bool_ops(self): | ||
exprs = '1 or 2', '1 and 2' | ||
exprs += 'a and b', 'a or b' | ||
|
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.
can you move down to numeric section.
make this more like:
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.
Yep, will do.