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
49391e6c
Commit
49391e6c
authored
May 02, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix: added negation copy to substitute function.
parent
358e632e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
6 deletions
+5
-6
external/graph_drawing
external/graph_drawing
+1
-1
src/node.py
src/node.py
+1
-4
src/rules/utils.py
src/rules/utils.py
+1
-1
tests/test_rules_utils.py
tests/test_rules_utils.py
+2
-0
No files found.
graph_drawing
@
ab2d0af7
Subproject commit a
ade5fc51f4b19e84d180fcff9b6c6d89db93667
Subproject commit a
b2d0af74078bf71f10da5e1f671f866caa84908
src/node.py
View file @
49391e6c
...
@@ -32,7 +32,7 @@ OP_AND = 9
...
@@ -32,7 +32,7 @@ OP_AND = 9
OP_OR
=
10
OP_OR
=
10
# Binary operators that are considered n-ary
# Binary operators that are considered n-ary
NARY_OPERATORS
=
[
OP_ADD
,
OP_SUB
,
OP_MUL
]
NARY_OPERATORS
=
[
OP_ADD
,
OP_SUB
,
OP_MUL
,
OP_AND
,
OP_OR
]
# N-ary (functions)
# N-ary (functions)
OP_INT
=
11
OP_INT
=
11
...
@@ -139,9 +139,6 @@ def to_expression(obj):
...
@@ -139,9 +139,6 @@ def to_expression(obj):
class
ExpressionBase
(
object
):
class
ExpressionBase
(
object
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
negated
=
0
def
__lt__
(
self
,
other
):
def
__lt__
(
self
,
other
):
"""
"""
Comparison between this expression{node,leaf} and another
Comparison between this expression{node,leaf} and another
...
...
src/rules/utils.py
View file @
49391e6c
...
@@ -125,7 +125,7 @@ def substitute(f, x, replacement):
...
@@ -125,7 +125,7 @@ def substitute(f, x, replacement):
children
=
map
(
lambda
c
:
substitute
(
c
,
x
,
replacement
),
f
)
children
=
map
(
lambda
c
:
substitute
(
c
,
x
,
replacement
),
f
)
return
N
(
f
.
op
,
*
children
)
return
N
(
f
.
op
,
*
children
,
negated
=
f
.
negated
)
def
divides
(
m
,
n
):
def
divides
(
m
,
n
):
...
...
tests/test_rules_utils.py
View file @
49391e6c
...
@@ -58,6 +58,8 @@ class TestRulesUtils(RulesTestCase):
...
@@ -58,6 +58,8 @@ class TestRulesUtils(RulesTestCase):
self
.
assertEqual
(
substitute
(
tree
(
'x2'
),
x
,
a
),
tree
(
'a2'
))
self
.
assertEqual
(
substitute
(
tree
(
'x2'
),
x
,
a
),
tree
(
'a2'
))
self
.
assertEqual
(
substitute
(
tree
(
'y + x + 1'
),
x
,
a
),
self
.
assertEqual
(
substitute
(
tree
(
'y + x + 1'
),
x
,
a
),
tree
(
'y + a + 1'
))
tree
(
'y + a + 1'
))
self
.
assertEqual
(
substitute
(
tree
(
'1 - 2x'
),
x
,
a
),
tree
(
'1 - 2a'
))
def
test_divides
(
self
):
def
test_divides
(
self
):
self
.
assertTrue
(
divides
(
3
,
3
))
self
.
assertTrue
(
divides
(
3
,
3
))
...
...
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