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
24dc157d
Commit
24dc157d
authored
Mar 29, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Node.contains() now ignores negation in the compared node during comparison.
parent
f5a7c1cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
2 deletions
+3
-2
src/node.py
src/node.py
+1
-1
tests/test_node.py
tests/test_node.py
+2
-1
No files found.
src/node.py
View file @
24dc157d
...
@@ -252,7 +252,7 @@ class ExpressionBase(object):
...
@@ -252,7 +252,7 @@ class ExpressionBase(object):
"""
"""
Check if a node equal to the specified one exists within this node.
Check if a node equal to the specified one exists within this node.
"""
"""
if
include_self
and
self
==
node
:
if
include_self
and
negate
(
self
,
0
)
==
node
:
return
True
return
True
if
not
self
.
is_leaf
:
if
not
self
.
is_leaf
:
...
...
tests/test_node.py
View file @
24dc157d
...
@@ -212,13 +212,14 @@ class TestNode(RulesTestCase):
...
@@ -212,13 +212,14 @@ class TestNode(RulesTestCase):
self
.
assertEqualNodes
(
Scope
(
-
n
).
as_nary_node
(),
-
n
)
self
.
assertEqualNodes
(
Scope
(
-
n
).
as_nary_node
(),
-
n
)
def
test_contains
(
self
):
def
test_contains
(
self
):
a
,
ab
,
bc
,
ln0
,
ln1
=
tree
(
'a, ab, bc, ln(a) + 1, ln(b) + 1
'
)
a
,
ab
,
bc
,
ln0
,
ln1
,
ma
=
tree
(
'a, ab, bc, ln(a) + 1, ln(b) + 1, -a
'
)
self
.
assertTrue
(
a
.
contains
(
a
))
self
.
assertTrue
(
a
.
contains
(
a
))
self
.
assertTrue
(
ab
.
contains
(
a
))
self
.
assertTrue
(
ab
.
contains
(
a
))
self
.
assertFalse
(
bc
.
contains
(
a
))
self
.
assertFalse
(
bc
.
contains
(
a
))
self
.
assertTrue
(
ln0
.
contains
(
a
))
self
.
assertTrue
(
ln0
.
contains
(
a
))
self
.
assertFalse
(
ln1
.
contains
(
a
))
self
.
assertFalse
(
ln1
.
contains
(
a
))
self
.
assertTrue
(
ma
.
contains
(
a
))
def
test_construct_function_derivative
(
self
):
def
test_construct_function_derivative
(
self
):
self
.
assertEqual
(
str
(
tree
(
'der(x ^ 2)'
)),
'[x ^ 2]
\
'
'
)
self
.
assertEqual
(
str
(
tree
(
'der(x ^ 2)'
)),
'[x ^ 2]
\
'
'
)
...
...
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