I recommend using the newer portion library instead
Pyinter is a small and simple library written in Python for performing interval and discontinous range arithmetic.
>>> pyinter.openclosed(1.1, 12)
(1.1, 12]
>>> discontinous_range = pyinter.IntervalSet([pyinter.closedopen(5, 10), pyinter.closed(22, 23)])
>>> discontinous_range
IntervalSet([5, 10), [22, 23])
>>> 7 in discontinous_range
True
>>> 10 in discontinous_range
False # This isn't in the range as it is an open interval which doesn't include its end points
- interval objects which can be
- unioned
- intersected
- easily constructed using helper functions: open, closed, openclosed and closedopen
- interval sets which can be
- unioned
- intersected
To install Pyinter, simply:
$ pip install pyinter
Or, if you absolutely must:
$ easy_install pyinter
But I'm told you really shouldn't do that.
Documentation is available at http://pyinter.readthedocs.org.
Contributions or suggestions for improvements are welcome.