Skip to content

IntervalSet.union and IntervalSet.intersection should accept Interval objects #25

Description

@AlexandreDecan

Right now, it's not possible to write closed(3,4) | closed(5,6) | closed(4,5). It results in a TypeError saying that Interval object is not iterable.

The current workaround is to wrap the Interval object into a IntervalSet, e.g. closed(3,4) | closed(5,6) | IntervalSet([closed(4,5)]) which is not very convenient.

A simple way to support the first notation could be to add:

other = IntervalSet([other]) if isinstance(other, Interval) else other

It could actually be a good idea to have Interval objects also supporting IntervalSet. In that case, an easy way could be to add:

if isinstance(other, IntervalSet):
  return other.union(self)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions