Skip to content

Commit 5ae4351

Browse files
committed
Make empty_localpart use constructor instead of convert
1 parent 12a9596 commit 5ae4351

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/darray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type DArray{T,N,A} <: AbstractArray{T,N}
5656
end
5757

5858
eltype{T}(::Type{DArray{T}}) = T
59-
empty_localpart(T,N,A) = convert(A, Array{T}(ntuple(zero, N)))
59+
empty_localpart(T,N,A) = A(Array{T}(ntuple(zero, N)))
6060

6161
const SubDArray{T,N,D<:DArray} = SubArray{T,N,D}
6262
const SubOrDArray{T,N} = Union{DArray{T,N}, SubDArray{T,N}}

test/darray.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ using SpecialFunctions
4545
global A134 = drandn(1)
4646
@test DArray(I -> DistributedArrays.localpart(A134), A134) == A134
4747
end
48+
49+
@testset "empty_localpart should work when only constructor (not conversion is defined)" begin
50+
@test DistributedArrays.empty_localpart(Float64,2,LowerTriangular{Float64,Matrix{Float64}}) isa
51+
LowerTriangular
52+
end
4853
end
4954

5055
check_leaks()

0 commit comments

Comments
 (0)