JuliaArrays / JuliaArrays/BlockArrays.jl

`Diagonal(BlockVector)[Block(i, i)]` is not `Diagonal`

Open
#427 2 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

For example:

julia> using BlockArrays

julia> d = Diagonal(BlockedVector([1, 2, 3, 4], [2, 2]))
4×4 Diagonal{Int64, BlockedVector{Int64, Vector{Int64}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}}} with indices BlockedOneTo([2, 4])×BlockedOneTo([2, 4]):
 1  ⋅  │  ⋅  ⋅
 ⋅  2  │  ⋅  ⋅
 ──────┼──────
 ⋅  ⋅  │  3  ⋅
 ⋅  ⋅  │  ⋅  4

julia> d[Block(1, 1)]
2×2 Matrix{Int64}:
 1  0
 0  2

Shows up in #426.

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 by reproducing the Diagonal(BlockedVector(...)) example from the issue and inspect the block-indexing path for d[Block(1, 1)]. Trace why that access returns a matrix instead of a Diagonal, then add or update a regression test showing the expected diagonal result.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.