Skip to content

Commit 83d5d34

Browse files
authored
Fix tests with FillArrays v0.12 (#179)
* Fix tests with FillArrays v0.12 * Update test_blockarrayinterface.jl * remove LazyArray-dependent test * Update test_blockbroadcast.jl
1 parent 9cf92a3 commit 83d5d34

File tree

5 files changed

+18
-45
lines changed

5 files changed

+18
-45
lines changed

Project.toml

Lines changed: 2 additions & 3 deletions
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.2"
3+
version = "0.16.3"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -15,11 +15,10 @@ julia = "1.6"
1515
[extras]
1616
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
1717
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
18-
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
1918
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
2019
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2120
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
2221
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2322

2423
[targets]
25-
test = ["Base64", "FillArrays", "LazyArrays", "OffsetArrays", "SparseArrays", "StaticArrays", "Test"]
24+
test = ["Base64", "FillArrays", "OffsetArrays", "SparseArrays", "StaticArrays", "Test"]

test/test_blockarrayinterface.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ end
114114

115115
@testset "non-standard block axes" begin
116116
A = BlockArray([1 2; 3 4], Fill(1,2),Fill(1,2))
117-
@test A isa BlockMatrix{Int,Matrix{Matrix{Int}},NTuple{2,BlockedUnitRange{StepRange{Int64,Int64}}}}
117+
@test A isa BlockMatrix{Int,Matrix{Matrix{Int}},NTuple{2,BlockedUnitRange{StepRange{Int,Int}}}}
118118
A = BlockArray([1 2; 3 4], Fill(1,2),[1,1])
119-
@test A isa BlockMatrix{Int,Matrix{Matrix{Int}},Tuple{BlockedUnitRange{StepRange{Int64,Int64}},BlockedUnitRange{Vector{Int}}}}
119+
@test A isa BlockMatrix{Int,Matrix{Matrix{Int}},Tuple{BlockedUnitRange{StepRange{Int,Int}},BlockedUnitRange{Vector{Int}}}}
120120
end
121121

122122
@testset "block Fill" begin
@@ -158,9 +158,9 @@ end
158158

159159
U = UpperTriangular(Ones((blockedrange([1,2]),blockedrange([2,1]))))
160160

161-
@test stringmime("text/plain", A) == "5-element Fill{Int64, 1, Tuple{BlockedUnitRange{Vector{Int64}}}} with indices 1:1:5: entries equal to 2"
162-
@test stringmime("text/plain", B) == "3×3 Diagonal{Float64, Ones{Float64, 1, Tuple{BlockedUnitRange{Vector{Int64}}}}} with indices 1:1:3×1:1:3"
163-
@test stringmime("text/plain", U) == "3×3 UpperTriangular{Float64, Ones{Float64, 2, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}} with indices 1:1:3×1:1:3:\n 1.0 1.0 │ 1.0\n ──────────┼─────\n ⋅ 1.0 │ 1.0\n ⋅ ⋅ │ 1.0"
161+
@test stringmime("text/plain", A) == "5-element Fill{$Int, 1, Tuple{BlockedUnitRange{Vector{$Int}}}} with indices 1:1:5, with entries equal to 2"
162+
@test stringmime("text/plain", B) == "3×3 Diagonal{Float64, Ones{Float64, 1, Tuple{BlockedUnitRange{Vector{$Int}}}}} with indices 1:1:3×1:1:3"
163+
@test stringmime("text/plain", U) == "3×3 UpperTriangular{Float64, Ones{Float64, 2, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}}} with indices 1:1:3×1:1:3:\n 1.0 1.0 │ 1.0\n ──────────┼─────\n ⋅ 1.0 │ 1.0\n ⋅ ⋅ │ 1.0"
164164

165165
@testset "views" begin
166166
# This in theory can be dropped because `view` returns the block, but we keep in case needed

test/test_blockarrays.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,21 +380,21 @@ end
380380
A = BlockArray(rand(4, 5), [1,3], [2,3]);
381381
buf = IOBuffer()
382382
Base.showerror(buf, BlockBoundsError(A, (3,2)))
383-
@test String(take!(buf)) == "BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockMatrix{Float64, Matrix{Matrix{Float64}}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}} at block index [3,2]"
383+
@test String(take!(buf)) == "BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockMatrix{Float64, Matrix{Matrix{Float64}}, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}} at block index [3,2]"
384384

385385

386386
A = PseudoBlockArray(rand(4, 5), [1,3], [2,3]);
387387
Base.showerror(buf, BlockBoundsError(A, (3,2)))
388-
@test String(take!(buf)) == "BlockBoundsError: attempt to access 2×2-blocked 4×5 PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}} at block index [3,2]"
388+
@test String(take!(buf)) == "BlockBoundsError: attempt to access 2×2-blocked 4×5 PseudoBlockMatrix{Float64, Matrix{Float64}, Tuple{BlockedUnitRange{Vector{$Int}}, BlockedUnitRange{Vector{$Int}}}} at block index [3,2]"
389389
end
390390

391391
@testset "replstring" begin
392-
@test stringmime("text/plain",BlockArray(collect(1:4), [1,3])) == "2-blocked 4-element BlockVector{Int64}:\n 1\n\n 2\n 3\n 4"
393-
@test stringmime("text/plain",PseudoBlockArray(collect(1:4), [1,3])) == "2-blocked 4-element PseudoBlockVector{Int64}:\n 1\n\n 2\n 3\n 4"
394-
@test stringmime("text/plain",BlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 BlockMatrix{Int64}:\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16"
395-
@test stringmime("text/plain",PseudoBlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 PseudoBlockMatrix{Int64}:\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16"
396-
@test stringmime("text/plain",BlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1])) == "2×2×2-blocked 2×2×2 BlockArray{Int64, 3}:\n[:, :, 1] =\n 1 3\n 2 4\n\n[:, :, 2] =\n 5 7\n 6 8"
397-
@test stringmime("text/plain",PseudoBlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1])) == "2×2×2-blocked 2×2×2 PseudoBlockArray{Int64, 3}:\n[:, :, 1] =\n 1 3\n 2 4\n\n[:, :, 2] =\n 5 7\n 6 8"
392+
@test stringmime("text/plain",BlockArray(collect(1:4), [1,3])) == "2-blocked 4-element BlockVector{$Int}:\n 1\n\n 2\n 3\n 4"
393+
@test stringmime("text/plain",PseudoBlockArray(collect(1:4), [1,3])) == "2-blocked 4-element PseudoBlockVector{$Int}:\n 1\n\n 2\n 3\n 4"
394+
@test stringmime("text/plain",BlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 BlockMatrix{$Int}:\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16"
395+
@test stringmime("text/plain",PseudoBlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 PseudoBlockMatrix{$Int}:\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16"
396+
@test stringmime("text/plain",BlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1])) == "2×2×2-blocked 2×2×2 BlockArray{$Int, 3}:\n[:, :, 1] =\n 1 3\n 2 4\n\n[:, :, 2] =\n 5 7\n 6 8"
397+
@test stringmime("text/plain",PseudoBlockArray(collect(reshape(1:8, 2, 2, 2)), [1,1], [1,1], [1,1])) == "2×2×2-blocked 2×2×2 PseudoBlockArray{$Int, 3}:\n[:, :, 1] =\n 1 3\n 2 4\n\n[:, :, 2] =\n 5 7\n 6 8"
398398
design = zeros(Int16,6,9);
399399
A = BlockArray(design,[6],[4,5])
400400
@test stringmime("text/plain",A) == "1×2-blocked 6×9 BlockMatrix{Int16}:\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0\n 0 0 0 0 │ 0 0 0 0 0"

