JuliaArrays / JuliaArrays/BlockArrays.jl

Allow block setindex with UniformScaling

Open Beginner friendly
#449 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
254
Forks
39
PR merge metrics
No merged PRs in 30d

Description

This should work:

julia> A = BlockArray(zeros(Int,4,4), [2,2], [2,2]); A[Block(1,1)] = I
ERROR: MethodError: no method matching size(::UniformScaling{Bool}, ::Int64)
The function `size` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  size(::BitVector, ::Integer)
   @ Base bitarray.jl:107
  size(::Type{<:Diagonal{T, SVector{N, T}} where T}, ::Int64) where N
   @ StaticArrays ~/.julia/packages/StaticArrays/lZeGV/src/SDiagonal.jl:18
  size(::Type{<:Union{Adjoint{T, <:Union{StaticArray{Tuple{var"#s2"}, T, 1} where var"#s2", StaticArray{Tuple{var"#s3", var"#s4"}, T, 2} where {var"#s3", var"#s4"}}}, Diagonal{T, <:StaticArray{Tuple{var"#s14"}, T, 1} where var"#s14"}, Hermitian{T, <:StaticArray{Tuple{var"#s11", var"#s12"}, T, 2} where {var"#s11", var"#s12"}}, LowerTriangular{T, <:StaticArray{Tuple{var"#s19", var"#s20"}, T, 2} where {var"#s19", var"#s20"}}, Symmetric{T, <:StaticArray{Tuple{var"#s8", var"#s9"}, T, 2} where {var"#s8", var"#s9"}}, Transpose{T, <:Union{StaticArray{Tuple{var"#s2"}, T, 1} where var"#s2", StaticArray{Tuple{var"#s3", var"#s4"}, T, 2} where {var"#s3", var"#s4"}}}, UnitLowerTriangular{T, <:StaticArray{Tuple{var"#s25", var"#s26"}, T, 2} where {var"#s25", var"#s26"}}, UnitUpperTriangular{T, <:StaticArray{Tuple{var"#s22", var"#s23"}, T, 2} where {var"#s22", var"#s23"}}, UpperTriangular{T, <:StaticArray{Tuple{var"#s16", var"#s17"}, T, 2} where {var"#s16", var"#s17"}}, StaticArray{Tuple{var"#s26"}, T, 1} where var"#s26", StaticArray{Tuple{var"#s1", var"#s4"}, T, 2} where {var"#s1", var"#s4"}, StaticArray{<:Tuple, T}} where T}, ::Int64)
   @ StaticArrays ~/.julia/packages/StaticArrays/lZeGV/src/abstractarray.jl:5
  ...

Stacktrace:
 [1] _check_setblock!(block_arr::BlockMatrix{…}, v::UniformScaling{…}, block::Tuple{…})
   @ BlockArrays ~/Projects/BlockArrays.jl/src/blockarray.jl:494
 [2] setindex!
   @ ~/Projects/BlockArrays.jl/src/blockarray.jl:503 [inlined]
 [3] setindex!(block_arr::BlockMatrix{Int64, Matrix{…}, Tuple{…}}, v::UniformScaling{Bool}, block::Block{2, Int64})
   @ BlockArrays ~/Projects/BlockArrays.jl/src/abstractblockarray.jl:161
 [4] top-level scope
   @ REPL[307]:1
Some type information was truncated. Use `show(err)` to see complete types.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the failing setindex! path in src/blockarray.jl, especially _check_setblock! around line 494, and review the call from src/abstractblockarray.jl. Reproduce the BlockArray example from the issue, then add coverage showing that assigning UniformScaling with I to a block succeeds and preserves the expected block values.

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
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.