Skip to content

Commit f15bf71

Browse files
committed
Fix tensor map subtype bounds and add regression coverage
1 parent b58fa66 commit f15bf71

6 files changed

Lines changed: 20 additions & 7 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
__pycache__
77
.ipynb*
88
*Manifest.toml
9+
*LocalPreferences.toml
910
.vscode
1011
experimental
1112
refs

‎src/tensors/adjoint.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# AdjointTensorMap: lazy adjoint
22
#==========================================================#
33
"""
4-
struct AdjointTensorMap{T, S, N₁, N₂, TT<:AbstractTensorMap} <: AbstractTensorMap{T, S, N₁, N₂}
4+
struct AdjointTensorMap{T<:Number, S<:IndexSpace, N₁, N₂, TT<:AbstractTensorMap} <: AbstractTensorMap{T, S, N₁, N₂}
55
66
Specific subtype of [`AbstractTensorMap`](@ref) that is a lazy wrapper for representing the
77
adjoint of an instance of [`AbstractTensorMap`](@ref).
88
"""
9-
struct AdjointTensorMap{T, S, N₁, N₂, TT <: AbstractTensorMap{T, S, N₂, N₁}} <:
9+
struct AdjointTensorMap{T <: Number, S <: IndexSpace, N₁, N₂, TT <: AbstractTensorMap{T, S, N₂, N₁}} <:
1010
AbstractTensorMap{T, S, N₁, N₂}
1111
parent::TT
1212
end

‎src/tensors/braidingtensor.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# special (2,2) tensor that implements a standard braiding operation
33
#====================================================================#
44
"""
5-
struct BraidingTensor{T, S <: IndexSpace, A <: DenseVector{T}} <: AbstractTensorMap{T, S, 2, 2}
5+
struct BraidingTensor{T <: Number, S <: IndexSpace, A <: DenseVector{T}} <: AbstractTensorMap{T, S, 2, 2}
66
BraidingTensor(V1::S, V2::S, adjoint::Bool=false) where {S<:IndexSpace}
77
BraidingTensor{T, S, A}(V1::S, V2::S, adjoint::Bool=false) where {T, S, A}
88
@@ -14,7 +14,7 @@ It holds that `domain(BraidingTensor(V1, V2)) == V1 ⊗ V2` and
1414
controls the array type of the braiding tensor used when indexing
1515
and multiplying with other tensors.
1616
"""
17-
struct BraidingTensor{T, S, A <: DenseVector{T}} <: AbstractTensorMap{T, S, 2, 2}
17+
struct BraidingTensor{T <: Number, S <: IndexSpace, A <: DenseVector{T}} <: AbstractTensorMap{T, S, 2, 2}
1818
V1::S
1919
V2::S
2020
adjoint::Bool

‎src/tensors/diagonal.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DiagonalTensorMap
22
#==========================================================#
3-
struct DiagonalTensorMap{T, S <: IndexSpace, A <: DenseVector{T}} <: AbstractTensorMap{T, S, 1, 1}
3+
struct DiagonalTensorMap{T <: Number, S <: IndexSpace, A <: DenseVector{T}} <: AbstractTensorMap{T, S, 1, 1}
44
data::A
55
domain::S # equals codomain
66

‎src/tensors/tensor.jl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# general tensor implementation with arbitrary symmetries
33
#==========================================================#
44
"""
5-
struct TensorMap{T, S<:IndexSpace, N₁, N₂, A<:DenseVector{T}} <: AbstractTensorMap{T, S, N₁, N₂}
5+
struct TensorMap{T<:Number, S<:IndexSpace, N₁, N₂, A<:DenseVector{T}} <: AbstractTensorMap{T, S, N₁, N₂}
66
77
Specific subtype of [`AbstractTensorMap`](@ref) for representing tensor maps (morphisms in
88
a tensor category), where the data is stored in a dense vector.
99
"""
10-
struct TensorMap{T, S <: IndexSpace, N₁, N₂, A <: DenseVector{T}} <: AbstractTensorMap{T, S, N₁, N₂}
10+
struct TensorMap{T <: Number, S <: IndexSpace, N₁, N₂, A <: DenseVector{T}} <: AbstractTensorMap{T, S, N₁, N₂}
1111
data::A
1212
space::TensorMapSpace{S, N₁, N₂}
1313

‎test/tensors/subtyping.jl‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Test
2+
using TensorKit
3+
using TensorKit: AdjointTensorMap
4+
5+
@testset "Tensor map subtyping" begin
6+
for TT in (TensorMap, DiagonalTensorMap, AdjointTensorMap, BraidingTensor)
7+
@test TT <: AbstractTensorMap
8+
for T in (Float64, ComplexF64)
9+
@test TT{T} <: AbstractTensorMap{T}
10+
end
11+
end
12+
end

0 commit comments

Comments
 (0)