-
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
Extend boolean functions for intervals to numbers #623
Conversation
The behaviour of Also julia> inf(pi)
3.141592653589793
julia> sup(pi)
3.1415926535897936 |
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #623 +/- ##
==========================================
- Coverage 83.46% 82.24% -1.23%
==========================================
Files 25 25
Lines 2153 2185 +32
==========================================
Hits 1797 1797
- Misses 356 388 +32 ☔ View full report in Codecov by Sentry. |
Thanks for this addition and bringing it up for discusion. A subtlety of the current proposal is that in some cases we do create the proper interval that contains the real value intended (or typed), e.g. In JuliaDiff/TaylorSeries.jl#345 I've been joggling with some internal functionality as a workaround (this was before #613). What I did was to define some internal function, say Something I noticed in JuliaDiff/TaylorSeries.jl#345 (and that I'm trying to solve) may help in the decision: In order to compute the Taylor series of certain functions (let us think of |
Ah yes you have IntervalArithmetic as a weak dependancy. The way you do it with In the example of
Absolutely. |
Thanks for the remark. I'll give it a try and provide some feedback |
Just to make it clear: I am not against that |
Oh I was just mentioning this by the way.
Indeed. Now it's just a matter of deciding whether |
Using this branch, I get the following: julia> x = interval(0.5,1)
Interval{Float64}(0.5, 1.0, com)
julia> x >= 0
ERROR: ArgumentError: `==` is only supported for thin intervals. See instead `isequal_interval`
... It seems to me that, using directly the comparison ( |
Yea that's what I was referring to in my previous comment. Somehow I can wrap my head around julia> isunbounded(Inf)
┌ Warning: invalid interval, NaI is returned
└ @ IntervalArithmetic ~/.julia/dev/IntervalArithmetic/src/intervals/construction.jl:417
false One good thing is that we have a warning message... And it's also not wrong in the sense that |
I agree!
This is indeed puzzling, but ok in my opinion; I think we are consistent with the fact that |
Regarding JuliaDiff/TaylorSeries.jl#345, I am not exploiting the proposed functionality, and the error messages, while ok, are also frustrating... Yet, I do need something related to #624, perhaps in the way you propose with |
This PR improves compatibility between
Number
andInterval
by permitting most boolean functions to take numbers as an argument.The general idea is that a boolean function defined for intervals, say
foo(x::Interval) = ...
, is extended to numbers by simplyfoo(x::Number) = foo(interval(x))
.This leads to some corner cases, eg
isthin(Inf, Inf)
andisthin(pi)
return false.Not sure if that should be the behaviour. The other possibility is of course to fall back to default Base functionalities:
isthinzero(x::Number) = iszero(x)
instead ofisthinzero(x::Number) = isthinzero(interval(x))
, etc.@lbenet do you think this can help with JuliaDiff/TaylorSeries.jl#345? Perhaps then you won't have to define your own
_isthinzero
function.