Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test rewrite #85

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
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
147 changes: 144 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,145 @@ concurrency:
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
sectors: ${{ steps.filter.outputs.sectors }}
fusiontrees: ${{ steps.filter.outputs.fusiontrees }}
spaces: ${{ steps.filter.outputs.spaces }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
sectors:
- 'src/sectors/**'
- 'test/sectors.jl'
fusiontrees:
- 'src/fusiontrees/**'
- 'test/fusiontrees.jl'
spaces:
- 'src/spaces/**'
- 'test/spaces.jl'
test-sectors:
needs: changes
if: ${{ needs.changes.outputs.sectors == 'true' }}
name: "Sectors : Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.6' # LTS version
- '1' # automatically expands to the latest stable 1.x release of Julia
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
- x86
exclude:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: lkdvos/julia-runtest@main
with:
suffix: "sectors"
env:
JULIA_NUM_THREADS: 4
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
with:
file: lcov.info
test-spaces:
needs: changes
if: ${{ needs.changes.outputs.spaces == 'true' }}
name: "Spaces : Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.6' # LTS version
- '1' # automatically expands to the latest stable 1.x release of Julia
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
- x86
exclude:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: lkdvos/julia-runtest@main
with:
suffix: "spaces"
env:
JULIA_NUM_THREADS: 4
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
with:
file: lcov.info
test-fusiontrees:
needs: changes
if: ${{ needs.changes.outputs.fusiontrees == 'true' }}
name: "Fusiontrees : Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.6' # LTS version
- '1' # automatically expands to the latest stable 1.x release of Julia
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
- x86
exclude:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: lkdvos/julia-runtest@main
with:
suffix: "fusiontrees"
env:
JULIA_NUM_THREADS: 4
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
with:
file: lcov.info
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
name: "Tests : Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -41,7 +178,9 @@ jobs:
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: lkdvos/julia-runtest@main
with:
suffix: '-sectors -spaces -fusiontrees'
env:
JULIA_NUM_THREADS: 4
- uses: julia-actions/julia-processcoverage@v1
Expand Down Expand Up @@ -71,6 +210,8 @@ jobs:
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: lkdvos/julia-runtest@main
with:
suffix: tensors
env:
JULIA_NUM_THREADS: 4
7 changes: 2 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,14 @@ WignerSymbols = "1,2"
julia = "1.6"

[extras]
CategoryData = "8fccf25a-f50e-468c-8fba-3cb130506274"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
HalfIntegers = "f0d1745a-41c9-11e9-1dd9-e5d34d218721"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"

[targets]
test = ["Combinatorics", "HalfIntegers", "LinearAlgebra", "Random", "TensorOperations", "Test", "TestExtras", "WignerSymbols", "ChainRulesCore", "ChainRulesTestUtils", "FiniteDifferences"]
test = ["Combinatorics", "Random", "Test", "TestExtras", "ChainRulesCore", "ChainRulesTestUtils", "FiniteDifferences", "CategoryData"]
2 changes: 1 addition & 1 deletion src/TensorKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module TensorKit
export Sector, AbstractIrrep, Irrep
export FusionStyle, UniqueFusion, MultipleFusion, MultiplicityFreeFusion,
SimpleFusion, GenericFusion
export BraidingStyle, SymmetricBraiding, Bosonic, Fermionic, Anyonic
export BraidingStyle, SymmetricBraiding, Bosonic, Fermionic, Anyonic, NoBraiding
export Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, U1Irrep, SU2Irrep, CU1Irrep
export FermionParity, FermionNumber, FermionSpin
export FibonacciAnyon, IsingAnyon
Expand Down
2 changes: 1 addition & 1 deletion src/planar/planaroperations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function planarcontract!(C::AbstractTensorMap{S,N₁,N₂},
β::Number,
backend::Backend...) where {S,N₁,N₂}
if BraidingStyle(sectortype(S)) == Bosonic()
return contract(C, A, pA, B, pB, pAB, α, β, backend...)
return contract!(C, A, pA, B, pB, pAB, α, β, backend...)
end

codA, domA = codomainind(A), domainind(A)
Expand Down
2 changes: 2 additions & 0 deletions src/sectors/sectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ function pentagon_equation(a::I, b::I, c::I, d::I; kwargs...) where {I<:Sector}
end

function hexagon_equation(a::I, b::I, c::I; kwargs...) where {I<:Sector}
BraidingStyle(I) isa NoBraiding &&
throw(ArgumentError("Hexagon equation only defined for sectors with braiding"))
for e in ⊗(c, a), f in ⊗(c, b)
for d in intersect(⊗(e, b), ⊗(a, f))
if FusionStyle(I) isa MultiplicityFreeFusion
Expand Down
50 changes: 48 additions & 2 deletions src/tensors/braidingtensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,33 @@ end

blocks(b::BraidingTensor) = blocks(TensorMap(b))

# Index manipulations
# -------------------
has_shared_permute(t::BraidingTensor, args...) = false
function add_transform!(tdst::AbstractTensorMap{S,N₁,N₂},
tsrc::BraidingTensor{S},
(p₁, p₂)::Index2Tuple{N₁,N₂},
fusiontreetransform,
α::Number,
β::Number,
backend::Backend...) where {S,N₁,N₂}
return add_transform!(tdst, copy(tsrc), (p₁, p₂), fusiontreetransform, α, β, backend...)
end

# VectorInterface
# ---------------
# TODO

# Planar operations
# -----------------
function planaradd!(C::AbstractTensorMap{S,N₁,N₂},
A::BraidingTensor{S},
p::Index2Tuple{N₁,N₂},
α::Number, β::Number,
backend::Backend...) where {S,N₁,N₂}
return planaradd!(C, copy(A), p, α, β, backend...)
end

function planarcontract!(C::AbstractTensorMap{S,N₁,N₂},
A::BraidingTensor{S},
(oindA, cindA)::Index2Tuple{2,2},
Expand Down Expand Up @@ -278,6 +305,27 @@ function planarcontract!(C::AbstractTensorMap{S,N₁,N₂},
return C
end

# Fallback cases for planarcontract!
# TODO: implement specialised cases for contracting 0, 1, 3 and 4 indices
function planarcontract!(C::AbstractTensorMap{S}, A::BraidingTensor{S}, pA::Index2Tuple,
B::AbstractTensorMap{S}, pB::Index2Tuple, α::Number, β::Number,
backend::Backend...) where {S}
return planarcontract!(C, copy(A), pA, B, pB, α, β, backend...)
end
function planarcontract!(C::AbstractTensorMap{S}, A::AbstractTensorMap{S}, pA::Index2Tuple,
B::BraidingTensor{S}, pB::Index2Tuple, α::Number, β::Number,
backend::Backend...) where {S}
return planarcontract!(C, A, pA, copy(B), pB, α, β, backend...)
end

function planartrace!(C::AbstractTensorMap{S,N₁,N₂},
A::BraidingTensor{S},
p::Index2Tuple{N₁,N₂}, q::Index2Tuple{N₃,N₃},
α::Number, β::Number,
backend::Backend...) where {S,N₁,N₂,N₃}
return planartrace!(C, copy(A), p, q, α, β, backend...)
end

# function planarcontract!(C::AbstractTensorMap{S,N₁,N₂},
# A::BraidingTensor{S},
# (oindA, cindA)::Index2Tuple{0,4},
Expand Down Expand Up @@ -538,5 +586,3 @@ end
# end
# return C
# end

has_shared_permute(t::BraidingTensor, args...) = false
6 changes: 3 additions & 3 deletions src/tensors/indexmanipulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If `copy=false`, `tdst` might share data with `tsrc` whenever possible. Otherwis

To permute into an existing destination, see [permute!](@ref) and [`add_permute!`](@ref)
"""
function permute(t::TensorMap{S}, (p₁, p₂)::Index2Tuple{N₁,N₂};
function permute(t::AbstractTensorMap{S}, (p₁, p₂)::Index2Tuple{N₁,N₂};
copy::Bool=false) where {S,N₁,N₂}
cod = ProductSpace{S,N₁}(map(n -> space(t, n), p₁))
dom = ProductSpace{S,N₂}(map(n -> dual(space(t, n)), p₂))
Expand Down Expand Up @@ -108,7 +108,7 @@ If `copy=false`, `tdst` might share data with `tsrc` whenever possible. Otherwis

To braid into an existing destination, see [braid!](@ref) and [`add_braid!`](@ref)
"""
function braid(t::TensorMap{S}, (p₁, p₂)::Index2Tuple, levels::IndexTuple;
function braid(t::AbstractTensorMap{S}, (p₁, p₂)::Index2Tuple, levels::IndexTuple;
copy::Bool=false) where {S}
@assert length(levels) == numind(t)
if BraidingStyle(sectortype(S)) isa SymmetricBraiding
Expand Down Expand Up @@ -161,7 +161,7 @@ If `copy=false`, `tdst` might share data with `tsrc` whenever possible. Otherwis

To permute into an existing destination, see [permute!](@ref) and [`add_permute!`](@ref)
"""
function LinearAlgebra.transpose(t::TensorMap{S},
function LinearAlgebra.transpose(t::AbstractTensorMap{S},
(p₁, p₂)::Index2Tuple=_transpose_indices(t);
copy::Bool=false) where {S}
if sectortype(S) === Trivial
Expand Down
Loading
Loading