Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
graph_drawing
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
graph_drawing
Commits
7e891018
Commit
7e891018
authored
Nov 24, 2011
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Successfully built n-ary graph drawer.
parent
d9474ea0
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
108 deletions
+154
-108
graph.py
graph.py
+120
-91
tests/test_graph.py
tests/test_graph.py
+34
-17
No files found.
graph.py
View file @
7e891018
This diff is collapsed.
Click to expand it.
tests/test_graph.py
View file @
7e891018
...
...
@@ -16,59 +16,76 @@ class TestGraph(unittest.TestCase):
def
test_simple_unary
(
self
):
uminus
=
Node
(
'-'
,
self
.
l1
)
g
=
generate_graph
(
uminus
,
Node
)
expect
=
self
.
strip
(
"""
self
.
assertEqualGraphs
(
g
,
"""
-
│
1
"""
)
assert
g
==
expect
def
test_simple_binary
(
self
):
plus
=
Node
(
'+'
,
self
.
l0
,
self
.
l1
)
g
=
generate_graph
(
plus
,
Node
)
expect
=
self
.
strip
(
"""
self
.
assertEqualGraphs
(
g
,
"""
+
╭┴╮
0 1
"""
)
assert
g
==
expect
def
test_multichar_unary
(
self
):
uminus
=
Node
(
'-'
,
self
.
multi
)
g
=
generate_graph
(
uminus
,
Node
)
expect
=
self
.
strip
(
"""
self
.
assertEqualGraphs
(
g
,
"""
-
│
test
"""
)
print
g
print
expect
assert
g
==
expect
def
test_multichar_binary
(
self
):
plus
=
Node
(
'+'
,
self
.
multi
,
self
.
l1
)
g
=
generate_graph
(
plus
,
Node
)
expect
=
self
.
strip
(
"""
self
.
assertEqualGraphs
(
g
,
"""
+
╭─
──┴╮
╭
──┴╮
test 1
"""
)
assert
g
==
expect
def
test_function
(
self
):
def
test_ternary
(
self
):
exp
=
Leaf
(
'x'
)
inf
=
Leaf
(
'o'
)
minus_inf
=
Node
(
'-'
,
Leaf
(
'L'
))
integral
=
Node
(
'n'
,
exp
,
minus_inf
,
inf
)
g
=
generate_graph
(
integral
,
Node
,
verbose
=
True
)
self
.
assertEqualGraphs
(
g
,
"""
n
╭─┼─╮
x - o
│
L
"""
)
def
test_ternary_multichar
(
self
):
exp
=
Leaf
(
'x'
)
inf
=
Leaf
(
'oo'
)
minus_inf
=
Node
(
'-'
,
inf
)
minus_inf
=
Node
(
'-'
,
Leaf
(
'LL'
)
)
integral
=
Node
(
'int'
,
exp
,
minus_inf
,
inf
)
g
=
generate_graph
(
integral
,
Node
)
expect
=
self
.
strip
(
"""
g
=
generate_graph
(
integral
,
Node
,
verbose
=
True
)
self
.
assertEqualGraphs
(
g
,
"""
int
╭─┼──╮
x - oo
│
oo
LL
"""
)
assert
g
==
expect
def
strip
(
self
,
str
):
return
str
.
replace
(
'
\
n
'
,
'
\
n
'
)[
1
:
-
1
]
def
assertEqualGraphs
(
self
,
g
,
expect
):
expect
=
self
.
strip
(
expect
)
if
g
!=
expect
:
print
'Expected:'
print
expect
print
'Got:'
print
g
raise
AssertionError
(
'Graph does not match expected value'
)
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