|
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, |
|
54 | 55 | _unary_math_ops, |
55 | 56 | ) |
56 | 57 | from pandas.core.computation.scope import DEFAULT_GLOBALS |
| 58 | +from pandas.util.version import Version |
| 59 | + |
| 60 | +numexpr = import_optional_dependency("numexpr", errors="ignore") |
57 | 61 |
|
58 | 62 |
|
59 | 63 | @pytest.fixture( |
@@ -322,7 +326,9 @@ def test_modulus(self, lhs, rhs, engine, parser): |
322 | 326 | def test_floor_division(self, lhs, rhs, engine, parser): |
323 | 327 | ex = "lhs // rhs" |
324 | 328 |
|
325 | | - if engine == "python": |
| 329 | + if engine == "python" or ( |
| 330 | + engine == "numexpr" and Version(numexpr.__version__) >= Version("2.13.0") |
| 331 | + ): |
326 | 332 | res = pd.eval(ex, engine=engine, parser=parser) |
327 | 333 | expected = lhs // rhs |
328 | 334 | tm.assert_equal(res, expected) |
@@ -393,7 +399,7 @@ def test_frame_invert(self, engine, parser): |
393 | 399 |
|
394 | 400 | # int raises on numexpr |
395 | 401 | 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"): |
397 | 403 | msg = "couldn't find matching opcode for 'invert" |
398 | 404 | with pytest.raises(NotImplementedError, match=msg): |
399 | 405 | pd.eval(expr, engine=engine, parser=parser) |
@@ -438,7 +444,7 @@ def test_series_invert(self, engine, parser): |
438 | 444 |
|
439 | 445 | # int raises on numexpr |
440 | 446 | 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"): |
442 | 448 | msg = "couldn't find matching opcode for 'invert" |
443 | 449 | with pytest.raises(NotImplementedError, match=msg): |
444 | 450 | pd.eval(expr, engine=engine, parser=parser) |
|
0 commit comments