pyinterval
pyinterval copied to clipboard
Filter out zero-length components
I'm using the pyinterval
package to represent unions of open intervals. Thus I would like to have an easy way to get rid of components whose inf
and sup
are identical. Is there a more elegant way to do it than the following?
b = interval()
for i in a:
if i.sup > i.inf:
b |= i
a = b
The following should do the trick:
>>> x = interval([1, 3], [4])
>>> interval.new(c for c in x if c.inf < c.sup)
interval([1.0, 3.0])