Superbird11 / ranges

Continuous Range, RangeSet, and RangeDict data structures for Python
MIT License
101 stars 10 forks source link

RangeDict unexpected item membership behavior #4

Closed jtmoon79 closed 3 years ago

jtmoon79 commented 4 years ago

The last statement value is unexpected

>>> from ranges import RangeDict, Range
>>> rd = RangeDict()
>>> rd[Range(0,5)] = 'zero to five'
>>> Range(0,5) in rd
True
>>> Range(0,4) in rd
True
>>> Range(1,4) in rd
True
>>> Range(1,5) in rd
False

Using Python 3.8.1 on Windows. ranges version 0.1.3.

Superbird11 commented 3 years ago

The bounds-checking function for Range was not using any special behavior if the other argument was also a Range, and so wasn't caring. This is kind of an edge case, but going along with the change suggested in issue #7, it makes sense.