Skip to content

Commit ad097ae

Browse files
committed
Make Block act like a scalar under broadcasting
1 parent 3bb14a0 commit ad097ae

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/blockindices.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ last(b::Block) = b
5252
iterate(x::Block) = (x, nothing)
5353
iterate(x::Block, ::Any) = nothing
5454
isempty(x::Block) = false
55-
broadcastable(x::Block) = x
55+
broadcastable(x::Block) = Ref(x)
5656
ndims(::Type{<:Block}) = 0
5757
ndims(::Block) = 0
5858
eltype(::Type{B}) where B<:Block = B

test/test_blockindices.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import BlockArrays: BlockIndex, BlockIndexRange, BlockSlice
1919
@test ndims(B) == ndims(Block{1,Int}) == 0
2020
@test !isempty(B)
2121
@test collect(B) == [B]
22-
@test B + 1 == Block(4)
22+
@test B .+ 1 == Block(4)
2323
@test iterate(B) == (B, nothing)
2424
@test Int.(B) == 3
2525
end

0 commit comments

Comments
 (0)