Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VOB
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
Container Registry
Model registry
Operate
Environments
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
Petra Gospodnetic
VOB
Commits
2d32265d
Commit
2d32265d
authored
4 years ago
by
gospodnetic
Browse files
Options
Downloads
Patches
Plain Diff
Add peak and trough plots
parent
d64b0591
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Vis.py
+78
-1
78 additions, 1 deletion
Vis.py
with
78 additions
and
1 deletion
Vis.py
+
78
−
1
View file @
2d32265d
...
...
@@ -15,8 +15,8 @@ class Vis:
fig
=
plt
.
figure
()
ax
=
fig
.
add_subplot
(
111
)
per_method_coverage
=
[]
for
log
in
logs
:
per_method_coverage
=
[]
per_method_coverage
.
append
(
util
.
convert_to_percentage
(
log
.
get_cumulative_coverage_per_vp
()))
...
...
@@ -30,6 +30,14 @@ class Vis:
ax
.
set_xlabel
(
"
Number of viewpoints
"
)
ax
.
set_ylabel
(
"
Coverage [%]
"
)
fig
.
suptitle
(
approach
)
peaks
,
troughs
=
self
.
__stacked_coverage_find_peaks_and_troughs
(
per_method_coverage
)
peaks
=
self
.
__filter_falling_peaks
(
peaks
)
# plt.plot(peaks, c="#009e28", ls="--", lw=2, alpha=0.5)
ax
.
plot
(
peaks
,
c
=
"
blue
"
,
ls
=
"
--
"
,
lw
=
2
,
alpha
=
0.5
)
ax
.
plot
(
troughs
,
c
=
"
#e36120
"
,
ls
=
"
--
"
,
lw
=
2
,
alpha
=
0.7
)
self
.
figures
.
append
(
fig
)
# It will show all currently created figures.
...
...
@@ -46,3 +54,72 @@ class Vis:
filename
=
output_path
+
label
figure
.
savefig
(
filename
)
# Stacked coverages are of different lengths, pad shorter ones by
# repeating the last value.
def
__pad_to_matrix
(
self
,
stacked_coverage
):
max_length
=
0
for
row
in
stacked_coverage
:
if
len
(
row
)
>
max_length
:
max_length
=
len
(
row
)
matrix_stacked_coverage
=
[]
for
row
in
stacked_coverage
:
if
len
(
row
)
<
max_length
:
length_difference
=
max_length
-
len
(
row
)
padding
=
np
.
full
(
length_difference
,
row
[
-
1
])
row
=
np
.
concatenate
([
row
,
padding
])
matrix_stacked_coverage
.
append
(
row
)
return
matrix_stacked_coverage
# For each viewpoint ste, find maximal value from 2D data representing
# stacked multiple coverage arrays (coverage per VP contribution of multiple methods)
def
__stacked_coverage_find_peaks_and_troughs
(
self
,
stacked_coverage
):
plot_min_padded_to_max_length
=
True
# Find method with the most viewpoints (length of coverage vector = viewpoint count)
max_length
=
0
min_length
=
len
(
stacked_coverage
[
0
])
for
row
in
stacked_coverage
:
if
len
(
row
)
>
max_length
:
max_length
=
len
(
row
)
if
len
(
row
)
<
min_length
:
min_length
=
len
(
row
)
if
plot_min_padded_to_max_length
:
stacked_coverage
=
self
.
__pad_to_matrix
(
stacked_coverage
)
peaks
=
[]
troughs
=
[]
for
i
in
range
(
max_length
):
max_val
=
0
min_val
=
100
for
row
in
stacked_coverage
:
# Check if there are enough elements.
if
len
(
row
)
<=
i
:
continue
if
row
[
i
]
>
max_val
:
max_val
=
row
[
i
]
if
row
[
i
]
<
min_val
:
min_val
=
row
[
i
]
peaks
.
append
(
max_val
)
if
plot_min_padded_to_max_length
:
troughs
.
append
(
min_val
)
elif
i
<
min_length
:
troughs
.
append
(
min_val
)
# Plots minimum curve using all the coverages.
# else:
# troughs.append(troughs[-1])
return
peaks
,
troughs
# Cumulative values can not fall, and falling peaks will appear if some methods
# have more viewpoints than the others
def
__filter_falling_peaks
(
self
,
peaks
):
for
i
in
range
(
1
,
len
(
peaks
)):
if
peaks
[
i
]
<
peaks
[
i
-
1
]:
peaks
[
i
]
=
peaks
[
i
-
1
]
return
peaks
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