Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
9a8d9d5a
Commit
9a8d9d5a
authored
Apr 17, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed use of hash_value from node classes.
parent
d810e27c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
36 deletions
+4
-36
src/node.py
src/node.py
+4
-36
No files found.
src/node.py
View file @
9a8d9d5a
...
@@ -130,21 +130,9 @@ def to_expression(obj):
...
@@ -130,21 +130,9 @@ def to_expression(obj):
class
ExpressionBase
(
object
):
class
ExpressionBase
(
object
):
hash_counter
=
1
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
negated
=
0
self
.
negated
=
0
# Create a unique hash value
self
.
hash_value
=
self
.
__class__
.
hash_counter
self
.
__class__
.
hash_counter
+=
1
def
__hash__
(
self
):
return
self
.
hash_value
def
__cmp__
(
self
):
return
hash
(
other
)
-
hash
(
self
)
def
__lt__
(
self
,
other
):
def
__lt__
(
self
,
other
):
"""
"""
Comparison between this expression{node,leaf} and another
Comparison between this expression{node,leaf} and another
...
@@ -193,6 +181,9 @@ class ExpressionBase(object):
...
@@ -193,6 +181,9 @@ class ExpressionBase(object):
"""
"""
return
not
(
self
==
other
)
return
not
(
self
==
other
)
def
clone
(
self
):
return
copy
.
deepcopy
(
self
)
def
is_op
(
self
,
*
ops
):
def
is_op
(
self
,
*
ops
):
return
not
self
.
is_leaf
and
self
.
op
in
ops
return
not
self
.
is_leaf
and
self
.
op
in
ops
...
@@ -363,18 +354,6 @@ class ExpressionNode(Node, ExpressionBase):
...
@@ -363,18 +354,6 @@ class ExpressionNode(Node, ExpressionBase):
return isinstance(other, ExpressionNode) and self.op == other.op
\
return isinstance(other, ExpressionNode) and self.op == other.op
\
and self.negated == other.negated and self.nodes == other.nodes
and self.negated == other.negated and self.nodes == other.nodes
def clone(self):
"""
Create a clone of the current node. Copy the hash value for comparison
in Scope operations.
"""
children = [child.clone() for child in self]
clone = ExpressionNode(self.op, *children)
clone.negated = self.negated
#clone.hash_value = self.hash_value
return clone
def substitute(self, old_child, new_child):
def substitute(self, old_child, new_child):
self.nodes[self.nodes.index(old_child)] = new_child
self.nodes[self.nodes.index(old_child)] = new_child
...
@@ -514,17 +493,6 @@ class ExpressionLeaf(Leaf, ExpressionBase):
...
@@ -514,17 +493,6 @@ class ExpressionLeaf(Leaf, ExpressionBase):
def __repr__(self):
def __repr__(self):
return str(self)
return str(self)
def clone(self):
"""
Create a clone of the current leaf. Copy the hash value for comparison
in Scope operations.
"""
clone = ExpressionLeaf(self.value)
clone.negated = self.negated
#clone.hash_value = self.hash_value
return clone
def equals(self, other, ignore_negation=False):
def equals(self, other, ignore_negation=False):
"""
"""
Check non-strict equivalence.
Check non-strict equivalence.
...
@@ -634,7 +602,7 @@ def negate(node, n=1):
...
@@ -634,7 +602,7 @@ def negate(node, n=1):
"""Negate the given node n times."""
"""Negate the given node n times."""
assert n >= 0
assert n >= 0
new_node =
copy.deepcopy(node
)
new_node =
node.clone(
)
new_node.negated = n
new_node.negated = n
return new_node
return new_node
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment