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

Make indexing into LinRange preserve eltype #35267

Merged
merged 1 commit into from
Mar 30, 2020

Conversation

sostock
Copy link
Contributor

@sostock sostock commented Mar 26, 2020

Previously, indexing into a LinRange{Int} with another range would return a LinRange{Float64}. This PR fixes that.

Before:

julia> LinRange{Int}(1,5,5)
5-element LinRange{Int64}:
 1.0,2.0,3.0,4.0,5.0

julia> LinRange{Int}(1,5,5)[1:2]
2-element LinRange{Float64}:
 1.0,2.0

After:

julia> LinRange{Int}(1,5,5)
5-element LinRange{Int64}:
 1,2,3,4,5

julia> LinRange{Int}(1,5,5)[1:2]
2-element LinRange{Int64}:
 1,2

Note that this also affects the printing of LinRange{Int} because of the way print_range is implemented.

@JeffBezanson JeffBezanson merged commit 1b228ff into JuliaLang:master Mar 30, 2020
oxinabox pushed a commit to oxinabox/julia that referenced this pull request Apr 8, 2020
ravibitsgoa pushed a commit to ravibitsgoa/julia that referenced this pull request Apr 9, 2020
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.

3 participants