orderedset
orderedset copied to clipboard
Fix __ge__ and __gt__ comparison methods
Quoting the Python documentation for sets:
"The subset and equality comparisons do not generalize to a total ordering function. For example, any two nonempty disjoint sets are not equal and are not subsets of each other, so all of the following return False: a<b, a==b, or a>b."
It is therefore not possible to define ge as the inverse of lt (and similarly gt as the inverse of le), since this will give false positive results.
Fix by implementing ge and gt using equivalent logic to that used in le and lt.
Signed-off-by: Michael Brown [email protected]
Do you have any queries or requested changes? Would it help if I opened an issue to report the original bug that is fixed by this patch?
Thanks,
Michael
@simonpercivall Any thoughts on this PR?
Until this issue is resolved here, may want to check out https://github.com/simonpercivall/orderedset/issues/38 As this issue is also fixed in https://pypi.org/project/stableset/