Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
338080ce
Commit
338080ce
authored
Jan 20, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update script to migrate to new format
parent
a80557e4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
dream/simulation/reformat.py
dream/simulation/reformat.py
+25
-1
No files found.
dream/simulation/reformat.py
View file @
338080ce
...
@@ -97,10 +97,34 @@ def format(m):
...
@@ -97,10 +97,34 @@ def format(m):
return
m
return
m
def
migrate_to_new_format
(
graph
):
new_graph
=
{
'graph'
:
{
'edge'
:
{}}}
for
node_id
,
node_data
in
graph
[
'nodes'
].
items
():
# some cleanups
if
node_data
.
get
(
'capacity'
):
node_data
[
'capacity'
]
=
float
(
node_data
[
'capacity'
])
node_data
.
pop
(
'isDummy'
,
None
)
node_data
.
pop
(
'id'
,
None
)
node_data
.
pop
(
'element_id'
,
None
)
coordinate
=
graph
[
'preference'
][
'coordinates'
].
get
(
node_id
)
node_data
[
'coordinate'
]
=
coordinate
print
node_data
[
'_class'
]
# TODO: discuss the new processing time data structure !
new_graph
[
'graph'
][
'node'
]
=
graph
[
'nodes'
]
for
edge_id
,
(
source
,
destination
,
data
)
in
graph
[
'edges'
].
items
():
data
[
'_class'
]
=
'Dream.Edge'
data
[
'source'
]
=
source
data
[
'destination'
]
=
destination
new_graph
[
'graph'
][
'edge'
][
edge_id
]
=
data
return
new_graph
with
open
(
sys
.
argv
[
1
])
as
infile
:
with
open
(
sys
.
argv
[
1
])
as
infile
:
m
=
json
.
load
(
infile
)
m
=
json
.
load
(
infile
)
m
.
update
(
format
(
m
)
)
m
=
migrate_to_new_format
(
m
)
#m.update(preferences=positionGraph(m))
#m.update(preferences=positionGraph(m))
with
open
(
sys
.
argv
[
1
],
"w"
)
as
outfile
:
with
open
(
sys
.
argv
[
1
],
"w"
)
as
outfile
:
...
...
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