Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setdiff returns a disjoint representation, whereas union does not #424

Open
goretkin opened this issue Nov 17, 2020 · 3 comments
Open

setdiff returns a disjoint representation, whereas union does not #424

goretkin opened this issue Nov 17, 2020 · 3 comments

Comments

@goretkin
Copy link

This strikes me as inconsistent:

julia> union(interval(0, 1), interval(2, 3))
[0, 3]

julia> setdiff(interval(0, 3), interval(1,2))
2-element Array{Interval{Float64},1}:
 [0, 1]
 [2, 3]
@dpsanders
Copy link
Member

It's true that in some sense it's inconsistent, but it's what is useful.
union here really means "interval hull". (There is also the synonym hull.)

If you want union to return a vector of intervals, that's a whole different world (which I have coded somewhere).

@goretkin
Copy link
Author

goretkin commented Nov 17, 2020

I suppose there are two separate issues, one is consistency in which some operations have an implicit "hull" and others do not.

The other issue is about type closure. It would be good if e.g. (even assuming b and c are overlapping to remove the question about whether union should return a hull or a disjoint set)

setdiff(a, union(b,c)) == setdiff(setdiff(a, b), c))

but since setdiff(a, b) returns something that itself cannot carry the semantics of a union of intervals (Unless everywhere Array{Interval} means "union of itnervals", which is almost certainly not tenable).

So probably setdiff should return an object that can only mean "union of intervals".

@dpsanders
Copy link
Member

Yes, that's a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants