Equal-Vote / starpy

Python implementation of the STAR Voting system
https://www.starvoting.org/
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

Should TrueTie([1, 0]) == TrueTie([1, 0])? #18

Open endolith opened 2 years ago

endolith commented 2 years ago

Currently this is False.

Probably should be True and probably TrueTie should be a subclass of set, similar to my comment on https://github.com/Equal-Vote/starpy/pull/17#issuecomment-1207539205?

So that TrueTie([1, 0]) == TrueTie((0, 1)) == TrueTie({1, 0, 1}) is also True.

TrueTie([1, 0]) == TrueTie([1, 0])
Out[53]: False

set([0, 1]) == set((1, 0)) == set({1, 0, 1})
Out[54]: True
endolith commented 2 years ago

Also would be good if TrueTie had a __repr__ that showed the tied winners? Instead of <STAR.TrueTie at 0x188dc2885c8>. If TrueTie({0, 1}) had a __repr__ of TrueTie({0, 1}), it would fit the convention of "If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value"

mikefranze commented 2 years ago

Quick fix would be TrueTie([1,0]).tied ==TrueTie([1,0]).tied, but wouldn't work if elements are out of order. I'll think on the set vs list issue.

mikefranze commented 2 years ago

Tried changing to set in #17, seems to work well.