Skip to content

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

Merged
merged 5 commits into from
Jul 28, 2021

Conversation

saehuihwang
Copy link
Contributor

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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):
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@jreback jreback added Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug labels Jul 22, 2021
@jreback
Copy link
Contributor

jreback commented Jul 22, 2021

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.

Comment on lines 1876 to 1879
if use_numexpr:
assert result == "numexpr"
else:
assert result == "python"
Copy link
Member

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?

Copy link
Contributor Author

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!

@jreback jreback added this to the 1.4 milestone Jul 26, 2021
@jreback
Copy link
Contributor

jreback commented Jul 26, 2021

lgtm. over to you @MarcoGorelli

@MarcoGorelli MarcoGorelli self-requested a review July 27, 2021 08:37
@jreback jreback merged commit 8e844a2 into pandas-dev:master Jul 28, 2021
@jreback
Copy link
Contributor

jreback commented Jul 28, 2021

thanks @saehuihwang

CGe0516 pushed a commit to CGe0516/pandas that referenced this pull request Jul 29, 2021
feefladder pushed a commit to feefladder/pandas that referenced this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dataframe.query uses numexpr even when 'compute.use_numexpr' is False
3 participants