Skip to content
Open
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
3 changes: 3 additions & 0 deletions ext/TensorKitAdaptExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ function Adapt.adapt_structure(to, x::DiagonalTensorMap)
data′ = adapt(to, x.data)
return DiagonalTensorMap(data′, x.domain)
end
function Adapt.adapt_structure(::Type{TorA}, x::BraidingTensor) where {TorA <: Union{Number, DenseArray{<:Number}}}
return BraidingTensor{scalartype(TorA)}(space(x), x.adjoint)
end

end
4 changes: 4 additions & 0 deletions test/tensors/planar.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Test, TestExtras
using Adapt
using TensorKit
using TensorKit: PlanarTrivial, ℙ
using TensorKit: planaradd!, planartrace!, planarcontract!
Expand All @@ -19,6 +20,9 @@ using .TestSetup
t2 = @constinferred BraidingTensor{ComplexF64}(W)
@test scalartype(t2) == ComplexF64
@test storagetype(t2) == Vector{ComplexF64}
t3 = @testinferred adapt(storagetype(t2), t1)
@test storagetype(t3) == storagetype(t2)
@test t3 == t2

W2 = reverse(codomain(W)) ← domain(W)
@test_throws SpaceMismatch BraidingTensor(W2)
Expand Down