Work around CloneProofSSD returning [nil] rather than [] for empty vote
[rubyvote] / lib / rubyvote / condorcet.rb
index 65c664dd28a57417aa0a90395562289c8de0eed4..aaa504477373e07735b6eab9b7c847db0c68232a 100644 (file)
@@ -184,7 +184,10 @@ class PureCondorcetResult < CondorcetResult
   def condorcet
     votes = @election.votes
     candidates = @election.candidates
-
+    unless votes.length>0 and candidates.length>0
+      @winners=[]
+      return @winners
+    end
     victors = Hash.new
     candidates.each do |candidate|
       victors[candidate] = Array.new
@@ -214,6 +217,7 @@ class CloneproofSSDResult < CondorcetResult
   def initialize(voteobj=nil)
     super(voteobj)
     @winners = self.cpssd()
+    @winners.delete nil
   end
 
   protected

Benjamin Mako Hill || Want to submit a patch?