Skip to content

Commit

Permalink
Make empty_localpart use constructor instead of convert
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed May 23, 2017
1 parent 12a9596 commit 5ae4351
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/darray.jl
Expand Up @@ -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}}
Expand Down
5 changes: 5 additions & 0 deletions test/darray.jl
Expand Up @@ -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()
Expand Down

0 comments on commit 5ae4351

Please sign in to comment.