Skip to content

Commit bc981f2

Browse files
committed
Make copy(DArray) copy
1 parent 5c6aa0d commit bc981f2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ Library improvements
152152

153153
* Added `recvfrom` to get source address of UDP packets ([#9418])
154154

155+
* copy(DArray) will now make a copy of the DArray ([#9745])
156+
155157
Deprecated or removed
156158
---------------------
157159

base/darray.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,13 @@ end
245245
getindex(d::DArray) = d[1]
246246
getindex(d::DArray, I::Union(Int,UnitRange{Int})...) = sub(d,I...)
247247

248-
copy(d::SubOrDArray) = d
248+
function copy!(dest::SubOrDArray, src::SubOrDArray)
249+
dest.dims == src.dims && dest.pmap == src.pmap && dest.indexes == src.indexes && dest.cuts == src.cuts || throw(ArgumentError("destination array doesn't fit to source array"))
250+
for p in dest.pmap
251+
@spawnat p copy!(localpart(dest), localpart(src))
252+
end
253+
dest
254+
end
249255

250256
# local copies are obtained by convert(Array, ) or assigning from
251257
# a SubDArray to a local Array.

0 commit comments

Comments
 (0)