Skip to content

Commit e57c7d6

Browse files
Backport PR #62452 on branch 2.3.x (TST: Adjust tests for numexpr 2.13) (#62454)
Co-authored-by: Matthew Roeschke <[email protected]>
1 parent e0fe9a0 commit e57c7d6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pandas/tests/computation/test_eval.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99

1010
from pandas.compat import PY312
11+
from pandas.compat._optional import import_optional_dependency
1112
from pandas.errors import (
1213
NumExprClobberingError,
1314
PerformanceWarning,
@@ -54,6 +55,9 @@
5455
_unary_math_ops,
5556
)
5657
from pandas.core.computation.scope import DEFAULT_GLOBALS
58+
from pandas.util.version import Version
59+
60+
numexpr = import_optional_dependency("numexpr", errors="ignore")
5761

5862

5963
@pytest.fixture(
@@ -322,7 +326,9 @@ def test_modulus(self, lhs, rhs, engine, parser):
322326
def test_floor_division(self, lhs, rhs, engine, parser):
323327
ex = "lhs // rhs"
324328

325-
if engine == "python":
329+
if engine == "python" or (
330+
engine == "numexpr" and Version(numexpr.__version__) >= Version("2.13.0")
331+
):
326332
res = pd.eval(ex, engine=engine, parser=parser)
327333
expected = lhs // rhs
328334
tm.assert_equal(res, expected)
@@ -393,7 +399,7 @@ def test_frame_invert(self, engine, parser):
393399

394400
# int raises on numexpr
395401
lhs = DataFrame(np.random.default_rng(2).integers(5, size=(5, 2)))
396-
if engine == "numexpr":
402+
if engine == "numexpr" and Version(numexpr.__version__) < Version("2.13.0"):
397403
msg = "couldn't find matching opcode for 'invert"
398404
with pytest.raises(NotImplementedError, match=msg):
399405
pd.eval(expr, engine=engine, parser=parser)
@@ -438,7 +444,7 @@ def test_series_invert(self, engine, parser):
438444

439445
# int raises on numexpr
440446
lhs = Series(np.random.default_rng(2).integers(5, size=5))
441-
if engine == "numexpr":
447+
if engine == "numexpr" and Version(numexpr.__version__) < Version("2.13.0"):
442448
msg = "couldn't find matching opcode for 'invert"
443449
with pytest.raises(NotImplementedError, match=msg):
444450
pd.eval(expr, engine=engine, parser=parser)

0 commit comments

Comments
 (0)