kvesteri / intervals

Python tools for handling intervals (ranges of comparable objects).
BSD 3-Clause "New" or "Revised" License
107 stars 17 forks source link

Intersection should be commutative #22

Closed arimbr closed 9 years ago

arimbr commented 10 years ago

I get these results

In [8]: IntInterval((1, 2)) & IntInterval([1, 2]) Out[8]: IntInterval('[1, 2)')

In [9]: IntInterval([1, 2]) & IntInterval((1, 2)) Out[9]: IntInterval('(1, 2]')

I would expect these to be True

IntInterval((1, 2)) & IntInterval([1, 2]) == IntInterval((1, 2)) IntInterval([1, 2]) & IntInterval((1, 2)) == IntInterval((1, 2))

Nor 1 or 2 should be included in the intersection in my opinion (I am considering the intersection to be the elements that are present in both intervals), but in any case the intersection should be commutative.