test/test_blockbroadcast.jl

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

44
@testset "broadcast" begin
@@ -111,7 +111,7 @@ import BlockArrays: SubBlockIterator, BlockIndexRange, Diagonal
111111
@test broadcast(-, v) == -v == -Vector(v)
112112
@test broadcast(+, v, 1) isa BlockVector{Int,Vector{UnitRange{Int}}}
113113
@test broadcast(+, v, 1) == Vector(v).+1
114-
@test broadcast(*, 2, v) isa BlockVector{Int,Vector{StepRange{Int,Int}}}
114+
@test broadcast(*, 2, v) isa BlockVector{Int,<:Vector{<:AbstractRange{Int}}}
115115
@test broadcast(*, 2, v) == 2Vector(v)
116116
end
117117

@@ -171,32 +171,6 @@ import BlockArrays: SubBlockIterator, BlockIndexRange, Diagonal
171171
@test blockisequal(axes(A .* Ones(axes(A))), axes(Ones(axes(A)) .* A), axes(A .* ones(6)))
172172
end
173173

174-
@testset "recurrences" begin
175-
N = 1000
176-
n = mortar(BroadcastArray(Fill,Base.OneTo(N),Base.OneTo(N)))
177-
k = mortar(BroadcastArray(Base.OneTo,Base.OneTo(N)))
178-
179-
@test view(n, Block(5)) Fill(5,5)
180-
@test view(k,Block(5)) Base.OneTo(5)
181-
a = b = c = 0.0
182-
# for some reason the following was causing major slowdown. I think it
183-
# went pass a limit to Base.Broadcast.flatten which caused `bc.f` to have a strange type.
184-
# bc = Base.Broadcast.instantiate(Base.broadcasted(/, Base.broadcasted(*, k, Base.broadcasted(-, Base.broadcasted(-, k, n), a)), Base.broadcasted(+, 2k, b+c-1)))
185-
186-
bc = Base.Broadcast.instantiate(Base.broadcasted((k,n,a,b,c) -> k * (k-n-a) / (2k+(b+c-1)), k, n, a, b, c))
187-
@test axes(n,1) axes(k,1) axes(bc)[1] blockedrange(Base.OneTo(N))
188-
u = (k .* (k .- n .- a) ./ (2k .+ (b+c-1)))
189-
@test u == (Vector(k) .* (Vector(k) .- Vector(n) .- a) ./ (2Vector(k) .+ (b+c-1)))
190-
@test copyto!(u, bc) == (k .* (k .- n .- a) ./ (2k .+ (b+c-1)))
191-
@test @allocated(copyto!(u, bc)) 1000
192-
# not clear why allocatinos so high: all allocations are coming from checking
193-
# axes
194-
195-
u = PseudoBlockArray{Float64}(undef, collect(1:N))
196-
@test copyto!(u, bc) == (k .* (k .- n .- a) ./ (2k .+ (b+c-1)))
197-
@test @allocated(copyto!(u, bc)) 1000
198-
end
199-
200174
@testset "type inferrence" begin
201175
u = BlockArray(randn(5), [2,3]);
202176
@inferred(copyto!(similar(u), Base.broadcasted(exp, u)))

test/test_blockindices.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ end
267267
@test findblock(b,1) == Block(1)
268268
@test_throws BoundsError findblock(b,0)
269269
@test_throws BoundsError findblock(b,6)
270-
@test stringmime("text/plain",blockedrange([1,2,2])) == "3-blocked 5-element BlockedUnitRange{Vector{Int64}}:\n 1\n\n 2\n 3\n\n 4\n 5"
270+
@test stringmime("text/plain",blockedrange([1,2,2])) == "3-blocked 5-element BlockedUnitRange{Vector{$Int}}:\n 1\n\n 2\n 3\n\n 4\n 5"
271271
end
272272

273273
@testset "BlockIndex type piracy (#108)" begin

0 commit comments

Comments
 (0)