Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
graph_drawing
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
graph_drawing
Commits
ab2d0af7
Commit
ab2d0af7
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added 'negated' keyword argument to node constructor.
parent
aade5fc5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
node.py
+4
-4
4 additions, 4 deletions
node.py
tests/test_node.py
+7
-3
7 additions, 3 deletions
tests/test_node.py
with
11 additions
and
7 deletions
node.py
+
4
−
4
View file @
ab2d0af7
...
...
@@ -3,11 +3,11 @@ from copy import deepcopy
class
Node
(
object
):
def
__init__
(
self
,
value
,
*
nodes
):
def
__init__
(
self
,
value
,
*
nodes
,
**
kwargs
):
super
(
Node
,
self
).
__init__
()
self
.
value
,
self
.
nodes
=
value
,
list
(
nodes
)
self
.
is_leaf
=
False
self
.
negated
=
0
self
.
negated
=
kwargs
.
get
(
'
negated
'
,
0
)
def
__getitem__
(
self
,
n
):
return
self
.
nodes
[
n
]
...
...
@@ -43,8 +43,8 @@ class Node(object):
class
Leaf
(
Node
):
def
__init__
(
self
,
value
):
super
(
Leaf
,
self
).
__init__
(
value
)
def
__init__
(
self
,
value
,
**
kwargs
):
super
(
Leaf
,
self
).
__init__
(
value
,
**
kwargs
)
self
.
value
=
value
self
.
nodes
=
None
self
.
is_leaf
=
True
...
...
This diff is collapsed.
Click to expand it.
tests/test_node.py
+
7
−
3
View file @
ab2d0af7
...
...
@@ -3,6 +3,7 @@ import doctest
import
node
from
node
import
Node
,
Leaf
from
line
import
generate_line
class
TestNode
(
unittest
.
TestCase
):
...
...
@@ -15,9 +16,6 @@ class TestNode(unittest.TestCase):
self
.
l1
=
Leaf
(
'
leaf 2
'
)
self
.
node
=
Node
(
'
node
'
,
self
.
l0
,
self
.
l1
)
def
tearDown
(
self
):
pass
def
test_getitem
(
self
):
assert
self
.
node
[
0
]
==
self
.
l0
...
...
@@ -47,3 +45,9 @@ class TestNode(unittest.TestCase):
self
.
assertEqual
(
str
(
l1
),
'
-1
'
)
l1
=
-
l1
self
.
assertEqual
(
str
(
l1
),
'
--1
'
)
def
test_kwargs_constructor
(
self
):
l1
,
l2
=
Leaf
(
1
),
Leaf
(
2
)
self
.
assertEqual
(
Node
(
'
+
'
,
l1
,
l2
,
negated
=
1
).
negated
,
1
)
self
.
assertEqual
(
Leaf
(
1
,
negated
=
2
).
negated
,
2
)
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