BlockArrays.jl icon indicating copy to clipboard operation
BlockArrays.jl copied to clipboard

error with views of Block and BlockIndex

Open ogauthe opened this issue 1 year ago • 0 comments

Hi! I noticed some combinations of view fails:

using BlockArrays: BlockArray, Block
ba = BlockArray(ones((1,1)), [1], [1])
julia> view(ba, Block(1,1)[1,1])
ERROR: BoundsError: attempt to access Tuple{} at index [1]
Stacktrace:
 [1] getindex(t::Tuple, i::Int64)
   @ Base ./tuple.jl:31
 [2] to_indices (repeats 2 times)
   @ ~/.julia/packages/BlockArrays/X84bj/src/views.jl:27 [inlined]
 [3] to_indices
   @ ~/.julia/packages/BlockArrays/X84bj/src/views.jl:36 [inlined]
 [4] to_indices
   @ ./indices.jl:360 [inlined]
 [5] view(A::BlockMatrix{Float64, Matrix{…}, Tuple{…}}, I::BlockIndex{2, Tuple{…}, Tuple{…}})
   @ Base ./subarray.jl:213
 [6] top-level scope
   @ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types.
julia> @view ba[Block(1,1)[1,1]]
ERROR: BoundsError: attempt to access Tuple{} at index [1]
Stacktrace:
 [1] getindex(t::Tuple, i::Int64)
   @ Base ./tuple.jl:31
 [2] to_indices (repeats 2 times)
   @ ~/.julia/packages/BlockArrays/X84bj/src/views.jl:27 [inlined]
 [3] to_indices
   @ ~/.julia/packages/BlockArrays/X84bj/src/views.jl:36 [inlined]
 [4] to_indices
   @ ./indices.jl:360 [inlined]
 [5] view(A::BlockMatrix{Float64, Matrix{…}, Tuple{…}}, I::BlockIndex{2, Tuple{…}, Tuple{…}})
   @ Base ./subarray.jl:213
 [6] top-level scope
   @ REPL[69]:1
Some type information was truncated. Use `show(err)` to see complete types.

Tested with Julia v"1.11.2" and BlockArrays v1.2.0.

ogauthe avatar Dec 09 '24 12:12 ogauthe