Skip to content

Union of isdisjoint intervals #191

Open
@ps-pat

Description

@ps-pat

Right now, this is the error message we get when trying to compute the union of incompatible intervals:

julia> OpenInterval(1, 2)  OpenInterval(2, 3)
ERROR: ArgumentError: Cannot construct union of disjoint sets.

It is a little bit confusing since it is possible to construct the union of disjoint intervals as long as they share an endpoint:

julia> isdisjoint(OpenInterval(1, 2), OpenInterval(2, 3))
true
julia> OpenInterval(1, 2)  ClosedInterval(2, 3)
1 .. 3 (open-closed)

The confusion arises from such a pair of intervals being disjoint but connected sets. Maybe the error message should be changed to reflect that. Also, right now, in order to check if two intervals are disconnected, you have to do something like

isdisjoint(A, B) && !=(endpoints(A  B)...)

which is a little bit inefficient since it computes A ∩ B twice or go full-on with

AB = A  B
isempty(AB) && !=(endpoints(AB)...)

which is kind of lengthy. Maybe it would make sense to have a isconnected method?

All in all fairly minor issue, but it got me a little bit confused as a first-time user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions