-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: compute.use_numexpr option not respected #42668
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
saehuihwang
commented
Jul 22, 2021
- closes Dataframe.query uses numexpr even when 'compute.use_numexpr' is False #32556
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
@@ -1865,6 +1865,16 @@ def test_invalid_engine(): | |||
pd.eval("x + y", local_dict={"x": 1, "y": 2}, engine="asdf") | |||
|
|||
|
|||
@td.skip_if_no_ne |
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 parameterize and text for both True/False here.
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.
added
# GH 32556 | ||
from pandas.core.computation.eval import _check_engine | ||
|
||
with pd.option_context("compute.use_numexpr", False): |
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 add a test similar to #32556 (comment)
that we can check from a user perspective that this is working.
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.
added
also look thru the referenced issue for any other things that we can test with this. it is quite trick to make sure this is working propertly. |
if use_numexpr: | ||
assert result == "numexpr" | ||
else: | ||
assert result == "python" |
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.
logic (e.g. if/else statements) in tests aren't ideal (https://testing.googleblog.com/2014/07/testing-on-toilet-dont-put-logic-in.html), how about something like
@pytest.mark.parametrize(
("use_numexpr", "expected"),
(
(True, "numexpr"),
(False, "python"),
)
)
def test_numexpr_option_respected(use_numexpr, expected):
and then, in the body, just assert result == expected
?
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.
This is good to know! Thank you for linking the resource. Added!
lgtm. over to you @MarcoGorelli |
thanks @saehuihwang |