kvesteri / intervals

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

TypeError: '<' not supported between instances of 'Interval' and 'Interval' #55

Open zhongyongbin1 opened 3 years ago

zhongyongbin1 commented 3 years ago

When I follow the example and use as follows:

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'

use python 3.9

sunxiuqiang commented 2 years ago

This error will be soved if you use interval3 package instead of interval.