Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PET-rating
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
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
Timo Heikkilä
PET-rating
Commits
16ef1ffa
Commit
16ef1ffa
authored
4 years ago
by
Ossi Laine
Browse files
Options
Downloads
Patches
Plain Diff
Added utils module
parent
886193cb
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/utils.py
+17
-0
17 additions, 0 deletions
app/utils.py
with
17 additions
and
0 deletions
app/utils.py
0 → 100644
+
17
−
0
View file @
16ef1ffa
from
itertools
import
zip_longest
def
map_values_to_int
(
values
:
dict
):
values
=
[
map
(
int
,
i
)
for
i
in
list
(
values
.
values
())]
return
zip_longest
(
*
values
,
fillvalue
=
None
)
def
calculate_mean
(
values
:
list
)
->
float
:
n_answers
=
sum
(
x
is
not
None
for
x
in
values
)
sum_of_answers
=
float
(
sum
(
filter
(
None
,
values
)))
mean
=
sum_of_answers
/
n_answers
return
round
(
mean
,
2
)
def
get_mean_from_slider_answers
(
answers
):
return
[
calculate_mean
(
values
)
for
values
in
map_values_to_int
(
answers
)]
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