Skip to content

TST: parametrize tests #31228

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 2 commits into from
Jan 23, 2020
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
54 changes: 24 additions & 30 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,45 +573,39 @@ def test_series_negate(self):
result = pd.eval(expr, engine=self.engine, parser=self.parser)
tm.assert_series_equal(expect, result)

def test_frame_pos(self):
@pytest.mark.parametrize(
"lhs",
[
# Float
DataFrame(randn(5, 2)),
# Int
DataFrame(randint(5, size=(5, 2))),
# bool doesn't work with numexpr but works elsewhere
DataFrame(rand(5, 2) > 0.5),
],
)
def test_frame_pos(self, lhs):
expr = self.ex("+")

# float
lhs = DataFrame(randn(5, 2))
expect = lhs
result = pd.eval(expr, engine=self.engine, parser=self.parser)
tm.assert_frame_equal(expect, result)

# int
lhs = DataFrame(randint(5, size=(5, 2)))
expect = lhs
result = pd.eval(expr, engine=self.engine, parser=self.parser)
tm.assert_frame_equal(expect, result)

# bool doesn't work with numexpr but works elsewhere
lhs = DataFrame(rand(5, 2) > 0.5)
expect = lhs
result = pd.eval(expr, engine=self.engine, parser=self.parser)
tm.assert_frame_equal(expect, result)

def test_series_pos(self):
@pytest.mark.parametrize(
"lhs",
[
# Float
Series(randn(5)),
# Int
Series(randint(5, size=5)),
# bool doesn't work with numexpr but works elsewhere
Series(rand(5) > 0.5),
],
)
def test_series_pos(self, lhs):
expr = self.ex("+")

# float
lhs = Series(randn(5))
expect = lhs
result = pd.eval(expr, engine=self.engine, parser=self.parser)
tm.assert_series_equal(expect, result)

# int
lhs = Series(randint(5, size=5))
expect = lhs
result = pd.eval(expr, engine=self.engine, parser=self.parser)
tm.assert_series_equal(expect, result)

# bool doesn't work with numexpr but works elsewhere
lhs = Series(rand(5) > 0.5)
expect = lhs
result = pd.eval(expr, engine=self.engine, parser=self.parser)
tm.assert_series_equal(expect, result)

Expand Down