-
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
Fix convert bug #320
Fix convert bug #320
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,7 +17,7 @@ convert(::Type{Interval{T}}, x::Bool) where {T} = convert(Interval{T}, Int(x)) | |||||
convert(::Type{Interval{T}}, x::Real) where {T} = atomic(Interval{T}, x) | ||||||
convert(::Type{Interval{T}}, x::T) where {T<:Real} = Interval{T}(x) | ||||||
convert(::Type{Interval{T}}, x::Interval{T}) where {T} = x | ||||||
convert(::Type{Interval{T}}, x::Interval) where {T} = atomic(Interval{T}, x) | ||||||
convert(::Type{Interval{T}}, x::Interval{S}) where {T,S} = atomic(Interval{T}, x) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
convert(::Type{Interval}, x::Real) = (T = typeof(float(x)); convert(Interval{T}, x)) | ||||||
convert(::Type{Interval}, x::Interval) = x | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not directly related to the issue, but this definition is the same as the one on line 20 and should probably be deleted (especially since the result would not be correct if for some weird reason it ever gets called). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I don't understand which definition you're talking about that is the same as the one on line 20? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On line 23: convert(::Type{Interval}, x::Interval) = x Since |
||||||
|
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.
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.
While I see your point, this would make the code harder to maintain if we change the parameter type constrain.
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.
You can add a constant and use that instead of
Real
.