Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
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
TO
Helios Server
Commits
c2a668de
Commit
c2a668de
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
made pretty_results and datatypes more robust in the face of nulls
parent
431a6b33
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
helios/datatypes/__init__.py
+8
-1
8 additions, 1 deletion
helios/datatypes/__init__.py
helios/models.py
+7
-4
7 additions, 4 deletions
helios/models.py
with
15 additions
and
5 deletions
helios/datatypes/__init__.py
+
8
−
1
View file @
c2a668de
...
...
@@ -171,7 +171,10 @@ class LDObject(object):
self
.
structured_fields
[
f
]
=
sub_ld_object
# set the field on the wrapped object too
if
sub_ld_object
!=
None
:
self
.
_setattr_wrapped
(
f
,
sub_ld_object
.
wrapped_obj
)
else
:
self
.
_setattr_wrapped
(
f
,
None
)
else
:
# a simple type
new_val
=
self
.
process_value_in
(
f
,
d
[
f
])
...
...
@@ -203,6 +206,10 @@ class LDObject(object):
@classmethod
def
fromDict
(
cls
,
d
,
type_hint
=
None
):
# null objects
if
d
==
None
:
return
None
# the LD type is either in d or in type_hint
# FIXME: get this from the dictionary itself
ld_type
=
type_hint
...
...
This diff is collapsed.
Click to expand it.
helios/models.py
+
7
−
4
View file @
c2a668de
...
...
@@ -480,9 +480,12 @@ class Election(HeliosModel):
counts
=
sorted
(
enumerate
(
result
),
key
=
lambda
(
x
):
x
[
1
])
counts
.
reverse
()
the_max
=
question
[
'
max
'
]
or
1
the_min
=
question
[
'
min
'
]
or
0
# if there's a max > 1, we assume that the top MAX win
if
question
[
'
max
'
]
>
1
:
return
[
c
[
0
]
for
c
in
counts
[:
question
[
'
max
'
]
]]
if
the_
max
>
1
:
return
[
c
[
0
]
for
c
in
counts
[:
the_
max
]]
# if max = 1, then depends on absolute or relative
if
question
[
'
result_type
'
]
==
'
absolute
'
:
...
...
@@ -490,8 +493,8 @@ class Election(HeliosModel):
return
[
counts
[
0
][
0
]]
else
:
return
[]
if
question
[
'
result_type
'
]
==
'
relative
'
:
else
:
# assumes that anything non-absolute is
relative
return
[
counts
[
0
][
0
]]
@property
...
...
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