diff --git a/src/darray.jl b/src/darray.jl index 454a85e..5caec59 100644 --- a/src/darray.jl +++ b/src/darray.jl @@ -56,7 +56,7 @@ type DArray{T,N,A} <: AbstractArray{T,N} end eltype{T}(::Type{DArray{T}}) = T -empty_localpart(T,N,A) = convert(A, Array{T}(ntuple(zero, N))) +empty_localpart(T,N,A) = A(Array{T}(ntuple(zero, N))) const SubDArray{T,N,D<:DArray} = SubArray{T,N,D} const SubOrDArray{T,N} = Union{DArray{T,N}, SubDArray{T,N}} diff --git a/test/darray.jl b/test/darray.jl index 3ce4239..37f0f53 100644 --- a/test/darray.jl +++ b/test/darray.jl @@ -45,6 +45,11 @@ using SpecialFunctions global A134 = drandn(1) @test DArray(I -> DistributedArrays.localpart(A134), A134) == A134 end + + @testset "empty_localpart should work when only constructor (not conversion is defined)" begin + @test DistributedArrays.empty_localpart(Float64,2,LowerTriangular{Float64,Matrix{Float64}}) isa + LowerTriangular + end end check_leaks()