Skip to content
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

RFC: promote ranges to the largest of the the start, step, or length (as applicable) #43059

Merged
merged 2 commits into from
Jan 12, 2022

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Nov 12, 2021

This is a test to see if we could switch range from oftype to promote for computing the size of the range. The main area this disrupted in the tests were caused by the auto-promotion rules for a few smallint types, causing length(r) to be a larger type than expected, and necessitating computing stop directly instead (which is an exact computation for these types, though would not have been valid generally–but other types generally do this promotion inside the definition of length).

Fixes #35711
Fixes #10554

@vtjnash vtjnash added the triage This should be discussed on a triage call label Nov 17, 2021
@vtjnash vtjnash changed the base branch from master to jn/ranges-last December 7, 2021 16:37
Base automatically changed from jn/ranges-last to master December 10, 2021 18:11
@JeffBezanson
Copy link
Member

From triage: looks pretty reasonable. But, we would really like to have the property that requesting a length of 0 (of any type) gives a fully-functional empty range. That requires us to switch from UnitRange to StepRangeLen as the return type for some ranges. Jameson will try to implement that, and we'll see if it breaks anything.

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Dec 16, 2021
…cable)

Be careful to use `oneunit` instead of `1`, so that arithmetic on
user-given types does not promote first to Int.

Fixes #35711
Fixes #10554
@vtjnash
Copy link
Member Author

vtjnash commented Jan 5, 2022

merge?

@vtjnash
Copy link
Member Author

vtjnash commented Jan 10, 2022

@nanosoldier runbenchmarks("range" || "ranges", vs=":master")

@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Jan 10, 2022
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@DilumAluthge
Copy link
Member

@vtjnash CI is green, but looks like there are some potential benchmark regressions?

@vtjnash
Copy link
Member Author

vtjnash commented Jan 12, 2022

looks like just noise to me
@nanosoldier runbenchmarks("RangeGenerator", vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@vtjnash vtjnash merged commit fd8b2ab into master Jan 12, 2022
@vtjnash vtjnash deleted the jn/bigstep-len-overflow branch January 12, 2022 16:00
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Jan 13, 2022
DilumAluthge added a commit that referenced this pull request Jan 13, 2022
vtjnash added a commit that referenced this pull request Jan 13, 2022
We cannot safely use reverse, so we do not anymore. That is now causing
conflict between #43059 and #29842. And this is likely clearer anyways.

Closes #43788
@vtjnash vtjnash mentioned this pull request Jan 13, 2022
vtjnash added a commit that referenced this pull request Jan 13, 2022
We cannot safely use reverse, so we do not anymore. That is now causing
conflict between #43059 and #29842. And this is likely clearer anyways.

Closes #43788
nickrobinson251 pushed a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
We cannot safely use reverse, so we do not anymore. That is now causing
conflict between JuliaLang#43059 and JuliaLang#29842. And this is likely clearer anyways.

Closes JuliaLang#43788
nickrobinson251 pushed a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
We cannot safely use reverse, so we do not anymore. That is now causing
conflict between JuliaLang#43059 and JuliaLang#29842. And this is likely clearer anyways.

Closes JuliaLang#43788
@martinholters
Copy link
Member

Not sure how much this is to worry about and it might be better fixed over there, but this broke DSP.jl because it does

convert(StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}, range(0.0, step=1, length=10))

which now throws. Including the final type argument, i.e.

convert(StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int}, range(0.0, step=1, length=10))

still works, but obviously requires Julia 1.7 or later.

martinholters added a commit to JuliaDSP/DSP.jl that referenced this pull request Jan 17, 2022
In Julia 1.7, the defintion of `StepRangeLen` acquired another type
parameter, making the fields typed with `FloatRange{Float64}` abstractly
typed. While that is unfortunate but not critical,
JuliaLang/julia#43059 further broke `convert`ing
to this abstract type, causing failures within DSP.jl. This change
reworks the defintion of `FloatRange` to pick the type of an appropriate
`range` call, making it adjust automatically to the changes in Julia. To
simplify things, the type parameter is dropped, as it was only used with
`Float64` anyway.
martinholters added a commit to JuliaDSP/DSP.jl that referenced this pull request Jan 17, 2022
In Julia 1.7, the definition of `StepRangeLen` acquired another type
parameter, making the fields typed with `FloatRange{Float64}` abstractly
typed. While that is unfortunate but not critical,
JuliaLang/julia#43059 further broke `convert`ing
to this abstract type, causing failures within DSP.jl. This change
reworks the definition of `FloatRange` to pick the type of an appropriate
`range` call, making it adjust automatically to the changes in Julia. To
simplify things, the type parameter is dropped, as it was only used with
`Float64` anyway.
martinholters added a commit to JuliaDSP/DSP.jl that referenced this pull request Jan 20, 2022
In Julia 1.7, the definition of `StepRangeLen` acquired another type
parameter, making the fields typed with `FloatRange{Float64}` abstractly
typed. While that is unfortunate but not critical,
JuliaLang/julia#43059 further broke `convert`ing
to this abstract type, causing failures within DSP.jl. This change
reworks the definition of `FloatRange` to pick the type of an appropriate
`range` call, making it adjust automatically to the changes in Julia. To
simplify things, the type parameter is dropped, as it was only used with
`Float64` anyway.
@vtjnash
Copy link
Member Author

vtjnash commented Feb 7, 2022

That seems like it should rather have been typeof( example_range ) or StepRangeLen{Float64}. I tried to preserve the functionality of many of the constructors without all type parameters, if they seemed right, but obviously not actually all of them.

EDIT: I see that DSP.jl went with the typeof option 👍

LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
…pplicable) (JuliaLang#43059)

Be careful to use `oneunit` instead of `1`, so that arithmetic on
user-given types does not promote first to Int.

Fixes JuliaLang#35711
Fixes JuliaLang#10554
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
We cannot safely use reverse, so we do not anymore. That is now causing
conflict between JuliaLang#43059 and JuliaLang#29842. And this is likely clearer anyways.

Closes JuliaLang#43788
@KristofferC
Copy link
Member

This feels like a PR where a PkgEval run would have been useful.

@vtjnash
Copy link
Member Author

vtjnash commented Mar 7, 2022

That is a bug, and I thought we already fixed it on master

@vtjnash
Copy link
Member Author

vtjnash commented Mar 7, 2022

Ah, we only fixed the adjacent case for float steps, but missed that

@KristofferC
Copy link
Member

So is jw3126/RangeHelpers.jl#2 an issue on Julia or expected?

@vtjnash
Copy link
Member Author

vtjnash commented Mar 8, 2022

We should fix it here. @jipolanco would you like to tackle this too, since you fixed the similar case in #44313?

LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
…pplicable) (JuliaLang#43059)

Be careful to use `oneunit` instead of `1`, so that arithmetic on
user-given types does not promote first to Int.

Fixes JuliaLang#35711
Fixes JuliaLang#10554
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
We cannot safely use reverse, so we do not anymore. That is now causing
conflict between JuliaLang#43059 and JuliaLang#29842. And this is likely clearer anyways.

Closes JuliaLang#43788
@jipolanco
Copy link
Contributor

Right, in #44313 I only took care of float steps. I'll try to push a fix for the general case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

range(0, length=Uint(0)) throws InexactError InexactError(): using range with higher values than Int64
7 participants