Skip to content

Commit e13b491

Browse files
committed
Use similar methods from ArrayPartion for NamedArrayPartition
1 parent 8765aae commit e13b491

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/named_array_partition.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ end
2626
# fields except through `getfield` and accessor functions.
2727
ArrayPartition(x::NamedArrayPartition) = getfield(x, :array_partition)
2828

29+
function Base.similar(x::NamedArrayPartition, args...)
30+
NamedArrayPartition(
31+
similar(getfield(x, :array_partition), args...), getfield(x, :names_to_indices))
32+
end
33+
2934
Base.Array(x::NamedArrayPartition) = Array(ArrayPartition(x))
3035

3136
function Base.zero(x::NamedArrayPartition{T, S, TN}) where {T, S, TN}

0 commit comments

Comments
 (0)