Skip to content

Commit 961768c

Browse files
Rabab53jpsamaroo
andcommitted
DArray: Implement missing similar method
Co-authored-by: Julian P Samaroo <[email protected]>
1 parent 7023730 commit 961768c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/array/darray.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ function Base.similar(x::DArray{T,N}) where {T,N}
208208
return DArray(T, x.domain, x.subdomains, thunks, x.partitioning, x.concat)
209209
end
210210

211+
function Base.similar(A::DArray{T,N} where T, ::Type{S}, dims::Dims{N}) where {S,N}
212+
d = ArrayDomain(map(x->1:x, dims))
213+
p = A.partitioning
214+
a = AllocateArray(S, (_, _, x...) -> Array{S,N}(undef, x...), d, partition(p, d), p)
215+
return _to_darray(a)
216+
end
217+
211218
Base.copy(x::DArray{T,N,B,F}) where {T,N,B,F} =
212219
map(identity, x)::DArray{T,N,B,F}
213220

0 commit comments

Comments
 (0)