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
7f65d03d
Commit
7f65d03d
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Fixed multiplication sign omission when left node ends with a digit."
This reverts commit
821c5062
.
parent
821c5062
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
line.py
+8
-4
8 additions, 4 deletions
line.py
tests/test_line.py
+6
-4
6 additions, 4 deletions
tests/test_line.py
with
14 additions
and
8 deletions
line.py
+
8
−
4
View file @
7f65d03d
...
...
@@ -39,6 +39,10 @@ def is_id(node):
return
node
.
is_leaf
and
not
node
.
title
().
isdigit
()
def
is_int
(
node
):
return
node
.
is_leaf
and
node
.
title
().
isdigit
()
def
is_power
(
node
):
return
not
node
.
is_leaf
and
node
.
title
()
==
'
^
'
...
...
@@ -162,11 +166,11 @@ def generate_line(root):
# (a) * b -> (a)b
# (a) * (b) -> (a)(b)
# 2 * a -> 2a
left_en
d
=
e
[
0
][
-
1
]
right_
begi
n
=
e
[
1
][
0
]
left_
par
en
=
e
[
0
][
-
1
]
==
'
)
'
right_
pare
n
=
e
[
1
][
0
]
==
'
(
'
left_suited
=
left_
end
==
'
)
'
or
left_end
.
isdigit
(
)
or
is_i
d
(
left
)
right_suited
=
right_
begin
==
'
(
'
left_suited
=
left_
paren
or
is_id
(
left
)
or
is_i
nt
(
left
)
right_suited
=
right_
paren
if
not
right_suited
and
not
right
.
negated
:
right_suited
=
is_id
(
right
)
or
is_power
(
right
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_line.py
+
6
−
4
View file @
7f65d03d
...
...
@@ -3,7 +3,7 @@ import doctest
import
line
from
node
import
Node
as
N
,
Leaf
as
L
from
line
import
generate_line
,
is_id
,
is_power
from
line
import
generate_line
,
is_id
,
is_int
,
is_power
class
TestLine
(
unittest
.
TestCase
):
...
...
@@ -152,9 +152,6 @@ class TestLine(unittest.TestCase):
mul
=
N
(
'
*
'
,
l2
,
N
(
'
^
'
,
a
,
l2
))
self
.
assertEquals
(
generate_line
(
mul
),
'
2a ^ 2
'
)
mul
=
N
(
'
*
'
,
N
(
'
^
'
,
a
,
l2
),
N
(
'
+
'
,
a
,
b
))
self
.
assertEquals
(
generate_line
(
mul
),
'
a ^ 2(a + b)
'
)
def
test_plus_to_minus
(
self
):
plus
=
N
(
'
+
'
,
L
(
1
),
-
L
(
2
))
self
.
assertEquals
(
generate_line
(
plus
),
'
1 - 2
'
)
...
...
@@ -175,6 +172,11 @@ class TestLine(unittest.TestCase):
self
.
assertFalse
(
is_id
(
neg
))
self
.
assertFalse
(
is_id
(
plus
))
self
.
assertTrue
(
is_int
(
l1
))
self
.
assertTrue
(
is_int
(
neg
))
self
.
assertFalse
(
is_int
(
neg_a
))
self
.
assertFalse
(
is_int
(
plus
))
self
.
assertTrue
(
is_power
(
power
))
self
.
assertFalse
(
is_power
(
l1
))
self
.
assertFalse
(
is_power
(
plus
))
...
...
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