Skip to content

Commit eeb5dd3

Browse files
authored
Type-stability in subblocks (#232)
* type-stability in subblocks * Add 1D test * fix test on v1.6 * version bump to v0.16.22
1 parent 3443469 commit eeb5dd3

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-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.16.21"
3+
version = "0.16.22"
44

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

src/blockbroadcast.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ subblocks(::Any, bs::NTuple{N,AbstractUnitRange{Int}}, dim::Integer) where N =
135135
(nothing for _ in blockaxes(bs[dim], 1))
136136

137137
function subblocks(arr::AbstractArray, bs::NTuple{N,AbstractUnitRange{Int}}, dim::Integer) where N
138-
if size(arr, dim) == 1
139-
return (BlockIndexRange(Block(1), 1:1) for _ in blockaxes(bs[dim], 1))
140-
end
141138
return SubBlockIterator(arr, bs, dim)
142139
end
143140

test/test_blockbroadcast.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,18 @@ import BlockArrays: SubBlockIterator, BlockIndexRange, Diagonal
251251

252252
@test [idx.indices[1] for idx in SubBlockIterator(subblock_lasts, block_lasts)] == [1:1,1:2,1:1,2:3]
253253
end
254+
255+
@testset "Adding BlockArrays" begin
256+
B = mortar(reshape([ones(1,1)], 1, 1))
257+
C = B + B
258+
@test C[Block(1,1)] == 2B[Block(1,1)]
259+
260+
B = mortar(reshape([[1 2], [3 4]], 1, 2))
261+
C = B + B
262+
@test C[Block(1,1)] == 2B[Block(1,1)]
263+
264+
B = mortar(reshape([[1]], 1))
265+
C = B + B
266+
@test C[Block(1)] == 2B[Block(1)]
267+
end
254268
end

0 commit comments

Comments
 (0)