Skip to content

Commit 179258f

Browse files
authored
TST: Adjust tests for numexpr 2.13 (#62452)
1 parent 44ef1cf commit 179258f

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,
@@ -53,6 +54,9 @@
5354
_unary_math_ops,
5455
)
5556
from pandas.core.computation.scope import DEFAULT_GLOBALS
57+
from pandas.util.version import Version
58+
59+
numexpr = import_optional_dependency("numexpr", errors="ignore")
5660

5761

5862
@pytest.fixture(
@@ -320,7 +324,9 @@ def test_modulus(self, lhs, rhs, engine, parser):
320324
def test_floor_division(self, lhs, rhs, engine, parser):
321325
ex = "lhs // rhs"
322326

323-
if engine == "python":
327+
if engine == "python" or (
328+
engine == "numexpr" and Version(numexpr.__version__) >= Version("2.13.0")
329+
):
324330
res = pd.eval(ex, engine=engine, parser=parser)
325331
expected = lhs // rhs
326332
tm.assert_equal(res, expected)
@@ -391,7 +397,7 @@ def test_frame_invert(self, engine, parser):
391397

392398
# int raises on numexpr
393399
lhs = DataFrame(np.random.default_rng(2).integers(5, size=(5, 2)))
394-
if engine == "numexpr":
400+
if engine == "numexpr" and Version(numexpr.__version__) < Version("2.13.0"):
395401
msg = "couldn't find matching opcode for 'invert"
396402
with pytest.raises(NotImplementedError, match=msg):
397403
pd.eval(expr, engine=engine, parser=parser)
@@ -436,7 +442,7 @@ def test_series_invert(self, engine, parser):
436442

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

0 commit comments

Comments
 (0)