Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
artoonie committed Sep 30, 2024
1 parent 3949bc8 commit 8a31ab5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions static/bargraph/barchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ function makeBarGraph(args) {
if(isEliminatedThisRound(d) || !isVertical) {
return "";
}
let percentDenominator;
if (lastRoundNumWinners > 1) {
percentDenominator = totalVotesPerRound[0];
} else {
Expand Down
16 changes: 8 additions & 8 deletions visualizer/graph/graphSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ def __init__(self, graph):
self.numWinners = len(self.winnerNames)
self.numEliminated = sum(len(r.eliminatedNames) for r in rounds)

# percentDenominator is either the current round total in IRV,
# and the first round total in STV
def percentDenominator(self, roundNum):
if self.numWinners <= 1:
return self.rounds[roundNum].totalActiveVotes
else:
return self.rounds[0].totalActiveVotes

def percent_denominator(self, roundNum):
"""
percentDenominator is either the current round total in IRV,
and the first round total in STV.
"""
if self.numWinners > 1:
roundNum = 0
return self.rounds[roundNum].totalActiveVotes


class RoundInfo:
Expand Down
6 changes: 3 additions & 3 deletions visualizer/tabular/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, graph, config):
d['change'] = changify(votesAddedThisRound)

myNumVotes = cinfo.totalVotesPerRound[roundNum]
percentDenominator = summary.percentDenominator(roundNum)
percentDenominator = summary.percent_denominator(roundNum)
d['primaryLabel'], d['secondaryLabel'] = makePrimarySecondaryLabels(
myNumVotes, percentDenominator, item)
d['name'] = cinfo.name
Expand Down Expand Up @@ -117,7 +117,7 @@ def __init__(self, graph, item):
self.rounds = range(numRounds)
for i, myNumVotes in enumerate(candidateInfo.totalVotesPerRound):
thisRoundSummary = summary.rounds[i]
percentDenominator = summary.percentDenominator(i)
percentDenominator = summary.percent_denominator(i)
self.eachRound.append(OneCandidateOneRound(
thisRoundSummary, myNumVotes, percentDenominator, item))

Expand Down Expand Up @@ -199,7 +199,7 @@ def __init__(self, config, totalActiveVotes, round_i, item, summary, linksForThi
self.round_i = round_i + 1

myNumVotes = float(totalActiveVotes)
percentDenominator = summary.percentDenominator(round_i)
percentDenominator = summary.percent_denominator(round_i)
self.primaryLabel, self.secondaryLabel = makePrimarySecondaryLabels(
myNumVotes, percentDenominator, item)

Expand Down

0 comments on commit 8a31ab5

Please sign in to comment.