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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Numeric
^^^^^^^
- Bug in :meth:`DataFrame.rank` raising ``ValueError`` with ``object`` columns and ``method="first"`` (:issue:`41931`)
- Bug in :meth:`DataFrame.rank` treating missing values and extreme values as equal (for example ``np.nan`` and ``np.inf``), causing incorrect results when ``na_option="bottom"`` or ``na_option="top`` used (:issue:`41931`)
-
- Bug in ``numexpr`` engine still being used when the option ``compute.use_numexpr`` is set to ``False`` (:issue:`32556`)

Conversion
^^^^^^^^^^
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/computation/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ def _check_engine(engine: str | None) -> str:
Engine name.
"""
from pandas.core.computation.check import NUMEXPR_INSTALLED
from pandas.core.computation.expressions import USE_NUMEXPR

if engine is None:
engine = "numexpr" if NUMEXPR_INSTALLED else "python"
engine = "numexpr" if USE_NUMEXPR else "python"

if engine not in ENGINES:
valid_engines = list(ENGINES.keys())
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

def test_numexpr_option_respected():
# 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

result = _check_engine(None)
assert result == "python"


@td.skip_if_no_ne
def test_invalid_parser():
msg = "Invalid parser 'asdf' passed"
Expand Down