Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
cate
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PCOG
cate
Commits
cb0f6cfd
Verified
Commit
cb0f6cfd
authored
Oct 15, 2018
by
Raphaël Bleuse
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move computation of crossing levels to Template
parent
409b1738
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
src/cate/core.py
src/cate/core.py
+16
-0
src/cate/main.py
src/cate/main.py
+4
-10
No files found.
src/cate/core.py
View file @
cb0f6cfd
...
...
@@ -5,8 +5,13 @@ Core routines and optimization logic.
"""
import
json
import
logging
from
.
import
check
from
.
import
_legacy
# XXX get rid of this!
logger
=
logging
.
getLogger
(
__name__
)
# pylint: disable=invalid-name
def
final_position
(
matrix
):
...
...
@@ -36,6 +41,7 @@ class Template:
if
not
check
.
is_linking
(
matrix
):
raise
ValueError
(
'Invalid linking matrix'
)
self
.
matrix
=
matrix
self
.
__crosslevels
=
None
@
classmethod
def
from_json
(
cls
,
fp
):
...
...
@@ -74,3 +80,13 @@ class Template:
raise
TypeError
(
'Invalid input structure'
)
return
cls
(
matrix
)
@
property
def
crosslevels
(
self
):
"""Level-by-level list of concurrent crossings of the template."""
if
self
.
__crosslevels
is
None
:
logger
.
info
(
'Starting optimization of template depth'
)
optimizer
=
_legacy
.
Tree
.
from_matrix
(
self
.
matrix
)
self
.
__crosslevels
=
optimizer
.
getShortestPaths
()
logger
.
info
(
'Finished optimization of template depth'
)
return
self
.
__crosslevels
src/cate/main.py
View file @
cb0f6cfd
...
...
@@ -29,22 +29,16 @@ def run(infile, *, output, color=True, complete_flow=False, scale=1.0):
exit
(
code
=
2
)
logger
.
info
(
'Input matrix'
)
for
m
in
template
.
matrix
:
logger
.
info
(
f
' {m}'
)
logger
.
info
(
"Starting constructing the tree"
)
myTree
=
_legacy
.
Tree
.
from_matrix
(
template
.
matrix
)
logger
.
info
(
"Finished constructing the tree"
)
for
row
in
template
.
matrix
:
logger
.
info
(
f
' {row}'
)
logger
.
info
(
"Starting creation of the SVG template"
)
try
:
if
output
==
'-'
:
# the special argument '-' means stdout
shortestPath
=
myTree
.
getShortestPaths
()
_legacy
.
drawSVGTemplate
(
template
.
matrix
,
shortestPath
,
sys
.
stdout
,
entireTemplate
=
complete_flow
,
white
=
not
color
,
scale
=
scale
)
_legacy
.
drawSVGTemplate
(
template
.
matrix
,
template
.
crosslevels
,
sys
.
stdout
,
entireTemplate
=
complete_flow
,
white
=
not
color
,
scale
=
scale
)
else
:
with
open
(
output
,
mode
=
'w'
)
as
fp
:
shortestPath
=
myTree
.
getShortestPaths
()
_legacy
.
drawSVGTemplate
(
template
.
matrix
,
shortestPath
,
fp
,
entireTemplate
=
complete_flow
,
white
=
not
color
,
scale
=
scale
)
_legacy
.
drawSVGTemplate
(
template
.
matrix
,
template
.
crosslevels
,
fp
,
entireTemplate
=
complete_flow
,
white
=
not
color
,
scale
=
scale
)
except
OSError
as
err
:
logger
.
critical
(
f
'Unable to write output: {err}'
)
exit
(
code
=
2
)
...
...
Raphaël Bleuse
@rbleuse
mentioned in issue
#7 (closed)
·
Oct 25, 2018
mentioned in issue
#7 (closed)
mentioned in issue #7
Toggle commit list
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