Commit fddfbe2d authored by Taddeus Kroes's avatar Taddeus Kroes

Some minor code improvements.

parent caa49342
...@@ -358,7 +358,7 @@ class Scope(object): ...@@ -358,7 +358,7 @@ class Scope(object):
return isinstance(other, Scope) and self.node == other.node \ return isinstance(other, Scope) and self.node == other.node \
and self.nodes == other.nodes and self.nodes == other.nodes
def remove(self, node, replacement=None): def remove(self, node, **kwargs):
if node.is_leaf: if node.is_leaf:
node_cmp = hash(node) node_cmp = hash(node)
else: else:
...@@ -371,8 +371,8 @@ class Scope(object): ...@@ -371,8 +371,8 @@ class Scope(object):
n_cmp = n n_cmp = n
if n_cmp == node_cmp: if n_cmp == node_cmp:
if replacement != None: if 'replacement' in kwargs:
self[i] = replacement self[i] = kwargs['replacement']
else: else:
del self.nodes[i] del self.nodes[i]
...@@ -416,7 +416,9 @@ def get_scope(node): ...@@ -416,7 +416,9 @@ def get_scope(node):
def negate(node, n=1): def negate(node, n=1):
"""Negate the given node n times.""" """Negate the given node n times."""
node = node.clone() assert n >= 0
node.negated = n
return node new_node = node.clone()
new_node.negated = n
return new_node
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment