Skip to content

error with views of Block and BlockIndex #442

Open
@ogauthe

Description

@ogauthe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions