-
-
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
Changes from 4 commits
c494dec
fdb1ed6
46f19af
2c3b292
a6cdd73
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 |
---|---|---|
|
@@ -1865,6 +1865,32 @@ def test_invalid_engine(): | |
pd.eval("x + y", local_dict={"x": 1, "y": 2}, engine="asdf") | ||
|
||
|
||
@td.skip_if_no_ne | ||
@pytest.mark.parametrize("use_numexpr", [True, False]) | ||
def test_numexpr_option_respected(use_numexpr): | ||
# GH 32556 | ||
from pandas.core.computation.eval import _check_engine | ||
|
||
with pd.option_context("compute.use_numexpr", use_numexpr): | ||
result = _check_engine(None) | ||
if use_numexpr: | ||
assert result == "numexpr" | ||
else: | ||
assert result == "python" | ||
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. 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
and then, in the body, just 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. This is good to know! Thank you for linking the resource. Added! |
||
|
||
|
||
@td.skip_if_no_ne | ||
def test_numexpr_option_incompatible_op(): | ||
# GH 32556 | ||
with pd.option_context("compute.use_numexpr", False): | ||
df = DataFrame( | ||
{"A": [True, False, True, False, None, None], "B": [1, 2, 3, 4, 5, 6]} | ||
) | ||
result = df.query("A.isnull()") | ||
expected = DataFrame({"A": [None, None], "B": [5, 6]}, index=[4, 5]) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@td.skip_if_no_ne | ||
def test_invalid_parser(): | ||
msg = "Invalid parser 'asdf' passed" | ||
|
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