Skip to content

Commit b751f9e

Browse files
committed
fix to_fusiontensor name
1 parent cb15d63 commit b751f9e

File tree

7 files changed

+16
-21
lines changed

7 files changed

+16
-21
lines changed

src/fusiontensor/array_cast.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ using TensorAlgebra: contract
1010
# ================================= High level interface =================================
1111

1212
#### cast from array to symmetric
13-
function to_fusiontensor(
14-
array::AbstractArray,
15-
codomain_legs::Tuple{Vararg{AbstractGradedUnitRange}},
16-
domain_legs::Tuple{Vararg{AbstractGradedUnitRange}},
17-
)
18-
return to_fusiontensor(array, codomain_legs, domain_legs)
19-
end
2013

2114
#### cast from symmetric to array
2215
function BlockSparseArrays.BlockSparseArray(ft::FusionTensor)

src/fusiontensor/base_interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Base.:*(ft::FusionTensor, x::Number) = x * ft
1313
function Base.:*(left::FusionTensor, right::FusionTensor)
1414
checkaxes_dual(domain_axes(left), codomain_axes(right))
1515
new_data_matrix = data_matrix(left) * data_matrix(right)
16-
return to_fusiontensor(new_data_matrix, codomain_axes(left), domain_axes(right))
16+
return FusionTensor(new_data_matrix, codomain_axes(left), domain_axes(right))
1717
end
1818

1919
Base.:+(ft::FusionTensor) = ft

