Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/blockarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
@inline Base.similar(block_array::Type{<:AbstractArray{T}}, axes::Tuple{Union{AbstractUnitRange{<:Integer},Integer},AbstractBlockedUnitRange,Vararg{Union{AbstractUnitRange{<:Integer},Integer}}}) where T =
BlockArray{T}(undef, map(to_axes,axes))

@inline Base.similar(B::BlockArray, ::Type{T}) where {T} = mortar(similar.(blocks(B), T))
@inline Base.similar(B::BlockArray, ::Type{T}) where {T} = _BlockArray(similar.(blocks(B), T), axes(B))

Check warning on line 454 in src/blockarray.jl

View check run for this annotation

Codecov / codecov/patch

src/blockarray.jl#L454

Added line #L454 was not covered by tests

const OffsetAxis = Union{Integer, UnitRange, Base.OneTo, Base.IdentityUnitRange}

Expand Down
3 changes: 3 additions & 0 deletions test/test_blockarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ end
@test similar(randn(6,5), Float64, (3,blockedrange(1:3))) isa BlockedMatrix
@test similar(typeof(view(randn(5),1:3)), (blockedrange(1:3),)) isa BlockedVector
@test similar(view(randn(5),1:3), Int, (blockedrange(1:3),)) isa BlockedVector{Int}

b = BlockVector([1,2,3,4,5,6,7,8,9,10], (BlockedOneTo(5:5:10),))
@test zero(b) isa typeof(b)
end

@test_throws DimensionMismatch BlockArray([1,2,3],[1,1])
Expand Down
Loading