Skip to content

Extend eval test of standard functions to cover python engine. #58393

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 1 commit into from
Apr 24, 2024
Merged
Changes from all 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
12 changes: 5 additions & 7 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,22 +1609,20 @@ def eval(self, *args, **kwargs):
kwargs["level"] = kwargs.pop("level", 0) + 1
return pd.eval(*args, **kwargs)

@pytest.mark.skipif(
not NUMEXPR_INSTALLED, reason="Unary ops only implemented for numexpr"
)
@pytest.mark.filterwarnings("ignore::RuntimeWarning")
@pytest.mark.parametrize("fn", _unary_math_ops)
def test_unary_functions(self, fn):
def test_unary_functions(self, fn, engine, parser):
df = DataFrame({"a": np.random.default_rng(2).standard_normal(10)})
a = df.a

expr = f"{fn}(a)"
got = self.eval(expr)
got = self.eval(expr, engine=engine, parser=parser)
with np.errstate(all="ignore"):
expect = getattr(np, fn)(a)
tm.assert_series_equal(got, expect, check_names=False)

@pytest.mark.parametrize("fn", _binary_math_ops)
def test_binary_functions(self, fn):
def test_binary_functions(self, fn, engine, parser):
df = DataFrame(
{
"a": np.random.default_rng(2).standard_normal(10),
Expand All @@ -1635,7 +1633,7 @@ def test_binary_functions(self, fn):
b = df.b

expr = f"{fn}(a, b)"
got = self.eval(expr)
got = self.eval(expr, engine=engine, parser=parser)
with np.errstate(all="ignore"):
expect = getattr(np, fn)(a, b)
tm.assert_almost_equal(got, expect, check_names=False)
Expand Down
Loading