Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BlockTensorKit"
uuid = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
authors = ["Lukas Devos <ldevos98@gmail.com> and contributors"]
version = "0.1.6"
version = "0.1.7"

[deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
Expand Down
6 changes: 4 additions & 2 deletions src/tensors/abstractblocktensor/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@
return @inbounds get(parent(t), key, default)
end

Base.copy(t::AbstractBlockTensorMap) = copy!(similar(t), t)
function Base.copy(t::AbstractBlockTensorMap)
return copy!(similar(t, Base.promote_op(copy, eltype(t)), space(t)), t)

Check warning on line 201 in src/tensors/abstractblocktensor/abstractarray.jl

View check run for this annotation

Codecov / codecov/patch

src/tensors/abstractblocktensor/abstractarray.jl#L200-L201

Added lines #L200 - L201 were not covered by tests
end
function Base.copy!(tdst::AbstractBlockTensorMap, tsrc::AbstractBlockTensorMap)
space(tdst) == space(tsrc) || throw(SpaceMismatch("$(space(tdst)) ≠ $(space(tsrc))"))
@inbounds for (key, value) in nonzero_pairs(tsrc)
tdst[key] = copy(value)
tdst[key] = copy!(tdst[key], value)

Check warning on line 206 in src/tensors/abstractblocktensor/abstractarray.jl

View check run for this annotation

Codecov / codecov/patch

src/tensors/abstractblocktensor/abstractarray.jl#L206

Added line #L206 was not covered by tests
end
return tdst
end
Expand Down
10 changes: 10 additions & 0 deletions test/abstracttensor/blocktensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,16 @@ end
@test ta ≈ tb
end

@testset "Adjoint via conversion" begin
t1 = rand(ComplexF64, V1 ⊗ V2 ← V4')
a = convert(TensorMap, t1)
t1adj = @constinferred adjoint(t1)
t1adj′ = @constinferred copy(t1adj)
@test !(eltype(t1adj′) <: TensorKit.AdjointTensorMap)
@test t1adj ≈ t1adj′
@test a' ≈ convert(TensorMap, t1adj)
end

# if hasfusiontensor(I)
# @timedtestset "Tensor functions" begin
# W = V1 ⊗ V2
Expand Down