-
Notifications
You must be signed in to change notification settings - Fork 71
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
1.0-dev: fix interval(::Interval)
and some ambiguities
#554
1.0-dev: fix interval(::Interval)
and some ambiguities
#554
Conversation
sorry for the delay! I'll try to have a look tomorrow |
Codecov ReportBase: 85.22% // Head: 85.47% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## 1.0-dev #554 +/- ##
===========================================
+ Coverage 85.22% 85.47% +0.25%
===========================================
Files 34 34
Lines 1793 1804 +11
===========================================
+ Hits 1528 1542 +14
+ Misses 265 262 -3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
No worries, thank you for taking the time 🙂 |
interval(::Interval)
and some ambiguitiesinterval(::Interval)
and some ambiguities
When I initially made this PR, I did not look at the changelog.md file. I see that conversions and promotions are purposely disallowed to guarantee correctness. However, doing this still does not guarantee that generic methods for On the other hand, the IntervalArithmetic.jl package should not have to guarantee correctness for functions defined outside of its scope. Arguably, anyone performing rigorous computations should make sure that the functions they call are safe for |
Ho ho ho you found our Pandora's box already ^^' First some reference of past related discussions #2 #165 #168 #237 #309 and #271 (on which the branch 1.0-dev is based). And now for a brief summary:
You are right. That's the only way to guarantee correctness. However in order to have interop we need to subtype
For interop in principle we only need to be sure we override all That's where the concept of flavors comes in. Flavors would allow to tune the behavior of interval for that kind of operations, and all corner cases that may be misinterpreted. This is also one of the thing that are slowly going into 1.0-dev.
This is a fair point, but we had greater ambitions ^^. My idea of disallowing promotion is that we should provide as much guarantee as possible out of the box. Promotion however is an easy way to shoot ourselves in the foot, as it makes it quite tricky to actually make sure all functions you call are safe for Now I haven't review this PR yet (will try to do it soon), if your implementation is trustworthy enough to avoid the problem we had in the past, I'm personnally fine bringing promotion back in 1.0-dev. |
Let me provide an example of what Benoit mentions about interoperability, where I am involved: |
Thanks for the detailed answer! 🙂 Indeed there were issues in the past with conversion/promotion, see also #539. The downside is that perhaps someone will have a slightly wider interval than necessary 🤷♂️.
Indeed not "mixing" Of course I am very biased on this topic 😅 since I am in a similar position as @lbenet (thanks for the work on TaylorSeries.jl and TaylorModels.jl, these are awesome libraries!). I am the developer of RadiiPolynomial.jl a library for computer-assisted proofs in dynamical systems (which includes Taylor but also Fourier and Chebyshev series). So I really appreciate having a flexible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the comment I left, which require a small change, LGTM, so I'm in favor of merging it.
I didn't know about |
I have made the suggested change: allow promotion only between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR is ok from my point of view; and thus I'm in favor of merging it. Any comments @lucaferranti, @Kolaru or @dpsanders ? |
All look good to me. I think that regarding the discussion, your opinion is actually in line with the consensus here :). As per promotion, I should have read the PR first. The problematic promotion was the promotion between number and interval[1][2]. Promoting interval of different types causes no problem as far as I can see. [1] Promotion between non interval |
Great! So let's go ahead and merge this! Thanks a lo @OlivierHnt ! |
+
,-
,*
and/
when the operands areInterval
s with differentnumtype
. The mechanism relies onpromote
, sopromote_rule
is defined, as a side-effect[Interval{Float32}(pi), Interval{Float64}(pi)]::Vector{Interval{Float64}}
with guaranteed error bounds.Showcase:
Before this PR:
After this PR