Skip to content

ENH: Gracefully handle empty intervals in difference (or other operators) #56

Closed
@damien-sornette

Description

@damien-sornette

Problem

Currently, passing an empty IntervalArray or IntervalSet to the difference operator will cause an error to be thrown. It's not so much a problem when you just make a difference between two elements, a simple if will protect you. However, it becomes a bit tedious to handle with 3 elements where the second and third can sometimes be empty. The number of possible cases becomes exponentially higher when you add more sets.

Of course you can add the arguments in an array and the iterate over them to "accumulate" the difference, but it seems overcomplicated for something that could be handled gracefully by the lib

Unless there is a reason not to ?

Solution

When an empty argument is passed, it is ignored, and the reference (leftmost argument) interval is returned. And if the left most argument is empty, then return it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions