Skip to content

Commit 3a355e5

Browse files
dlfivefiftyKristofferC
authored andcommitted
Convert AbstractVector{Int} arguments for block sizes to Vector{Int} (#28)
1 parent aec22b2 commit 3a355e5

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/blockarray.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ end
8181
end
8282
end
8383

84+
85+
BlockArray{T, N, R <: AbstractArray{T,N}}(::Type{R}, block_sizes::Vararg{AbstractVector{Int}, N}) =
86+
BlockArray(R, Vector{Int}.(block_sizes)...)
87+
88+
BlockArray{T, N}(arr::AbstractArray{T, N}, block_sizes::Vararg{AbstractVector{Int}, N}) =
89+
BlockArray(arr, Vector{Int}.(block_sizes)...)
90+
8491
################################
8592
# AbstractBlockArray Interface #
8693
################################

test/runtests.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
using BlockArrays
2-
if VERSION >= v"0.5-"
3-
using Base.Test
4-
else
5-
using BaseTestNext
6-
const Test = BaseTestNext
7-
end
2+
using Base.Test
3+
84

95
include("test_blockindices.jl")
106
include("test_blockarrays.jl")

test/test_blockarrays.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,14 @@ end
157157

158158
replstrmime(x) = stringmime("text/plain", x)
159159
@test replstrmime(BlockArray(collect(reshape(1:16, 4, 4)), [1,3], [2,2])) == "2×2-blocked 4×4 BlockArrays.BlockArray{Int64,2,Array{Int64,2}}:\n 1 5 │ 9 13\n ──────┼────────\n 2 6 │ 10 14\n 3 7 │ 11 15\n 4 8 │ 12 16"
160+
161+
162+
@testset "AbstractVector{Int} blocks" begin
163+
A = BlockArray(ones(6,6),1:3,1:3)
164+
@test A[1,1] == 1
165+
@test A[Block(2,3)] == ones(2,3)
166+
167+
A = BlockArray(Matrix{Float64},1:3,1:3)
168+
A[Block(2,3)] = ones(2,3)
169+
@test A[Block(2,3)] == ones(2,3)
170+
end

0 commit comments

Comments
 (0)