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
c0a73ab4
Commit
c0a73ab4
authored
Mar 14, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further improved multiplication sign omission.
parent
01cf1342
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
line.py
line.py
+3
-2
tests/test_line.py
tests/test_line.py
+3
-0
No files found.
line.py
View file @
c0a73ab4
...
@@ -168,9 +168,10 @@ def generate_line(root):
...
@@ -168,9 +168,10 @@ def generate_line(root):
# 2 * a -> 2a
# 2 * a -> 2a
l
=
e
[
0
][
-
1
]
l
=
e
[
0
][
-
1
]
r
=
e
[
1
][
0
]
r
=
e
[
1
][
0
]
left_simple
=
is_id
(
left
)
or
is_int
(
left
)
if
r
==
'('
or
(
l
==
')'
and
r
!=
'-'
)
\
if
(
r
==
'('
and
left_simple
)
or
(
l
==
')'
and
r
!=
'-'
)
\
or
(
(
is_id
(
left
)
or
is_int
(
left
))
and
r
.
isalpha
()):
or
(
left_simple
and
r
.
isalpha
()):
sep
=
''
sep
=
''
exp
=
sep
.
join
(
e
)
exp
=
sep
.
join
(
e
)
...
...
tests/test_line.py
View file @
c0a73ab4
...
@@ -155,6 +155,9 @@ class TestLine(unittest.TestCase):
...
@@ -155,6 +155,9 @@ class TestLine(unittest.TestCase):
mul
=
N
(
'*'
,
l2
,
N
(
'^'
,
l2
,
a
))
mul
=
N
(
'*'
,
l2
,
N
(
'^'
,
l2
,
a
))
self
.
assertEquals
(
generate_line
(
mul
),
'2 * 2 ^ a'
)
self
.
assertEquals
(
generate_line
(
mul
),
'2 * 2 ^ a'
)
mul
=
N
(
'*'
,
N
(
'/'
,
a
,
l2
),
N
(
'+'
,
a
,
b
))
self
.
assertEquals
(
generate_line
(
mul
),
'a / 2 * (a + b)'
)
def
test_plus_to_minus
(
self
):
def
test_plus_to_minus
(
self
):
plus
=
N
(
'+'
,
L
(
1
),
-
L
(
2
))
plus
=
N
(
'+'
,
L
(
1
),
-
L
(
2
))
self
.
assertEquals
(
generate_line
(
plus
),
'1 - 2'
)
self
.
assertEquals
(
generate_line
(
plus
),
'1 - 2'
)
...
...
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