JuliaArrays / JuliaArrays/BlockArrays.jl
Broadcasted setindex (surprisingly) silently doesn't do anything
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 254
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
MWE:
julia> using BlockArrays, LinearAlgebra
julia> A = mortar(reshape([randn(2, 2), randn(2, 2), randn(2, 2), randn(2, 2)], (2, 2)))
2×2-blocked 4×4 BlockMatrix{Float64}:
-0.915837 -0.333415 │ -0.458008 0.521461
-0.566032 1.29096 │ 0.515333 -0.969364
───────────────────────┼──────────────────────
0.449189 -0.0617162 │ -0.96811 -1.22779
-0.155907 1.19382 │ -2.00874 -0.362436
julia> for ii in axes(A, 1), jj in axes(A, 2)
A[ii, jj] = ifelse( ii == jj, 2.0, 1.0)
end
julia> A
2×2-blocked 4×4 BlockMatrix{Float64}:
2.0 1.0 │ 1.0 1.0
1.0 2.0 │ 1.0 1.0
──────────┼──────────
1.0 1.0 │ 2.0 1.0
1.0 1.0 │ 1.0 2.0
julia> A[diagind(A)] .= -1.0
4-element view(reshape(::BlockedArray{…,::Matrix{Float64}}, 16), 1:5:16) with eltype Float64:
-1.0
-1.0
-1.0
-1.0
julia> A
2×2-blocked 4×4 BlockMatrix{Float64}:
2.0 1.0 │ 1.0 1.0
1.0 2.0 │ 1.0 1.0
──────────┼──────────
1.0 1.0 │ 2.0 1.0
1.0 1.0 │ 1.0 2.0
It seems like A should've been modified in these last two steps, or warned me that I was doing something unsupported...
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
Start by reproducing the MWE in the issue with BlockArrays, focusing on broadcasted assignment through A[diagind(A)] and the preceding block-indexed assignments. Read the relevant Julia array indexing, view, and setindex behavior used by BlockArrays; done means the diagonal broadcast visibly updates A or the unsupported operation reports a clear warning or error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100