Skip to content

Commit 4f8055a

Browse files
committed
CLN/TST: fail with a NotImplementedError on and or not
1 parent a0c79ae commit 4f8055a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

pandas/computation/expr.py

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def visit_BinOp(self, node):
7777
return op(left, right)
7878

7979
def visit_UnaryOp(self, node):
80+
if isinstance(node.op, ast.Not):
81+
raise NotImplementedError("not operator not yet supported")
8082
op = self.visit(node.op)
8183
return op(self.visit(node.operand))
8284

@@ -107,6 +109,8 @@ def visit_Call(self, node):
107109
def visit_Attribute(self, node):
108110
raise NotImplementedError("attribute access is not yet supported")
109111

112+
def visit_BoolOp(self, node):
113+
raise NotImplementedError("boolean operators are not yet supported")
110114

111115
class Expr(StringMixin):
112116
"""Expr object"""

pandas/computation/tests/test_eval.py

+33
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,39 @@ def test_is_expr():
610610
check_is_expr(engine)
611611

612612

613+
def check_not_fails(engine):
614+
x = True
615+
assert_raises(NotImplementedError, pd.eval, 'not x', engine=engine,
616+
local_dict={'x': x})
617+
618+
619+
def test_not_fails():
620+
for engine in _engines:
621+
check_not_fails(engine)
622+
623+
624+
def check_and_fails(engine):
625+
x, y = False, True
626+
assert_raises(NotImplementedError, pd.eval, 'x and y', engine=engine,
627+
local_dict={'x': x, 'y': y})
628+
629+
630+
def test_and_fails():
631+
for engine in _engines:
632+
check_and_fails(engine)
633+
634+
635+
def check_or_fails(engine):
636+
x, y = True, False
637+
assert_raises(NotImplementedError, pd.eval, 'x or y', engine=engine,
638+
local_dict={'x': x, 'y': y})
639+
640+
641+
def test_or_fails():
642+
for engine in _engines:
643+
check_or_fails(engine)
644+
645+
613646
if __name__ == '__main__':
614647
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
615648
exit=False)

0 commit comments

Comments
 (0)