Skip to content

Commit 26d991f

Browse files
simonjayhawkinsjreback
authored andcommitted
CLN: Remove unused test code (pandas-dev#25670)
1 parent 848e262 commit 26d991f

File tree

1 file changed

+16
-46
lines changed

1 file changed

+16
-46
lines changed

pandas/tests/computation/test_eval.py

+16-46
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@
2323
from pandas.core.computation.expressions import (
2424
_NUMEXPR_INSTALLED, _USE_NUMEXPR)
2525
from pandas.core.computation.ops import (
26-
_arith_ops_syms, _binary_math_ops, _binary_ops_dict, _bool_ops_syms,
26+
_arith_ops_syms, _binary_math_ops, _binary_ops_dict,
2727
_special_case_arith_ops_syms, _unary_math_ops)
2828
import pandas.util.testing as tm
2929
from pandas.util.testing import (
3030
assert_frame_equal, assert_numpy_array_equal, assert_produces_warning,
3131
assert_series_equal, makeCustomDataframe as mkdf, randbool)
3232

33-
_series_frame_incompatible = _bool_ops_syms
34-
_scalar_skip = 'in', 'not in'
35-
3633

3734
@pytest.fixture(params=(
3835
pytest.param(engine,
@@ -162,13 +159,21 @@ def teardown_method(self, method):
162159
del self.pandas_rhses, self.pandas_lhses, self.current_engines
163160

164161
@pytest.mark.slow
165-
def test_complex_cmp_ops(self):
166-
cmp_ops = ('!=', '==', '<=', '>=', '<', '>')
167-
cmp2_ops = ('>', '<')
168-
for lhs, cmp1, rhs, binop, cmp2 in product(self.lhses, cmp_ops,
169-
self.rhses, self.bin_ops,
170-
cmp2_ops):
171-
self.check_complex_cmp_op(lhs, cmp1, rhs, binop, cmp2)
162+
@pytest.mark.parametrize('cmp1', ['!=', '==', '<=', '>=', '<', '>'],
163+
ids=['ne', 'eq', 'le', 'ge', 'lt', 'gt'])
164+
@pytest.mark.parametrize('cmp2', ['>', '<'], ids=['gt', 'lt'])
165+
def test_complex_cmp_ops(self, cmp1, cmp2):
166+
for lhs, rhs, binop in product(
167+
self.lhses, self.rhses, self.bin_ops):
168+
lhs_new = _eval_single_bin(lhs, cmp1, rhs, self.engine)
169+
rhs_new = _eval_single_bin(lhs, cmp2, rhs, self.engine)
170+
expected = _eval_single_bin(
171+
lhs_new, binop, rhs_new, self.engine)
172+
173+
ex = '(lhs {cmp1} rhs) {binop} (lhs {cmp2} rhs)'.format(
174+
cmp1=cmp1, binop=binop, cmp2=cmp2)
175+
result = pd.eval(ex, engine=self.engine, parser=self.parser)
176+
self.check_equal(result, expected)
172177

173178
def test_simple_cmp_ops(self):
174179
bool_lhses = (DataFrame(randbool(size=(10, 5))),
@@ -225,41 +230,6 @@ def check_equal(self, result, expected):
225230
else:
226231
assert result == expected
227232

228-
def check_complex_cmp_op(self, lhs, cmp1, rhs, binop, cmp2):
229-
skip_these = _scalar_skip
230-
ex = '(lhs {cmp1} rhs) {binop} (lhs {cmp2} rhs)'.format(cmp1=cmp1,
231-
binop=binop,
232-
cmp2=cmp2)
233-
scalar_with_in_notin = (is_scalar(rhs) and (cmp1 in skip_these or
234-
cmp2 in skip_these))
235-
if scalar_with_in_notin:
236-
with pytest.raises(TypeError):
237-
pd.eval(ex, engine=self.engine, parser=self.parser)
238-
with pytest.raises(TypeError):
239-
pd.eval(ex, engine=self.engine, parser=self.parser,
240-
local_dict={'lhs': lhs, 'rhs': rhs})
241-
else:
242-
lhs_new = _eval_single_bin(lhs, cmp1, rhs, self.engine)
243-
rhs_new = _eval_single_bin(lhs, cmp2, rhs, self.engine)
244-
if (isinstance(lhs_new, Series) and
245-
isinstance(rhs_new, DataFrame) and
246-
binop in _series_frame_incompatible):
247-
pass
248-
# TODO: the code below should be added back when left and right
249-
# hand side bool ops are fixed.
250-
#
251-
# try:
252-
# pytest.raises(Exception, pd.eval, ex,
253-
# local_dict={'lhs': lhs, 'rhs': rhs},
254-
# engine=self.engine, parser=self.parser)
255-
# except AssertionError:
256-
# raise
257-
else:
258-
expected = _eval_single_bin(
259-
lhs_new, binop, rhs_new, self.engine)
260-
result = pd.eval(ex, engine=self.engine, parser=self.parser)
261-
self.check_equal(result, expected)
262-
263233
def check_chained_cmp_op(self, lhs, cmp1, mid, cmp2, rhs):
264234

265235
def check_operands(left, right, cmp_op):

0 commit comments

Comments
 (0)