Skip to content

Commit 8fa17c7

Browse files
authored
preserve block types in similar for BlockArray (#284)
1 parent e828f4a commit 8fa17c7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/blockarray.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ end
369369
@inline Base.similar(block_array::Type{<:AbstractArray{T}}, axes::Tuple{Union{AbstractUnitRange{Int},Integer},BlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
370370
BlockArray{T}(undef, map(to_axes,axes))
371371

372+
@inline Base.similar(B::BlockArray, ::Type{T}) where {T} = mortar(similar.(blocks(B), T))
373+
372374
const OffsetAxis = Union{Integer, UnitRange, Base.OneTo, Base.IdentityUnitRange}
373375

374376
# avoid ambiguities

0 commit comments

Comments
 (0)