Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
crossroads segmentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Jean-Marie Favreau
crossroads segmentation
Commits
85222339
Commit
85222339
authored
3 years ago
by
Jean-Marie Favreau
Browse files
Options
Downloads
Patches
Plain Diff
Add a script to generate stats on crossroads
parent
7824a65a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/stats-intersection-info.py
+78
-0
78 additions, 0 deletions
src/stats-intersection-info.py
with
78 additions
and
0 deletions
src/stats-intersection-info.py
0 → 100755
+
78
−
0
View file @
85222339
#!/usr/bin/env python3
# coding: utf-8
import
argparse
import
json
def
is_evaluated
(
entry
):
for
el
in
entry
:
if
el
[
"
type
"
]
==
"
evaluation
"
:
return
True
return
False
def
is_single_node
(
entry
):
for
el
in
entry
:
if
el
[
"
type
"
]
==
"
crossroad
"
:
return
len
(
el
[
"
nodes
"
][
"
inner
"
])
+
len
(
el
[
"
nodes
"
][
"
border
"
])
==
1
# should never append
return
0
def
get_nb_complex
(
entry
):
d
=
{}
for
el
in
entry
:
if
el
[
"
type
"
]
in
[
"
crossroad
"
,
"
branch
"
]:
for
l
in
[
"
inner
"
,
"
border
"
]:
for
n
in
el
[
"
nodes
"
][
l
]:
if
n
in
d
:
d
[
n
]
+=
1
else
:
d
[
n
]
=
1
nb
=
0
for
e
in
d
:
if
d
[
e
]
>
2
:
nb
+=
1
return
nb
def
get_stats
(
entries
,
latex
):
nb_intersections
=
len
(
entries
)
nb_single
=
len
([
e
for
e
in
entries
if
is_single_node
(
e
)])
complexity
=
[
get_nb_complex
(
e
)
for
e
in
entries
]
nb_complex
=
len
([
e
for
e
in
complexity
if
e
>
1
])
nb_intermediate
=
nb_intersections
-
nb_complex
-
nb_single
if
latex
:
print
(
'
&
'
.
join
(
map
(
str
,
[
nb_intersections
,
nb_single
,
nb_intermediate
,
nb_complex
]))
+
"
\\\\
"
)
else
:
print
(
"
Nb:
"
,
nb_intersections
)
print
(
"
1 node:
"
,
nb_single
,
"
(
"
,
f
'
{
(
nb_single
/
nb_intersections
*
100
)
:
.
1
f
}
'
,
"
%)
"
)
print
(
"
n nodes, 1 complex node:
"
,
nb_intermediate
,
"
(
"
,
f
'
{
(
nb_intermediate
/
nb_intersections
*
100
)
:
.
1
f
}
'
,
"
%)
"
)
print
(
"
n complex nodes:
"
,
nb_complex
,
"
(
"
,
f
'
{
(
nb_complex
/
nb_intersections
*
100
)
:
.
1
f
}
'
,
"
%)
"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"
Print statistics from a set of crossroads (intersections) contained in a json file.
"
)
parser
.
add_argument
(
'
-i
'
,
'
--input
'
,
help
=
'
Input json file
'
,
type
=
argparse
.
FileType
(
'
r
'
),
required
=
True
)
parser
.
add_argument
(
'
-l
'
,
'
--latex
'
,
help
=
'
LaTeX output
'
,
action
=
'
store_true
'
)
args
=
parser
.
parse_args
()
# load data
all
=
json
.
load
(
args
.
input
)
evaluated
=
[
e
for
e
in
all
if
is_evaluated
(
e
)]
if
args
.
latex
:
print
(
"
% stats
"
,
args
.
input
.
name
)
get_stats
(
all
,
True
)
print
(
"
% stats on evaluated
"
)
get_stats
(
evaluated
,
True
)
else
:
print
(
"
Stats:
"
)
get_stats
(
all
)
print
(
""
)
print
(
"
Stats on evaluated:
"
)
get_stats
(
evaluated
)
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