Skip to content

Instantly share code, notes, and snippets.

@cmutel

cmutel/ontology_voting.py

Last active Apr 9, 2019
Embed
What would you like to do?
BONSAI voting on nomenclature for "flow object" possible replacement
orig_data = """BDACFE
DCAFBE
AFDCEB
ADCFBE
CAEBDF
DCABFGHE
AFCED
DCAFBEGH
BGEACDH""".split("\n")
LETTERS = "ABCDEFGH"
def _(x, s, default):
try:
return s.index(x) + 1
except ValueError:
return default + 1
mapping = {x: i + 1 for i, x in enumerate(LETTERS)}
data = [[_(letter, line, len(LETTERS)) for letter in LETTERS] for line in orig_data]
for line in data:
print(str(line)[1:-1])
import numpy as np
for letter in LETTERS:
print(letter, np.average([_(letter, line, len(LETTERS)) for line in orig_data]))
@cmutel

This comment has been minimized.

Copy link
Owner Author

@cmutel cmutel commented Apr 8, 2019

To do instant runoff voting, use https://petertheone.github.io/IRV/

Use this list of candidates:
A
B
C
D
E
F

And these responses printed out by this gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment