Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Detection eddies
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
IPSL
LMD
DPAO
Detection eddies
Commits
ebe6e6e4
Commit
ebe6e6e4
authored
1 year ago
by
Lionel GUEZ
Browse files
Options
Downloads
Patches
Plain Diff
Add timings for script `trajectories.py`
parent
699ecbf0
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
Trajectories/Tests/perf_tests.json
+3
-2
3 additions, 2 deletions
Trajectories/Tests/perf_tests.json
Trajectories/trajectories.py
+18
-0
18 additions, 0 deletions
Trajectories/trajectories.py
with
21 additions
and
2 deletions
Trajectories/Tests/perf_tests.json
+
3
−
2
View file @
ebe6e6e4
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
"command"
:
[
"command"
:
[
"$src_dir/Trajectories/trajectories.py"
,
"$src_dir/Trajectories/trajectories.py"
,
"$PWD/Perf_cost_function/segments_cost_functions.gt"
"$PWD/Perf_cost_function/segments_cost_functions.gt"
]
],
}
"exclude_cmp"
:
[
"timings.txt"
]
}
}
}
This diff is collapsed.
Click to expand it.
Trajectories/trajectories.py
+
18
−
0
View file @
ebe6e6e4
...
@@ -18,6 +18,7 @@ import json
...
@@ -18,6 +18,7 @@ import json
import
sys
import
sys
import
report_graph
import
report_graph
import
numpy
as
np
import
numpy
as
np
import
time
def
new_traj
(
ind_traj
,
traj_prop
,
n
,
traj_vert_ind
):
def
new_traj
(
ind_traj
,
traj_prop
,
n
,
traj_vert_ind
):
"""
Assign new trajectory to vertex index n.
"""
"""
Assign new trajectory to vertex index n.
"""
...
@@ -27,6 +28,8 @@ def new_traj(ind_traj, traj_prop, n, traj_vert_ind):
...
@@ -27,6 +28,8 @@ def new_traj(ind_traj, traj_prop, n, traj_vert_ind):
traj_vert_ind
.
append
([
n
])
traj_vert_ind
.
append
([
n
])
return
ind_traj
return
ind_traj
t0
=
time
.
perf_counter
()
timings_file
=
open
(
"
timings.txt
"
,
"
w
"
)
if
len
(
sys
.
argv
)
!=
2
:
sys
.
exit
(
"
Required argument: input-graph
"
)
if
len
(
sys
.
argv
)
!=
2
:
sys
.
exit
(
"
Required argument: input-graph
"
)
g
=
graph_tool
.
load_graph
(
sys
.
argv
[
1
])
g
=
graph_tool
.
load_graph
(
sys
.
argv
[
1
])
print
(
"
Input graph:
"
)
print
(
"
Input graph:
"
)
...
@@ -34,6 +37,9 @@ print("Number of vertices:", g.num_vertices())
...
@@ -34,6 +37,9 @@ print("Number of vertices:", g.num_vertices())
print
(
"
Number of edges:
"
,
g
.
num_edges
())
print
(
"
Number of edges:
"
,
g
.
num_edges
())
print
(
"
Internal properties:
"
)
print
(
"
Internal properties:
"
)
g
.
list_properties
()
g
.
list_properties
()
t1
=
time
.
perf_counter
()
timings_file
.
write
(
f
'
Loading done in
{
t1
-
t0
:
.
0
f
}
s
\n
'
)
t0
=
t1
if
"
cost_function
"
in
g
.
edge_properties
:
if
"
cost_function
"
in
g
.
edge_properties
:
closest_succ
=
g
.
new_vertex_property
(
'
int
'
)
closest_succ
=
g
.
new_vertex_property
(
'
int
'
)
...
@@ -55,6 +61,9 @@ else:
...
@@ -55,6 +61,9 @@ else:
# This happens if there are only isolated segments.
# This happens if there are only isolated segments.
print
(
"
No cost values in the input file.
"
)
print
(
"
No cost values in the input file.
"
)
t1
=
time
.
perf_counter
()
timings_file
.
write
(
f
'
closest_succ defined in
{
t1
-
t0
:
.
0
f
}
s
\n
'
)
t0
=
t1
traj_prop
=
g
.
new_vertex_property
(
'
int
'
,
val
=
-
1
)
traj_prop
=
g
.
new_vertex_property
(
'
int
'
,
val
=
-
1
)
# Trajectory index to which a segment belongs. - 1 means the segment
# Trajectory index to which a segment belongs. - 1 means the segment
# does not belong yet to any trajectory. The trajectory index is also
# does not belong yet to any trajectory. The trajectory index is also
...
@@ -144,6 +153,9 @@ for n in topology.topological_sort(g):
...
@@ -144,6 +153,9 @@ for n in topology.topological_sort(g):
# traj_prop[n] != - 1
# traj_prop[n] != - 1
t1
=
time
.
perf_counter
()
timings_file
.
write
(
f
'
traj_prop defined in
{
t1
-
t0
:
.
0
f
}
s
\n
'
)
t0
=
t1
print
(
"
Number of trajectories:
"
,
len
(
traj_vert_ind
))
print
(
"
Number of trajectories:
"
,
len
(
traj_vert_ind
))
# We have trajectories as lists of vertex indices. Now construct
# We have trajectories as lists of vertex indices. Now construct
...
@@ -173,6 +185,10 @@ for t in traj_vert_ind:
...
@@ -173,6 +185,10 @@ for t in traj_vert_ind:
traj_segm
.
append
(
list_segm
)
traj_segm
.
append
(
list_segm
)
expanded_traj
.
append
(
list_eddies_traj
)
expanded_traj
.
append
(
list_eddies_traj
)
t1
=
time
.
perf_counter
()
timings_file
.
write
(
f
'
traj_segm and expanded_traj defined in
{
t1
-
t0
:
.
0
f
}
s
\n
'
)
t0
=
t1
# Save:
# Save:
with
open
(
"
traj_segm.json
"
,
"
w
"
)
as
outfile
:
with
open
(
"
traj_segm.json
"
,
"
w
"
)
as
outfile
:
...
@@ -185,4 +201,6 @@ with open("expanded_traj.json", "w") as outfile:
...
@@ -185,4 +201,6 @@ with open("expanded_traj.json", "w") as outfile:
outfile
,
separators
=
(
'
,
'
,
'
:
'
))
outfile
,
separators
=
(
'
,
'
,
'
:
'
))
print
(
"
Created expanded_traj.json.
"
)
print
(
"
Created expanded_traj.json.
"
)
t1
=
time
.
perf_counter
()
timings_file
.
write
(
f
'
Saving done in
{
t1
-
t0
:
.
0
f
}
s
\n
'
)
print
(
'
Done
'
)
print
(
'
Done
'
)
This diff is collapsed.
Click to expand it.
GUEZ Lionel
@guez
mentioned in commit
a5e7bd7d
·
2 weeks ago
mentioned in commit
a5e7bd7d
mentioned in commit a5e7bd7d9cdc5430d19765aeeb3a3c41cc94e99c
Toggle commit list
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