Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
trs
Commits
9a8d9d5a
Commit
9a8d9d5a
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Removed use of hash_value from node classes.
parent
d810e27c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/node.py
+4
-36
4 additions, 36 deletions
src/node.py
with
4 additions
and
36 deletions
src/node.py
+
4
−
36
View file @
9a8d9d5a
...
...
@@ -130,21 +130,9 @@ def to_expression(obj):
class
ExpressionBase
(
object
):
hash_counter
=
1
def
__init__
(
self
,
*
args
,
**
kwargs
):
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
):
"""
Comparison between this expression{node,leaf} and another
...
...
@@ -193,6 +181,9 @@ class ExpressionBase(object):
"""
return
not
(
self
==
other
)
def
clone
(
self
):
return
copy
.
deepcopy
(
self
)
def
is_op
(
self
,
*
ops
):
return
not
self
.
is_leaf
and
self
.
op
in
ops
...
...
@@ -363,18 +354,6 @@ class ExpressionNode(Node, ExpressionBase):
return
isinstance
(
other
,
ExpressionNode
)
and
self
.
op
==
other
.
op
\
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
):
self
.
nodes
[
self
.
nodes
.
index
(
old_child
)]
=
new_child
...
...
@@ -514,17 +493,6 @@ class ExpressionLeaf(Leaf, ExpressionBase):
def
__repr__
(
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
):
"""
Check non-strict equivalence.
...
...
@@ -634,7 +602,7 @@ def negate(node, n=1):
"""
Negate the given node n times.
"""
assert
n
>=
0
new_node
=
copy
.
deepcopy
(
node
)
new_node
=
node
.
clone
(
)
new_node
.
negated
=
n
return
new_node
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment