Skip to content

Commit

Permalink
Suppress invalid value warning in cast
Browse files Browse the repository at this point in the history
When hypothesis generates all-zero utilities array, we get a
RuntimeWarning: invalid value encountered in cast in line
    return np.around(normed).astype(np.uint8)
  • Loading branch information
endolith committed Jul 5, 2024
1 parent bc962d9 commit b23bfeb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions elsim/strategies/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ def honest_normed_scores(utilities, max_score=5):
# Normalize every voter's maximum utility to 1
normed /= np.amax(normed, axis=1)[:, np.newaxis]

# Normalize every voter's maximum score to max_score
normed *= max_score
# Normalize every voter's maximum score to max_score
normed *= max_score

scores = np.around(normed).astype(np.uint8)

# Quantize to discrete scale
return np.around(normed).astype(np.uint8)
return scores


def approval_optimal(utilities):
Expand Down

0 comments on commit b23bfeb

Please sign in to comment.