Skip to content

Commit 5b84935

Browse files
authored
fix blockisequalorscalar(ax, a) when a is Ref (#153)
* change blockisequalorscalar() to work for ::Ref input * fix failing diagonal tests This actually seems unrelated to the rest of this commit but without importing Diagonal some tests fail here. Maybe Diagonal should be exported? In any case, this fixes the failing tests for now. * add tests for minimal failing examples on previous version * v0.14.4
1 parent a478a8c commit 5b84935

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockArrays"
22
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
3-
version = "0.14.3"
3+
version = "0.14.4"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/blockbroadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ _hasscalarlikevec(a, b...) = _hasscalarlikevec(b...)
209209
_hasscalarlikevec(a::AbstractVector, b...) = size(a,1) == 1 || _hasscalarlikevec(b...)
210210

211211
blockisequalorscalar(ax, ::Number) = true
212-
blockisequalorscalar(ax, a) = blockisequal(ax, axes(a,1))
212+
blockisequalorscalar(ax, a) = blockisequal(ax, Base.axes1(a))
213213

214214
function copyto!(dest::AbstractVector,
215215
bc::Broadcasted{<:AbstractBlockStyle{1}, <:Any, <:Any, Args}) where {Args <: Tuple}

test/test_blockbroadcast.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using BlockArrays, FillArrays, LazyArrays, Test
2-
import BlockArrays: SubBlockIterator, BlockIndexRange
2+
import BlockArrays: SubBlockIterator, BlockIndexRange, Diagonal
33

44
@testset "broadcast" begin
55
@testset "BlockArray" begin
@@ -115,6 +115,19 @@ import BlockArrays: SubBlockIterator, BlockIndexRange
115115
@test broadcast(*, 2, v) == 2Vector(v)
116116
end
117117

118+
@testset "BlockVector broadcast" begin
119+
a = BlockArray(randn(3),[1,2])
120+
b = broadcast(+, Ref(1), a)
121+
@test b isa BlockArray{eltype(a),1}
122+
@test Base.axes1(a) == Base.axes1(b)
123+
@test Vector(b) == broadcast(+, Ref(1), Vector(a))
124+
a = BlockArray(randn(16),[1,3,5,7])
125+
b = broadcast(+, Ref(1), a)
126+
@test b isa BlockArray{eltype(a),1}
127+
@test Base.axes1(a) == Base.axes1(b)
128+
@test Vector(b) == broadcast(+, Ref(1), Vector(a))
129+
end
130+
118131
@testset "special axes" begin
119132
A = BlockArray(randn(6), Ones{Int}(6))
120133
B = BlockArray(randn(6), Ones{Int}(6))
@@ -255,4 +268,4 @@ import BlockArrays: SubBlockIterator, BlockIndexRange
255268

256269
@test [idx.indices[1] for idx in SubBlockIterator(subblock_lasts, block_lasts)] == [1:1,1:2,1:1,2:3]
257270
end
258-
end
271+
end

0 commit comments

Comments
 (0)