JuliaArrays / JuliaArrays/BlockArrays.jl

Regression in broadcasting between blockarray and normal array

Open
#223 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

This used to work on 0.16.3:

a = PseudoBlockArray(zeros(10 + 12, 10 + 12), [10, 12], [10, 12]) 
b = rand(22, 22)
a .+= b .* 1.0

It currently errors with:

ERROR: DimensionMismatch("array could not be broadcast to match destination")
Stacktrace:
  [1] check_broadcast_shape
    @ ./broadcast.jl:540 [inlined]
  [2] check_broadcast_axes
    @ ./broadcast.jl:543 [inlined]
  [3] check_broadcast_axes
    @ ./broadcast.jl:547 [inlined]
  [4] instantiate
    @ ./broadcast.jl:284 [inlined]
  [5] materialize!
    @ ./broadcast.jl:871 [inlined]
  [6] materialize!
    @ ./broadcast.jl:868 [inlined]
  [7] broadcast!(::typeof(+), ::SubArray{Float64, 2, Matrix{Float64}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}, ::SubArray{Float64, 2, Matrix{Float64}, Tuple{UnitRange{Int64}, UnitRange{Int64}}, false}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(*), Tuple{Matrix{Float64}, Float64}})
    @ Base.Broadcast ./broadcast.jl:837
  [8] macro expansion
    @ ~/.julia/packages/BlockArrays/B2UXn/src/blockbroadcast.jl:175 [inlined]
  [9] _generic_blockbroadcast_copyto!(dest::PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}, bc::Base.Broadcast.Broadcasted{BlockArrays.PseudoBlockStyle{2}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}, typeof(+), Tuple{PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(*), Tuple{Matrix{Float64}, Float64}}}})
    @ BlockArrays ~/.julia/packages/BlockArrays/B2UXn/src/blockbroadcast.jl:151
 [10] copyto!(dest::PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}, bc::Base.Broadcast.Broadcasted{BlockArrays.PseudoBlockStyle{2}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}, typeof(+), Tuple{PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(*), Tuple{Matrix{Float64}, Float64}}}})
    @ BlockArrays ~/.julia/packages/BlockArrays/B2UXn/src/blockbroadcast.jl:193
 [11] materialize!(dest::PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}, bc::Base.Broadcast.Broadcasted{BlockArrays.PseudoBlockStyle{2}, Nothing, typeof(+), Tuple{PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, typeof(*), Tuple{Matrix{Float64}, Float64}}}})
    @ BlockArrays ~/.julia/packages/BlockArrays/B2UXn/src/blockbroadcast.jl:148
 [12] top-level scope
    @ REPL[4]: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

Reproduce the example from the issue with PseudoBlockArray and a normal Julia array. Start in src/blockbroadcast.jl, especially the broadcast! and copyto! paths shown in the stack trace, and compare the destination and broadcast axes. Done means the a .+= b .* 1.0 operation works as it did in version 0.16.3.

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
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.