diff --git a/NDTensors/src/tensor/tensor.jl b/NDTensors/src/tensor/tensor.jl index d5d10b371b..932f601d8a 100644 --- a/NDTensors/src/tensor/tensor.jl +++ b/NDTensors/src/tensor/tensor.jl @@ -213,7 +213,8 @@ imag(T::Tensor) = setstorage(T, imag(storage(T))) function Base.map(f, t1::Tensor, t_tail::Tensor...; kwargs...) elt = mapreduce(eltype, promote_type, (t1, t_tail...)) if !iszero(f(zero(elt))) - return map(f, array(t1), array.(t_tail)...; kwargs...) + # TODO: Do a better job of preserving the storage type, if possible. + return tensor(Dense(map(f, array(t1), array.(t_tail)...; kwargs...)), inds(t1)) end return setstorage(t1, map(f, storage(t1), storage.(t_tail)...; kwargs...)) end diff --git a/test/base/test_itensor.jl b/test/base/test_itensor.jl index ebcb88f2d1..0cbb0f5c68 100644 --- a/test/base/test_itensor.jl +++ b/test/base/test_itensor.jl @@ -160,7 +160,7 @@ end B = map(x -> 2x, A) @test B ≈ 2A @test eltype(B) == Float64 - @test_throws ErrorException map(x -> x + 1, A) + @test array(map(x -> x + 1, A)) ≈ map(x -> x + 1, array(A)) end @testset "getindex with state string" begin