simonpercivall / orderedset

Ordered Set implementation in Cython
Other
74 stars 14 forks source link

Fix __ge__ and __gt__ comparison methods #22

Open mcb30 opened 5 years ago

mcb30 commented 5 years ago

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 mbrown@fensystems.co.uk

mcb30 commented 5 years ago

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

azmeuk commented 4 years ago

@simonpercivall Any thoughts on this PR?

idanmiara commented 1 year ago

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/