Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Liquid Majority Judgment
Limaju CLI Python
Commits
96db16fa
Commit
96db16fa
authored
Dec 19, 2019
by
Dominique Merle
💬
Browse files
Provide sort_candidates() API.
parent
d2f1bfbc
Changes
1
Hide whitespace changes
Inline
Side-by-side
limaju/limaju.py
View file @
96db16fa
...
...
@@ -112,7 +112,7 @@ def decrement_mention(tally, mention):
tally
[
mention
]
-=
1
def
sort_two_candidates
(
judgments_of
,
tally_of
,
mentions
,
ca
,
cb
):
def
sort_two_candidates
(
tally_of
,
mentions
,
ca
,
cb
):
toca
=
tally_of
[
ca
]
tocb
=
tally_of
[
cb
]
mdca
=
get_median
(
toca
,
mentions
)
...
...
@@ -250,19 +250,33 @@ def deliberate(judgments_data,
# Here we could hook to external, replaceable classes
# to simplify usage of other algorithms.
return
sort_two_candidates
(
everyones_judgments
,
judgments_tallies
,
mentions
,
ca
,
cb
)
sorted_candidates
=
sort_candidates
(
judgments_tallies
,
candidates_list
,
mentions
)
return
sorted_candidates
,
judgments_tallies
def
sort_candidates
(
judgments_tallies
,
candidates
,
mentions
):
def
_cmp_candidates
(
ca
,
cb
):
# Here we could hook to external, replaceable classes
# to simplify usage of other algorithms.
return
sort_two_candidates
(
judgments_tallies
,
mentions
,
ca
,
cb
)
sorted_candidates
=
sorted
(
candidates
_list
,
return
sorted
(
candidates
,
key
=
cmp_to_key
(
_cmp_candidates
)
)
return
sorted_candidates
,
judgments_tallies
def
main
(
args_parser
,
args
):
# move to bottom, no need for a func
log
(
"MAJORITY JUDGMENT POLLING -- Version %s"
%
__version__
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment