from interval import Interval, IntervalSet
data = [(2, 4), (9, 13), (6, 12)]
intervals = IntervalSet([Interval.between(min, max) for min, max in data])
print ([(i.lower_bound, i.upper_bound) for i in intervals])
But it reported an error, and I haven’t found a solution to a similar problem for a long time:
Traceback (most recent call last):
File "/Users/zhongyongbin/Desktop/sapm/change-server/code/utils/handle_database/test_intercept.py", line 13, in <module>
intervals = IntervalSet([Interval(min, max) for min, max in data])
File "/usr/local/lib/python3.9/site-packages/interval.py", line 2065, in __init__
BaseIntervalSet.__init__(self, items)
File "/usr/local/lib/python3.9/site-packages/interval.py", line 922, in __init__
self._add(i)
File "/usr/local/lib/python3.9/site-packages/interval.py", line 1935, in _add
self.intervals.sort()
TypeError: '<' not supported between instances of 'Interval' and 'Interval'
When I follow the example and use as follows:
But it reported an error, and I haven’t found a solution to a similar problem for a long time:
use python 3.9