Skip to content

Commit b66ae4a

Browse files
committed
Tests for zeros/ones (#380)
* Tests for zeros/ones * Fix method ambiguity
1 parent 8ea4c53 commit b66ae4a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/pseudo_blockarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ rowsupport(A::PseudoBlockArray, j) = rowsupport(A.blocks, j)
338338
###
339339

340340
for op in (:zeros, :ones)
341-
@eval $op(::Type{T}, axs::Tuple{BlockedUnitRange,Vararg{Any}}) where T = PseudoBlockArray($op(T, map(length,axs)...), axs)
341+
@eval $op(::Type{T}, axs::Tuple{BlockedUnitRange,Vararg{Union{Integer,AbstractUnitRange}}}) where T = PseudoBlockArray($op(T, map(length,axs)...), axs)
342342
end
343343

344344
Base.replace_in_print_matrix(f::PseudoBlockVecOrMat, i::Integer, j::Integer, s::AbstractString) =

test/test_blockarrays.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ end
110110
@test blocksizes(B) == ([2,1], [2,1])
111111
@test B == reshape([1:9;],3,3)
112112
@test blocks(B) isa Matrix{Matrix{Int}}
113+
114+
@testset "zeros/ones" begin
115+
br = blockedrange(2:3)
116+
z = zeros(Float64, br)
117+
@test all(iszero, z)
118+
@test axes(z) == (br,)
119+
o = ones(Float64, br)
120+
@test all(isone, o)
121+
@test axes(o) == (br,)
122+
end
113123
end
114124

115125
@testset "PseudoBlockArray constructors" begin

0 commit comments

Comments
 (0)