Skip to content

Commit 2524447

Browse files
authored
Increase code and test coverage (#381)
1 parent 24dde42 commit 2524447

6 files changed

Lines changed: 14 additions & 88 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Printf = "1"
5151
Random = "1"
5252
ScopedValues = "1.3.0"
5353
Strided = "2"
54-
TensorKitSectors = "0.3.6"
54+
TensorKitSectors = "0.3.7"
5555
TensorOperations = "5.1"
5656
TupleTools = "1.5"
5757
VectorInterface = "0.4.8, 0.5"

src/TensorKit.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ module TensorKit
88
# Exports
99
#---------
1010
# Reexport common sector types:
11-
export Sector, AbstractIrrep, Irrep
11+
export Sector, AbstractIrrep, Irrep, GroupElement
1212
export FusionStyle, UniqueFusion, MultipleFusion, MultiplicityFreeFusion, SimpleFusion, GenericFusion
1313
export UnitStyle, SimpleUnit, GenericUnit
1414
export BraidingStyle, SymmetricBraiding, Bosonic, Fermionic, Anyonic, NoBraiding, HasBraiding
15-
export Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, U1Irrep, SU2Irrep, CU1Irrep
15+
export Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, LargeZNIrrep
16+
export ZNElement, Z2Element, Z3Element, Z4Element, DNIrrep, A4Irrep, U1Irrep, SU2Irrep, CU1Irrep
1617
export ProductSector, TimeReversed
1718
export FermionParity, FermionNumber, FermionSpin
1819
export FibonacciAnyon, IsingAnyon, IsingBimodule
@@ -41,8 +42,9 @@ export infimum, supremum, isisomorphic, ismonomorphic, isepimorphic
4142

4243
# Reexport methods for sectors and properties thereof
4344
export sectortype, sectors, hassector
44-
export unit, rightunit, leftunit, allunits, isunit, otimes
45-
export Nsymbol, Fsymbol, Rsymbol, Bsymbol, frobenius_schur_phase, frobenius_schur_indicator, twist, sectorscalartype, deligneproduct
45+
export unit, rightunit, leftunit, allunits, isunit, otimes, deligneproduct, timereversed
46+
export Nsymbol, Fsymbol, Rsymbol, Bsymbol, frobenius_schur_phase, frobenius_schur_indicator, twist, fusiontensor
47+
export sectorscalartype, fusionscalartype, braidingscalartype
4648

4749
# Export methods for fusion trees
4850
export fusiontrees, braid, permute, transpose
@@ -52,7 +54,7 @@ export fusiontrees, braid, permute, transpose
5254

5355
# some unicode
5456
export , , , ×, , ℂ, ℝ, ℤ, , , , , , ,
55-
export ℤ₂, ℤ₃, ℤ₄, U₁, SU, SU₂, CU₁
57+
export ℤ₂, ℤ₃, ℤ₄, D₃, D₄, A₄, U₁, SU, SU₂, CU₁
5658
export fℤ₂, fU₁, fSU₂
5759
export ℤ₂Space, ℤ₃Space, ℤ₄Space, U₁Space, CU₁Space, SU₂Space
5860

src/auxiliary/dicts.jl

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -21,84 +21,6 @@ Base.get(d::SingletonDict, key, default) = isequal(d.key, key) ? d.value : defau
2121

2222
Base.iterate(d::SingletonDict, s = true) = s ? ((d.key => d.value), false) : nothing
2323

24-
struct VectorDict{K, V} <: AbstractDict{K, V}
25-
keys::Vector{K}
26-
values::Vector{V}
27-
end
28-
VectorDict{K, V}() where {K, V} = VectorDict{K, V}(Vector{K}(), Vector{V}())
29-
VectorDict() = VectorDict{Any, Any}()
30-
31-
function VectorDict{K, V}(kvs) where {K, V}
32-
keys = Vector{K}()
33-
values = Vector{V}()
34-
if Base.IteratorSize(kv) !== SizeUnknown()
35-
sizehint!(keys, length(kvs))
36-
sizehint!(values, length(kvs))
37-
end
38-
for (k, v) in kvs
39-
push!(keys, k)
40-
push!(values, v)
41-
end
42-
return VectorDict{K, V}(keys, values)
43-
end
44-
VectorDict(kv1::Pair{K, V}, kvs::Pair{K, V}...) where {K, V} = VectorDict{K, V}((kv1, kvs...))
45-
VectorDict(g::Base.Generator) = VectorDict(g...)
46-
47-
Base.length(d::VectorDict) = length(d.keys)
48-
function Base.sizehint!(d::VectorDict, newsz)
49-
(sizehint!(d.keys, newsz); sizehint!(d.values, newsz); return d)
50-
end
51-
52-
@propagate_inbounds getpair(d::VectorDict, i::Integer) = d.keys[i] => d.values[i]
53-
54-
Base.copy(d::VectorDict) = VectorDict(copy(d.keys), copy(d.values))
55-
Base.empty(::VectorDict, ::Type{K}, ::Type{V}) where {K, V} = VectorDict{K, V}()
56-
Base.empty!(d::VectorDict) = (empty!(d.keys); empty!(d.values); return d)
57-
58-
function Base.delete!(d::VectorDict, key)
59-
i = findfirst(isequal(key), d.keys)
60-
if !(i === nothing || i == 0)
61-
deleteat!(d.keys, i)
62-
deleteat!(d.values, i)
63-
end
64-
return d
65-
end
66-
67-
Base.keys(d::VectorDict) = d.keys
68-
Base.values(d::VectorDict) = d.values
69-
Base.haskey(d::VectorDict, key) = key in d.keys
70-
function Base.getindex(d::VectorDict, key)
71-
i = findfirst(isequal(key), d.keys)
72-
@inbounds begin
73-
return i !== nothing ? d.values[i] : throw(KeyError(key))
74-
end
75-
end
76-
function Base.setindex!(d::VectorDict, v, key)
77-
i = findfirst(isequal(key), d.keys)
78-
if i === nothing
79-
push!(d.keys, key)
80-
push!(d.values, v)
81-
else
82-
d.values[i] = v
83-
end
84-
return d
85-
end
86-
87-
function Base.get(d::VectorDict, key, default)
88-
i = findfirst(isequal(key), d.keys)
89-
@inbounds begin
90-
return i !== nothing ? d.values[i] : default
91-
end
92-
end
93-
94-
function Base.iterate(d::VectorDict, s = 1)
95-
@inbounds if s > length(d)
96-
return nothing
97-
else
98-
return (d.keys[s] => d.values[s]), s + 1
99-
end
100-
end
101-
10224
struct SortedVectorDict{K, V} <: AbstractDict{K, V}
10325
keys::Vector{K}
10426
values::Vector{V}

src/tensors/abstracttensor.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ See also [`domain`](@ref) and [`space`](@ref).
212212

213213
codomain(t::AbstractTensorMap) = codomain(space(t))
214214
codomain(t::AbstractTensorMap, i) = codomain(t)[i]
215-
target(t::AbstractTensorMap) = codomain(t) # categorical terminology
216215

217216
@doc """
218217
domain(t::AbstractTensorMap{T,S,N₁,N₂}) -> ProductSpace{S,N₂}
@@ -226,7 +225,6 @@ See also [`codomain`](@ref) and [`space`](@ref).
226225

227226
domain(t::AbstractTensorMap) = domain(space(t))
228227
domain(t::AbstractTensorMap, i) = domain(t)[i]
229-
source(t::AbstractTensorMap) = domain(t) # categorical terminology
230228

231229
@doc """
232230
numout(x) -> Int

test/setup.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ function randsector(::Type{I}) where {I <: Sector}
8787
return a
8888
end
8989
function hasfusiontensor(I::Type{<:Sector})
90-
isa(UnitStyle(I), GenericUnit) && return false
9190
try
92-
TensorKit.fusiontensor(unit(I), unit(I), unit(I))
91+
u = first(allunits(I))
92+
fusiontensor(u, u, u)
9393
return true
9494
catch e
9595
if e isa MethodError

test/tensors/diagonal.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ using TensorKit
44
diagspacelist = (
55
(ℂ^4)',
66
Vect[Z2Irrep](0 => 2, 1 => 3),
7+
Vect[Z3Element{1}](0 => 2, 1 => 3, 2 => 1),
8+
Vect[A4Irrep](0 => 1, 1 => 2, 2 => 2, 3 => 2),
79
Vect[FermionNumber](0 => 2, 1 => 2, -1 => 1),
810
Vect[SU2Irrep](0 => 2, 1 => 1)',
911
Vect[FibonacciAnyon](:I => 2, => 2),
12+
Vect[Z3Element{1}](0 => 2, 1 => 2, 2 => 1),
13+
Vect[IsingBimodule]((1, 1, 0) => 2, (1, 1, 1) => 3),
1014
)
1115

1216
@testset "DiagonalTensor with domain $V" for V in diagspacelist

0 commit comments

Comments
 (0)