Skip to content

Commit c94ec36

Browse files
committed
change copy implementation to handle adjoint better
Also fix `eltype` in `similar` call
1 parent 063bdd7 commit c94ec36

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/tensors/abstractblocktensor/abstractarray.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,13 @@ end
197197
return @inbounds get(parent(t), key, default)
198198
end
199199

200-
Base.copy(t::AbstractBlockTensorMap) = copy!(similar(t), t)
200+
function Base.copy(t::AbstractBlockTensorMap)
201+
return copy!(similar(t, Base.promote_op(copy, eltype(t)), space(t)), t)
202+
end
201203
function Base.copy!(tdst::AbstractBlockTensorMap, tsrc::AbstractBlockTensorMap)
202204
space(tdst) == space(tsrc) || throw(SpaceMismatch("$(space(tdst))$(space(tsrc))"))
203205
@inbounds for (key, value) in nonzero_pairs(tsrc)
204-
tdst[key] = copy(value)
206+
tdst[key] = copy!(tdst[key], value)
205207
end
206208
return tdst
207209
end

0 commit comments

Comments
 (0)