JuliaArrays / JuliaArrays/BlockArrays.jl

Check dimensions match in PseudoBlockArray constructor

Open
#181 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 throw an error:

julia>  PseudoBlockArray(randn(5), SVector(1,3))
2-blocked 4-element PseudoBlockVector{Float64, Vector{Float64}, Tuple{BlockedUnitRange{SVector{2, Int64}}}}:
  0.04726771128137562
 ────────────────────
 -1.4647247301327797 
 -0.44549682847156197
 -0.5779924141573399 

Note that

julia>  BlockArray(randn(5), SVector(1,3))
ERROR: DimensionMismatch("block size for dimension 1: [1, 3] does not sum to the array size: 5")
Stacktrace:
 [1] (BlockArray{Float64, N, R, BS} where {N, R<:(AbstractArray{var"#s4", N} where var"#s4"<:AbstractArray{Float64, N}), BS<:Tuple{Vararg{AbstractUnitRange{Int64}, N}}})(arr::Vector{Float64}, block_sizes::SVector{2, Int64})
   @ BlockArrays ~/Projects/BlockArrays.jl/src/blockarray.jl:168
 [2] BlockArray(arr::Vector{Float64}, block_sizes::SVector{2, Int64})
   @ BlockArrays ~/Projects/BlockArrays.jl/src/blockarray.jl:174
 [3] top-level scope
   @ REPL[5]:1

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 at the PseudoBlockArray constructor, using the shown BlockArray(arr, block_sizes) call as the reference behavior. Reproduce the SVector(1, 3) case and verify that a mismatched total size raises DimensionMismatch rather than constructing a 4-element result; the payload names no test file.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.