|
8 | 8 | import pytest
|
9 | 9 |
|
10 | 10 | from pandas.compat import PY312
|
| 11 | +from pandas.compat._optional import import_optional_dependency |
11 | 12 | from pandas.errors import (
|
12 | 13 | NumExprClobberingError,
|
13 | 14 | PerformanceWarning,
|
|
53 | 54 | _unary_math_ops,
|
54 | 55 | )
|
55 | 56 | from pandas.core.computation.scope import DEFAULT_GLOBALS
|
| 57 | +from pandas.util.version import Version |
| 58 | + |
| 59 | +numexpr = import_optional_dependency("numexpr", errors="ignore") |
56 | 60 |
|
57 | 61 |
|
58 | 62 | @pytest.fixture(
|
@@ -320,7 +324,9 @@ def test_modulus(self, lhs, rhs, engine, parser):
|
320 | 324 | def test_floor_division(self, lhs, rhs, engine, parser):
|
321 | 325 | ex = "lhs // rhs"
|
322 | 326 |
|
323 |
| - if engine == "python": |
| 327 | + if engine == "python" or ( |
| 328 | + engine == "numexpr" and Version(numexpr.__version__) >= Version("2.13.0") |
| 329 | + ): |
324 | 330 | res = pd.eval(ex, engine=engine, parser=parser)
|
325 | 331 | expected = lhs // rhs
|
326 | 332 | tm.assert_equal(res, expected)
|
@@ -391,7 +397,7 @@ def test_frame_invert(self, engine, parser):
|
391 | 397 |
|
392 | 398 | # int raises on numexpr
|
393 | 399 | 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"): |
395 | 401 | msg = "couldn't find matching opcode for 'invert"
|
396 | 402 | with pytest.raises(NotImplementedError, match=msg):
|
397 | 403 | pd.eval(expr, engine=engine, parser=parser)
|
@@ -436,7 +442,7 @@ def test_series_invert(self, engine, parser):
|
436 | 442 |
|
437 | 443 | # int raises on numexpr
|
438 | 444 | 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"): |
440 | 446 | msg = "couldn't find matching opcode for 'invert"
|
441 | 447 | with pytest.raises(NotImplementedError, match=msg):
|
442 | 448 | pd.eval(expr, engine=engine, parser=parser)
|
|
0 commit comments