Skip to content

CLN: Remove unused test code #25670

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 4 commits into from
Mar 12, 2019
Merged
Changes from 1 commit
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
46 changes: 9 additions & 37 deletions pandas/tests/computation/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
assert_series_equal, makeCustomDataframe as mkdf, randbool)

_series_frame_incompatible = _bool_ops_syms
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_series_frame_incompatible can also be removed. AFK for a short while. will remove.

_scalar_skip = 'in', 'not in'


@pytest.fixture(params=(
Expand Down Expand Up @@ -168,7 +167,15 @@ def test_complex_cmp_ops(self):
for lhs, cmp1, rhs, binop, cmp2 in product(self.lhses, cmp_ops,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to parametrize this?

self.rhses, self.bin_ops,
cmp2_ops):
self.check_complex_cmp_op(lhs, cmp1, rhs, binop, cmp2)
lhs_new = _eval_single_bin(lhs, cmp1, rhs, self.engine)
rhs_new = _eval_single_bin(lhs, cmp2, rhs, self.engine)
expected = _eval_single_bin(
lhs_new, binop, rhs_new, self.engine)

ex = '(lhs {cmp1} rhs) {binop} (lhs {cmp2} rhs)'.format(
cmp1=cmp1, binop=binop, cmp2=cmp2)
result = pd.eval(ex, engine=self.engine, parser=self.parser)
self.check_equal(result, expected)

def test_simple_cmp_ops(self):
bool_lhses = (DataFrame(randbool(size=(10, 5))),
Expand Down Expand Up @@ -225,41 +232,6 @@ def check_equal(self, result, expected):
else:
assert result == expected

def check_complex_cmp_op(self, lhs, cmp1, rhs, binop, cmp2):
skip_these = _scalar_skip
ex = '(lhs {cmp1} rhs) {binop} (lhs {cmp2} rhs)'.format(cmp1=cmp1,
binop=binop,
cmp2=cmp2)
scalar_with_in_notin = (is_scalar(rhs) and (cmp1 in skip_these or
cmp2 in skip_these))
if scalar_with_in_notin:
with pytest.raises(TypeError):
pd.eval(ex, engine=self.engine, parser=self.parser)
with pytest.raises(TypeError):
pd.eval(ex, engine=self.engine, parser=self.parser,
local_dict={'lhs': lhs, 'rhs': rhs})
else:
lhs_new = _eval_single_bin(lhs, cmp1, rhs, self.engine)
rhs_new = _eval_single_bin(lhs, cmp2, rhs, self.engine)
if (isinstance(lhs_new, Series) and
isinstance(rhs_new, DataFrame) and
binop in _series_frame_incompatible):
pass
# TODO: the code below should be added back when left and right
# hand side bool ops are fixed.
#
# try:
# pytest.raises(Exception, pd.eval, ex,
# local_dict={'lhs': lhs, 'rhs': rhs},
# engine=self.engine, parser=self.parser)
# except AssertionError:
# raise
else:
expected = _eval_single_bin(
lhs_new, binop, rhs_new, self.engine)
result = pd.eval(ex, engine=self.engine, parser=self.parser)
self.check_equal(result, expected)

def check_chained_cmp_op(self, lhs, cmp1, mid, cmp2, rhs):

def check_operands(left, right, cmp_op):
Expand Down