-
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
Add typemin, typemax, ::Type version of eps. #108
Add typemin, typemax, ::Type version of eps. #108
Conversation
Codecov Report
@@ Coverage Diff @@
## master #108 +/- ##
==========================================
+ Coverage 92.81% 92.84% +0.03%
==========================================
Files 21 21
Lines 960 965 +5
==========================================
+ Hits 891 896 +5
Misses 69 69
Continue to review full report at Codecov.
|
Thanks very much for the contribution! I agree about |
I don't remember what was the motivation for such a definition. It is a fair point that it should behave as @tkoolen Thanks for the contribution! |
OK, made the IntervalArithmetic.jl/test/interval_tests/numeric.jl Lines 158 to 160 in e6375b0
This is because |
I tried what I proposed above, or rather convert(::Type{Interval{T}}, x::T) where {T<:Real} = Interval{T}(x)
convert(::Type{Interval{T}}, x::T) where {T<:AbstractFloat} = Interval{T}(x) but that resulted in a bunch of test failures. |
Sorry for the delay in replying. I'm pretty sure there are |
With latest release:
or maybe I'm missing something? |
Sure, there is a
is overly conservative, but now I think it's just buggy. On master: julia> using IntervalArithmetic
julia> a = @interval(0.1);
julia> epsa = eps(a)
1.3877787807814457e-17
julia> epsa_interval = convert(Interval{Float64}, epsa)
[1.38777e-17, 1.38778e-17]
julia> epsa ∈ epsa_interval # !!!
false and julia> b = Interval(0.1, 0.1);
julia> d = dist(a,b)
1.3877787807814457e-17
julia> d_interval = convert(Interval{Float64}, d)
[1.38777e-17, 1.38778e-17]
julia> d ∈ d_interval # again: !!!
false
julia> d < d_interval.hi
true
julia> d < d_interval.lo
true
julia> d <= eps(a) # the test on master
true
julia> d_interval <= Interval(eps(a)) # essentially the test on the PR branch if `dist` returns a Float64
false |
Sorry for the delay in getting to this. There is a problem here: using
Intervals with two I propose using something like
|
9931f46
to
4421fe6
Compare
OK, thanks. Rebased onto master and addressed your comment. Since |
By the way, the conservative widening part of #108 (comment) was also addressed by #114, so I was able to undo my changes to |
|
||
typemin(::Type{Interval{T}}) where T<:AbstractFloat = wideinterval(typemin(T)) | ||
typemax(::Type{Interval{T}}) where T<:AbstractFloat = wideinterval(typemax(T)) | ||
typemin(::Type{Interval{T}}) where T<:Integer = Interval(typemin(T)) |
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.
The package is not supposed to be used with integer intervals, but I guess no harm is done!
Many thanks @tkoolen! Do you have an example of using the package with RigidBodyDynamics.jl? |
You're very welcome.
Yeah, a simple demo over at https://github.com/JuliaRobotics/RigidBodyDynamics.jl/blob/tk/interval-arithmetic/notebooks/Rigorous%20error%20bounds%20using%20IntervalArithmetic.ipynb (currently on a branch). I'm putting together some additional notebooks, partly for two upcoming tutorials. Could I bother you for a new tag? |
Very nice! I have a few modifications to suggest for that notebook -- shall I make a PR or just list them here? (And is there now a decent story about diffs for notebooks? |
You can just list them here, that's probably easier. Thank you! |
A few missing methods needed to use IntervalArithmetic with RigidBodyDynamics.jl.
Just a note: I was surprised that
eps(::Interval{T})
returns aT
, not anInterval{T}
. This isn't causing any trouble for me, but it's perhaps a little surprising thateps(::Type{Interval{T}})
now returns aT
(to be consistent witheps(::Interval{T})
), whereas e.g.one(::Type{Interval{T}})
returns anInterval{T}
.Thanks for the package!