JuliaArrays / JuliaArrays/FillArrays.jl
`cumsum` for `Ones` has inconsistent output type depending on element type
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 187
- Forks
- 41
- Avg merge
- 17h 29m
- Merged PRs (30d)
- 1
Description
For example using FillArrays v1.9.3:
julia> using FillArrays
julia> cumsum(Ones{Int64}(4))
Base.OneTo(4)
julia> cumsum(Ones{Int32}(4))
4-element Vector{Int32}:
1
2
3
4
I believe the issue is this line: https://github.com/JuliaArrays/FillArrays.jl/blob/v1.9.3/src/FillArrays.jl#L578.
It may in fact be an issue with convert of Base.OneTo:
julia> convert(AbstractVector{Int64}, Base.OneTo(4))
Base.OneTo(4)
julia> convert(AbstractVector{Int32}, Base.OneTo(4))
4-element Vector{Int32}:
1
2
3
4
i.e. it seems like it should preserve that it is Base.OneTo and just change the element type. A workaround could be to use:
cumsum(x::AbstractOnesVector{II}) where II<:Integer = convert(AbstractVector{II}, oneto(II(length(x))))
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two cumsum examples from the issue, then inspect src/FillArrays.jl around line 578 and Julia's conversion of Base.OneTo to AbstractVector. Verify the intended behavior for Int64 and Int32 and add or update coverage so the result preserves the appropriate lazy range representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100