-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Typescript version of STAR-PR with tests #268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall
I just did a quick scan over the implementation, but if the tests pass then I trust it
expect(results.summaryData.weightedScoresByRound[1]).toStrictEqual([0, 0, 16, 23]); | ||
}) | ||
test("Fractional surplus", () => { | ||
// Two winners, two main parties, Allison wins first round with highest score, Allison has 8 highest level supporters, more than the quota of 6 voters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if Allison's highest level supporters has 4 5s and 4 4s? Does the fractional surplus work any differently? If so, can we add another test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, it is handled slightly different. Added extra test case.
} | ||
} | ||
// converts list of strings to string with correct grammar ([a,b,c] => 'a, b, and c') | ||
const formatter = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this variable used? The logic seems like a front end problem, so I was surprised to see it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was accidently copied over from the STAR tabulator which uses it to write human readable logs. It could possibly be used in all the tabulators but removed it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test, approved!
Updating STAR-PR (Allocated Score) to typescript with a few basic tests.
Currently the random tiebreaker works, but there are some cases where numerical errors can prevent ties from being found (Equal-Vote/starpy#23). This isn't a huge deal at the moment since the ties will be broken randomly and the numerical errors are probably random, but it'll be best to be able to at least identify ties.
I suspect it is related to or exacerbated by the scores normalization, so removing that will be the first step.