Fix #39798 by using one(start) rather than 1 for _linrange#40467
Merged
oscardssmith merged 4 commits intoJuliaLang:masterfrom May 27, 2021
Merged
Fix #39798 by using one(start) rather than 1 for _linrange#40467oscardssmith merged 4 commits intoJuliaLang:masterfrom
oscardssmith merged 4 commits intoJuliaLang:masterfrom
Conversation
Contributor
Author
|
@mbauman After thinking about it for some time, I think we should merge this one to fix #39798. I'm quite confident that the The additional julia> function Base.TwicePrecision{T}(nd::Tuple{Integer,Integer}, nb::Integer) where T
Base.twiceprecision(Base.TwicePrecision{T}(nd), nb)
end
julia> range(Int32(1), Int32(1); length = 10)
1.0:0.0:1.0
julia> typeof(range(Int32(1), Int32(1); length = 10))
StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}} |
shirodkara
pushed a commit
to shirodkara/julia
that referenced
this pull request
Jun 9, 2021
…uliaLang#40467) * Fix JuliaLang#39798 by using one(start) rather than 1 for _linrange * Expand tests for JuliaLang#39798
johanmon
pushed a commit
to johanmon/julia
that referenced
this pull request
Jul 5, 2021
…uliaLang#40467) * Fix JuliaLang#39798 by using one(start) rather than 1 for _linrange * Expand tests for JuliaLang#39798
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a variation on #39808 using
one(start)rather thanoneunit(start)and fixes the bug identified in #39798:In the hypothetical scenario proposed by @mbauman,
startis a unitfulInteger. In that case,one(start)is better fordenthanoneunit(start)wherestart <: Integerbecauseone(start)is unitless and would not strip the units of the ratio. Thus,startandone(start)have distinct types since the former is unitful and the latter is unitless. Thus the methodTwicePrecision{T}(nd::Tuple{I,I}, nb::Integer) where {T,I}would not apply.In this version, we thus also implement
TwicePrecision{T}(nd::Tuple{Integer,Integer}, nb::Integer) where T.