JuliaArrays / JuliaArrays/BlockArrays.jl

missing `similar` method for `PseudoBlockArray` (`mapslices` unusable)

Open
#226 4 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

julia> using BlockArrays

julia> b = mortar([rand(5,5) for i=1:2, j=1:2]);

julia> mapslices(identity, b[1:5,:]; dims=1)
ERROR: MethodError: no method matching similar(::Vector{Float64}, ::Type{Float64}, ::Tuple{UnitRange{Int64}, UnitRange{Int64}})
Closest candidates are:
  similar(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{N}}, ::Type{ElType}, ::Any) where {N, ElType} at C:\Users\sternlab\AppData\Local\Programs\Julia-1.7.2\share\julia\base\broadcast.jl:212
  similar(::Base.Broadcast.Broadcasted{Base.Broadcast.ArrayConflict}, ::Type{ElType}, ::Any) where ElType at C:\Users\sternlab\AppData\Local\Programs\Julia-1.7.2\share\julia\base\broadcast.jl:217
  similar(::ArrayLayouts.MulAdd{<:Any, <:ArrayLayouts.DualLayout, ArrayLayouts.ZerosLayout}, ::Type{T}, ::Any) where T at C:\Users\sternlab\.julia\packages\ArrayLayouts\nCtQC\src\muladd.jl:414
  ...
Stacktrace:
 [1] similar(a::Vector{Float64}, dims::Tuple{UnitRange{Int64}, UnitRange{Int64}})
   @ Base .\abstractarray.jl:783
 [2] mapslices(f::typeof(identity), A::PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{Base.OneTo{Int64}, BlockedUnitRange{Vector{Int64}}}}; dims::Int64)
   @ Base .\abstractarray.jl:2795
 [3] top-level scope
   @ REPL[5]:1

This is a regression introduced between 0.16.17 and 0.16.18

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

Reproduce the Julia 1.7 example using BlockArrays and mapslices(identity, b[1:5,:]; dims=1), then inspect PseudoBlockArray's existing allocation and similar methods. Done means the reported mapslices call no longer raises the missing similar(::Vector, ...) MethodError and the regression is covered by an appropriate test.

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.