diff --git a/src/array/array.jl b/src/array/array.jl index 329c238b0..b4cc08a60 100644 --- a/src/array/array.jl +++ b/src/array/array.jl @@ -144,7 +144,7 @@ function Base.similar(A::AbstractDimArray; data=similar(parent(A)), dims=dims(A), refdims=refdims(A), name=_noname(A), metadata=metadata(A), kw... ) - rebuild(A; dims=format(dims, data), refdims, name, metadata, kw...) + rebuild(A; data, dims=format(dims, data), refdims, name, metadata, kw...) end function Base.similar(A::AbstractDimArray, ::Type{T}; data=similar(parent(A), T), diff --git a/test/array.jl b/test/array.jl index 8a73b7793..dc5aea74c 100644 --- a/test/array.jl +++ b/test/array.jl @@ -127,6 +127,7 @@ end @testset "similar" begin @testset "similar with no args" begin da_sim = similar(da) + @test parent(da_sim) !== parent(da) # check if the same memory @test eltype(da_sim) == eltype(da) @test size(da_sim) == size(da) @test dims(da_sim) === dims(da) @@ -152,6 +153,7 @@ end @testset "similar with a type" begin da_float = @inferred similar(da, Float64) + @test parent(da_float) !== parent(da) # check if the same memory @test eltype(da_float) == Float64 @test size(da_float) == size(da) @test dims(da_float) === dims(da)