src/fusiontensor/fusiontensor.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ function BlockArrays.findblock(ft::FusionTensor, f1::SectorFusionTree, f2::Secto
8181
b2 = find_sector_block.(leaves(f2), dual.(domain_axes(ft)))
8282
return Block(b1..., b2...)
8383
end
84+
# TBD move to GradedUnitRanges? rename findfirst_sector?
8485
function find_sector_block(s::AbstractSector, l::AbstractGradedUnitRange)
8586
return findfirst(==(s), blocklabels(l))
8687
end

src/permutedims/permutedims.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function naive_permutedims(ft, biperm::BlockedPermutation{2})
1212
# naive permute: cast to dense, permutedims, cast to FusionTensor
1313
arr = Array(ft)
1414
permuted_arr = permutedims(arr, Tuple(biperm))
15-
permuted = FusionTensor(permuted_arr, new_codomain_legs, new_domain_legs)
15+
permuted = to_fusiontensor(permuted_arr, new_codomain_legs, new_domain_legs)
1616
return permuted
1717
end
1818

test/basics/test_basics.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using FusionTensors:
66
codomain_axes,
77
data_matrix,
88
domain_axes,
9-
fusiontensor,
9+
FusionTensor,
1010
checkaxes,
1111
checkaxes_dual,
1212
matrix_column_axis,
@@ -30,7 +30,7 @@ include("setup.jl")
3030
@test space_isequal(matrix_column_axis(ft0), g2)
3131

3232
m = BlockSparseArray{Float64}(g1, g2)
33-
ft1 = fusiontensor(m, (g1,), (g2,))
33+
ft1 = FusionTensor(m, (g1,), (g2,))
3434

3535
# getters
3636
@test data_matrix(ft1) == m
@@ -100,7 +100,7 @@ end
100100
gr = fusion_product(g1, g2)
101101
gc = dual(fusion_product(dual(g3), dual(g4)))
102102
m2 = BlockSparseArray{Float64}(gr, gc)
103-
ft = fusiontensor(m2, (g1, g2), (g3, g4))
103+
ft = FusionTensor(m2, (g1, g2), (g3, g4))
104104

105105
@test data_matrix(ft) == m2
106106
@test checkaxes(codomain_axes(ft), (g1, g2))

test/basics/test_linear_algebra.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using Test: @test, @testset
55
using BlockArrays: BlockArrays
66

77
using BlockSparseArrays: BlockSparseArrays
8-
using FusionTensors: FusionTensor
8+
using FusionTensors: FusionTensor, to_fusiontensor
99
using GradedUnitRanges: dual, gradedrange
1010
using SymmetrySectors: U1, SU2, TrivialSector
1111

@@ -30,7 +30,7 @@ include("setup.jl")
3030
@test norm(ft0) == 0
3131
@test tr(ft0) == 0
3232

33-
ft = FusionTensor(sdst, (g, g), (dual(g), dual(g)))
33+
ft = to_fusiontensor(sdst, (g, g), (dual(g), dual(g)))
3434
@test isnothing(check_sanity(ft))
3535
@test norm(ft) 3 / 2
3636
@test isapprox(tr(ft), 0; atol=eps(Float64))

test/basics/test_permutedims.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ using FusionTensors:
99
matrix_row_axis,
1010
naive_permutedims,
1111
ndims_domain,
12-
ndims_codomain
12+
ndims_codomain,
13+
to_fusiontensor
1314
using GradedUnitRanges: dual, gradedrange, space_isequal
1415
using SymmetrySectors: O2, U1, SectorProduct, SU2
1516
using TensorAlgebra: blockedperm
@@ -67,7 +68,7 @@ include("setup.jl")
6768
arr[3:4, 1:3, 5:5, 1:2] .= 2.0
6869
arr[1:2, 4:5, 5:5, 1:2] .= 3.0
6970
arr[3:4, 4:5, 1:4, 3:3] .= 4.0
70-
ft = FusionTensor(arr, codomain_legs, domain_legs)
71+
ft = to_fusiontensor(arr, codomain_legs, domain_legs)
7172
biperm = blockedperm((3,), (2, 4, 1))
7273

7374
ftp = permutedims(ft, biperm)
@@ -85,7 +86,7 @@ include("setup.jl")
8586

8687
@testset "Less than two axes" begin
8788
if VERSION >= v"1.11"
88-
@test_broken FusionTensor(ones(()), (), ()) isa FusionTensor
89+
@test_broken to_fusiontensor(ones(()), (), ()) isa FusionTensor
8990
#= ft0p = permutedims(ft0, (), ())
9091
@test ft0p isa FusionTensor{Float64,0}
9192
@test data_matrix(ft0p) ≈ data_matrix(ft0)
@@ -100,7 +101,7 @@ include("setup.jl")
100101
v = zeros((6,))
101102
v[1] = 1.0
102103
biperm = blockedperm((), (1,))
103-
ft1 = FusionTensor(v, (g,), ())
104+
ft1 = to_fusiontensor(v, (g,), ())
104105
ft2 = permutedims(ft1, biperm)
105106
@test isnothing(check_sanity(ft2))
106107
@test ft2 naive_permutedims(ft1, biperm)
@@ -142,16 +143,16 @@ end
142143
for biperm in [
143144
blockedperm((2, 1), (3, 4)), blockedperm((3, 1), (2, 4)), blockedperm((3, 1, 4), (2,))
144145
]
145-
ft = FusionTensor(sds22, (g2, g2), (g2b, g2b))
146+
ft = to_fusiontensor(sds22, (g2, g2), (g2b, g2b))
146147
@test permutedims(ft, biperm) naive_permutedims(ft, biperm)
147148
@test permutedims(adjoint(ft), biperm) naive_permutedims(adjoint(ft), biperm)
148149

149-
ft = FusionTensor(sds22b, (g2, g2b), (g2b, g2))
150+
ft = to_fusiontensor(sds22b, (g2, g2b), (g2b, g2))
150151
@test permutedims(ft, biperm) naive_permutedims(ft, biperm)
151152
@test permutedims(adjoint(ft), biperm) naive_permutedims(adjoint(ft), biperm)
152153
end
153154
for biperm in [blockedperm((1, 2, 3, 4), ()), blockedperm((), (3, 1, 2, 4))]
154-
ft = FusionTensor(sds22, (g2, g2), (g2b, g2b))
155+
ft = to_fusiontensor(sds22, (g2, g2), (g2b, g2b))
155156
@test permutedims(ft, biperm) naive_permutedims(ft, biperm)
156157
end
157158
end

0 commit comments

Comments
 (0)