Skip to content

Commit

Permalink
Tests for zeros/ones (#380)
Browse files Browse the repository at this point in the history
* Tests for zeros/ones

* Fix method ambiguity
  • Loading branch information
jishnub authored Apr 3, 2024
1 parent 62a2ec5 commit f879d94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pseudo_blockarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ rowsupport(A::PseudoBlockArray, j) = rowsupport(A.blocks, j)
###

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

Base.replace_in_print_matrix(f::PseudoBlockVecOrMat, i::Integer, j::Integer, s::AbstractString) =
Expand Down
10 changes: 10 additions & 0 deletions test/test_blockarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ end
@test blocksizes(B) == ([2,1], [2,1])
@test B == reshape([1:9;],3,3)
@test blocks(B) isa Matrix{Matrix{Int}}

@testset "zeros/ones" begin
br = blockedrange(2:3)
z = zeros(Float64, br)
@test all(iszero, z)
@test axes(z) == (br,)
o = ones(Float64, br)
@test all(isone, o)
@test axes(o) == (br,)
end
end

@testset "PseudoBlockArray constructors" begin
Expand Down

0 comments on commit f879d94

Please sign in to comment.