JuliaArrays / JuliaArrays/StaticArrays.jl
Difference between Array reshaping and MArray/SizedArray reshaping
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
Modifying a reshaped array modifies the original array as well but it doesn't do that with MArray or SizedArray (a copy is created instead):
julia> vm = @MVector ones(4);
julia> vmr = reshape(vm, Size(2,2))
2×2 MArray{Tuple{2,2},Float64,2,4} with indices SOneTo(2)×SOneTo(2):
1.0 1.0
1.0 1.0
julia> vmr[1] = 12
12
julia> vm
4-element MArray{Tuple{4},Float64,1,4} with indices SOneTo(4):
1.0
1.0
1.0
1.0
Since we now have SizedArray that can wrap any AbstractArray, this could be fixed relatively easily. Is this something worth fixing before the 1.0 release?
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 Julia REPL example for reshape on MArray and SizedArray, then trace the reshape entry points and storage behavior for these types versus ordinary Array. Determine the intended aliasing behavior and add regression coverage showing whether reshaped mutations affect the original; done means the behavior is consistent with the agreed semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100