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

Type piracy with the union operator #5

Open
dpsanders opened this issue May 5, 2021 · 4 comments · Fixed by #10
Open

Type piracy with the union operator #5

dpsanders opened this issue May 5, 2021 · 4 comments · Fixed by #10

Comments

@dpsanders
Copy link
Contributor

Loading this package pirates the union operator from IntervalArithmetic.
I guess this is OK but it should be documented.

@AnderGray
Copy link
Owner

This is a good point. We'll make a note of it in the documentation. I believe using hull between intervals should have the same functionality

@abraunst
Copy link
Contributor

To me, it seems that this is a "bug" in IntervalArithmetic, as the union of two interval is not necessary an interval (and the convex hull is different from the union in general!). So IntervalArithmetic maybe should define hull but not union ?

@dpsanders
Copy link
Contributor Author

I take your point, but I want to be able to use for two intervals and stay within the (standard) interval world.
If you want the interval union version, you can use IntervalUnions as your inputs I guess (even though they have a single interval inside).

Also, what should union give if the intervals overlap (in the IntervalUnion case)? There are type-stability, and hence performance, issues to be careful with. The answer should always be an IntervalUnion, even if there's only a single interval.

@abraunst
Copy link
Contributor

I take your point, but I want to be able to use for two intervals and stay within the (standard) interval world. If you want the interval union version, you can use IntervalUnions as your inputs I guess (even though they have a single interval inside).

I see :) Forgive me for the question, but why is it important to use instead of hull? I'm using IntervalUnionArithmetic probably in a rather atypical way (and don't use IntervalArithmetic directly yet) so maybe I don't see the full picture. But it's super useful to me (so thanks both by the way)! At the moment the type piracy thing is a bit ugly, at the very least because it gives a warning in precompilation.

Also, what should union give if the intervals overlap (in the IntervalUnion case)? There are type-stability, and hence performance, issues to be careful with. The answer should always be an IntervalUnion, even if there's only a single interval.

Yes, agreed... hull on the other hand could and should always return an Interval.

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

Successfully merging a pull request may close this issue.

3 participants