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
49391e6c
Commit
49391e6c
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix: added negation copy to substitute function.
parent
358e632e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
external/graph_drawing
+1
-1
1 addition, 1 deletion
external/graph_drawing
src/node.py
+1
-4
1 addition, 4 deletions
src/node.py
src/rules/utils.py
+1
-1
1 addition, 1 deletion
src/rules/utils.py
tests/test_rules_utils.py
+2
-0
2 additions, 0 deletions
tests/test_rules_utils.py
with
5 additions
and
6 deletions
graph_drawing
@
ab2d0af7
Subproject commit a
ade5fc51f4b19e84d180fcff9b6c6d89db93667
Subproject commit a
b2d0af74078bf71f10da5e1f671f866caa84908
This diff is collapsed.
Click to expand it.
src/node.py
+
1
−
4
View file @
49391e6c
...
...
@@ -32,7 +32,7 @@ OP_AND = 9
OP_OR
=
10
# 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)
OP_INT
=
11
...
...
@@ -139,9 +139,6 @@ def to_expression(obj):
class
ExpressionBase
(
object
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
negated
=
0
def
__lt__
(
self
,
other
):
"""
Comparison between this expression{node,leaf} and another
...
...
This diff is collapsed.
Click to expand it.
src/rules/utils.py
+
1
−
1
View file @
49391e6c
...
...
@@ -125,7 +125,7 @@ def substitute(f, x, replacement):
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
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_rules_utils.py
+
2
−
0
View file @
49391e6c
...
...
@@ -58,6 +58,8 @@ class TestRulesUtils(RulesTestCase):
self
.
assertEqual
(
substitute
(
tree
(
'
x2
'
),
x
,
a
),
tree
(
'
a2
'
))
self
.
assertEqual
(
substitute
(
tree
(
'
y + x + 1
'
),
x
,
a
),
tree
(
'
y + a + 1
'
))
self
.
assertEqual
(
substitute
(
tree
(
'
1 - 2x
'
),
x
,
a
),
tree
(
'
1 - 2a
'
))
def
test_divides
(
self
):
self
.
assertTrue
(
divides
(
3
,
3
))
...
...
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