Skip to content

Commit f2ef131

Browse files
authored
Runic formatter (#18)
* update formatter to runic * update action * change precompile statement
1 parent c253ed7 commit f2ef131

File tree

17 files changed

+309
-268
lines changed

17 files changed

+309
-268
lines changed

.github/workflows/FormatCheck.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Format Check"
1+
name: FormatCheck
22

33
on:
44
push:
@@ -7,10 +7,11 @@ on:
77
- 'master'
88
tags: '*'
99
pull_request:
10+
branches:
11+
- 'main'
12+
- 'master'
1013

1114
jobs:
12-
format-check:
15+
formatcheck:
1316
name: "Format Check"
14-
uses: "QuantumKitHub/.github/.github/workflows/formatcheck.yml@main"
15-
with:
16-
juliaformatter-version: "2"
17+
uses: "QuantumKitHub/QuantumKitHubActions/.github/workflows/FormatCheck.yml@main"

src/TensorKitSectors.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export sectorscalartype
1010
export dim, sqrtdim, invsqrtdim, frobeniusschur, twist, fusiontensor, dual
1111
export otimes, deligneproduct, times
1212
export FusionStyle, UniqueFusion, MultipleFusion, SimpleFusion, GenericFusion,
13-
MultiplicityFreeFusion
13+
MultiplicityFreeFusion
1414
export BraidingStyle, NoBraiding, SymmetricBraiding, Bosonic, Fermionic, Anyonic
1515
export SectorSet, SectorValues, findindex
1616
export rightone, leftone
@@ -58,11 +58,14 @@ include("multifusion.jl") # multifusion example, namely Rep Z2 ⊕ Rep Z2 ≅ Is
5858
include("precompile.jl")
5959

6060
function __precompile__()
61-
for I in (Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, U1Irrep, SU2Irrep, CU1Irrep,
62-
FermionParity, FermionNumber, FermionSpin, PlanarTrivial, FibonacciAnyon,
63-
IsingAnyon, TimeReversed{IsingAnyon}, TimeReversed{FibonacciAnyon})
61+
for I in (
62+
Trivial, Z2Irrep, Z3Irrep, Z4Irrep, ZNIrrep, U1Irrep, SU2Irrep, CU1Irrep,
63+
FermionParity, FermionNumber, FermionSpin, PlanarTrivial, FibonacciAnyon,
64+
IsingAnyon, TimeReversed{IsingAnyon}, TimeReversed{FibonacciAnyon},
65+
)
6466
precompile_sector(I)
6567
end
68+
return
6669
end
6770

6871
end # module TensorKitSectors

src/anyons.jl

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ struct PlanarTrivial <: Sector end
1313

1414
Base.IteratorSize(::Type{SectorValues{PlanarTrivial}}) = HasLength()
1515
Base.length(::SectorValues{PlanarTrivial}) = 1
16-
Base.iterate(::SectorValues{PlanarTrivial}, i=0) = i == 0 ? (PlanarTrivial(), 1) : nothing
16+
Base.iterate(::SectorValues{PlanarTrivial}, i = 0) = i == 0 ? (PlanarTrivial(), 1) : nothing
1717
function Base.getindex(::SectorValues{PlanarTrivial}, i::Int)
1818
return i == 1 ? PlanarTrivial() :
19-
throw(BoundsError(values(PlanarTrivial), i))
19+
throw(BoundsError(values(PlanarTrivial), i))
2020
end
2121
findindex(::SectorValues{PlanarTrivial}, c::PlanarTrivial) = 1
2222
Base.isless(::PlanarTrivial, ::PlanarTrivial) = false
@@ -28,8 +28,8 @@ FusionStyle(::Type{PlanarTrivial}) = UniqueFusion()
2828
BraidingStyle(::Type{PlanarTrivial}) = NoBraiding()
2929
Base.isreal(::Type{PlanarTrivial}) = true
3030

31-
Nsymbol(::Vararg{PlanarTrivial,3}) = 1
32-
Fsymbol(::Vararg{PlanarTrivial,6}) = 1
31+
Nsymbol(::Vararg{PlanarTrivial, 3}) = 1
32+
Fsymbol(::Vararg{PlanarTrivial, 6}) = 1
3333

3434
(::PlanarTrivial, ::PlanarTrivial) = (PlanarTrivial(),)
3535

@@ -56,7 +56,7 @@ end
5656

5757
Base.IteratorSize(::Type{SectorValues{FibonacciAnyon}}) = HasLength()
5858
Base.length(::SectorValues{FibonacciAnyon}) = 2
59-
function Base.iterate(::SectorValues{FibonacciAnyon}, i=0)
59+
function Base.iterate(::SectorValues{FibonacciAnyon}, i = 0)
6060
return i == 0 ? (FibonacciAnyon(:I), 1) : (i == 1 ? (FibonacciAnyon(), 2) : nothing)
6161
end
6262
function Base.getindex(S::SectorValues{FibonacciAnyon}, i::Int)
@@ -91,7 +91,7 @@ Base.IteratorSize(::Type{FibonacciIterator}) = Base.HasLength()
9191
Base.IteratorEltype(::Type{FibonacciIterator}) = Base.HasEltype()
9292
Base.length(iter::FibonacciIterator) = (isone(iter.a) || isone(iter.b)) ? 1 : 2
9393
Base.eltype(::Type{FibonacciIterator}) = FibonacciAnyon
94-
function Base.iterate(iter::FibonacciIterator, state=1)
94+
function Base.iterate(iter::FibonacciIterator, state = 1)
9595
I = FibonacciAnyon(:I)
9696
τ = FibonacciAnyon()
9797
if state == 1 # first iteration
@@ -110,8 +110,10 @@ function Nsymbol(a::FibonacciAnyon, b::FibonacciAnyon, c::FibonacciAnyon)
110110
return isone(a) + isone(b) + isone(c) != 2
111111
end # zero if one tau and two ones
112112

113-
function Fsymbol(a::FibonacciAnyon, b::FibonacciAnyon, c::FibonacciAnyon,
114-
d::FibonacciAnyon, e::FibonacciAnyon, f::FibonacciAnyon)
113+
function Fsymbol(
114+
a::FibonacciAnyon, b::FibonacciAnyon, c::FibonacciAnyon,
115+
d::FibonacciAnyon, e::FibonacciAnyon, f::FibonacciAnyon
116+
)
115117
Nsymbol(a, b, e) || return zero(_goldenratio)
116118
Nsymbol(e, c, d) || return zero(_goldenratio)
117119
Nsymbol(b, c, f) || return zero(_goldenratio)
@@ -144,7 +146,7 @@ end
144146
function Base.show(io::IO, a::FibonacciAnyon)
145147
s = isone(a) ? ":I" : ""
146148
return get(io, :typeinfo, nothing) === FibonacciAnyon ?
147-
print(io, s) : print(io, "FibonacciAnyon(", s, ")")
149+
print(io, s) : print(io, "FibonacciAnyon(", s, ")")
148150
end
149151

150152
Base.hash(a::FibonacciAnyon, h::UInt) = hash(a.isone, h)
@@ -179,7 +181,7 @@ const all_isinganyons = (IsingAnyon(:I), IsingAnyon(:σ), IsingAnyon(:ψ))
179181

180182
Base.IteratorSize(::Type{SectorValues{IsingAnyon}}) = HasLength()
181183
Base.length(::SectorValues{IsingAnyon}) = length(all_isinganyons)
182-
Base.iterate(::SectorValues{IsingAnyon}, i=1) = iterate(all_isinganyons, i)
184+
Base.iterate(::SectorValues{IsingAnyon}, i = 1) = iterate(all_isinganyons, i)
183185
Base.getindex(::SectorValues{IsingAnyon}, i::Int) = getindex(all_isinganyons, i)
184186

185187
function findindex(::SectorValues{IsingAnyon}, a::IsingAnyon)
@@ -214,7 +216,7 @@ function Base.length(iter::IsingIterator)
214216
return (iter.a == σ && iter.b == σ) ? 2 : 1
215217
end
216218

217-
function Base.iterate(iter::IsingIterator, state=1)
219+
function Base.iterate(iter::IsingIterator, state = 1)
218220
I, σ, ψ = all_isinganyons
219221
if state == 1 # first iteration
220222
iter.a == I && return (iter.b, 2)
@@ -232,16 +234,20 @@ end
232234

233235
function Nsymbol(a::IsingAnyon, b::IsingAnyon, c::IsingAnyon)
234236
I, σ, ψ = all_isinganyons
235-
return ((a == I && b == c)
237+
return (
238+
(a == I && b == c)
236239
|| (b == I && a == c)
237240
|| (c == I && a == b)
238241
|| (a == σ && b == σ && c == ψ)
239242
|| (a == σ && b == ψ && c == σ)
240-
|| (a == ψ && b == σ && c == σ))
243+
|| (a == ψ && b == σ && c == σ)
244+
)
241245
end
242246

243-
function Fsymbol(a::IsingAnyon, b::IsingAnyon, c::IsingAnyon,
244-
d::IsingAnyon, e::IsingAnyon, f::IsingAnyon)
247+
function Fsymbol(
248+
a::IsingAnyon, b::IsingAnyon, c::IsingAnyon,
249+
d::IsingAnyon, e::IsingAnyon, f::IsingAnyon
250+
)
245251
Nsymbol(a, b, e) || return 0.0
246252
Nsymbol(e, c, d) || return 0.0
247253
Nsymbol(b, c, f) || return 0.0

src/auxiliary.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ end
3131
end
3232

3333
@inline localoffset(d, I::Tuple{Int}, sz::Tuple{Int}) = 0
34-
@inline function localoffset(d, I::NTuple{N,Int}, sz::NTuple{N,Int}) where {N}
34+
@inline function localoffset(d, I::NTuple{N, Int}, sz::NTuple{N, Int}) where {N}
3535
offset = 0
3636
for i in 1:(I[1] - 1)
3737
offset += num_manhattan_points(d - i + 1, Base.tail(sz))
@@ -55,7 +55,7 @@ end
5555

5656
# inverse mapping
5757
@inline invertlocaloffset(d, offset, sz::Tuple{Int}) = (d + 1,)
58-
@inline function invertlocaloffset(d, offset, sz::Tuple{Int,Int,Vararg{Int}})
58+
@inline function invertlocaloffset(d, offset, sz::Tuple{Int, Int, Vararg{Int}})
5959
i₁ = 1
6060
while i₁ < sz[1]
6161
jump = num_manhattan_points(d - i₁ + 1, Base.tail(sz))

src/fermions.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Base.convert(::Type{FermionParity}, a) = FermionParity(a)
2020

2121
Base.IteratorSize(::Type{SectorValues{FermionParity}}) = HasLength()
2222
Base.length(::SectorValues{FermionParity}) = 2
23-
function Base.iterate(::SectorValues{FermionParity}, i=0)
23+
function Base.iterate(::SectorValues{FermionParity}, i = 0)
2424
return i == 2 ? nothing : (FermionParity(i), i + 1)
2525
end
2626
function Base.getindex(::SectorValues{FermionParity}, i::Int)
@@ -41,21 +41,21 @@ Base.isreal(::Type{FermionParity}) = true
4141
function Nsymbol(a::FermionParity, b::FermionParity, c::FermionParity)
4242
return (a.isodd b.isodd) == c.isodd
4343
end
44-
function Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {I<:FermionParity}
44+
function Fsymbol(a::I, b::I, c::I, d::I, e::I, f::I) where {I <: FermionParity}
4545
return Int(Nsymbol(a, b, e) * Nsymbol(e, c, d) * Nsymbol(b, c, f) * Nsymbol(a, f, d))
4646
end
47-
function Rsymbol(a::I, b::I, c::I) where {I<:FermionParity}
47+
function Rsymbol(a::I, b::I, c::I) where {I <: FermionParity}
4848
return a.isodd && b.isodd ? -Int(Nsymbol(a, b, c)) : Int(Nsymbol(a, b, c))
4949
end
5050
twist(a::FermionParity) = a.isodd ? -1 : +1
5151

52-
function fusiontensor(a::I, b::I, c::I) where {I<:FermionParity}
52+
function fusiontensor(a::I, b::I, c::I) where {I <: FermionParity}
5353
@warn "FermionParity Arrays do not preserve categorical properties." maxlog = 1
5454
return fill(Int(Nsymbol(a, b, c)), (1, 1, 1, 1))
5555
end
5656

5757
function Base.show(io::IO, a::FermionParity)
58-
if get(io, :typeinfo, nothing) === typeof(a)
58+
return if get(io, :typeinfo, nothing) === typeof(a)
5959
print(io, Int(a.isodd))
6060
else
6161
print(io, type_repr(typeof(a)), "(", Int(a.isodd), ")")
@@ -97,7 +97,7 @@ See also: [`SU2Irrep`](@ref), [`FermionParity`](@ref)
9797
"""
9898
const FermionSpin = SU2Irrep FermionParity
9999
const fSU₂ = FermionSpin
100-
FermionSpin(j::Real) = (s=SU2Irrep(j); s FermionParity(isodd(twice(s.j))))
100+
FermionSpin(j::Real) = (s = SU2Irrep(j); s FermionParity(isodd(twice(s.j))))
101101
type_repr(::Type{FermionSpin}) = "FermionSpin"
102102

103103
# convenience default converter -> allows Vect[FermionSpin](1 => 1)

src/groups.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type_repr(T::Type) = repr(T)
2121

2222
const GroupTuple = Tuple{Vararg{Group}}
2323

24-
abstract type ProductGroup{T<:GroupTuple} <: Group end
24+
abstract type ProductGroup{T <: GroupTuple} <: Group end
2525

2626
"""
2727
×(G::Vararg{Type{<:Group}}) -> ProductGroup{Tuple{G...}}
@@ -34,20 +34,20 @@ const times = ×
3434

3535
×(a::Type{<:Group}, b::Type{<:Group}, c::Type{<:Group}...) = ×(×(a, b), c...)
3636
×(G::Type{<:Group}) = ProductGroup{Tuple{G}}
37-
×(G1::Type{ProductGroup{Tuple{}}},
38-
G2::Type{ProductGroup{T}}) where {T<:GroupTuple} = G2
39-
function ×(G1::Type{ProductGroup{T1}},
40-
G2::Type{ProductGroup{T2}}) where {T1<:GroupTuple,T2<:GroupTuple}
37+
×(G1::Type{ProductGroup{Tuple{}}}, G2::Type{ProductGroup{T}}) where {T <: GroupTuple} = G2
38+
function ×(
39+
G1::Type{ProductGroup{T1}}, G2::Type{ProductGroup{T2}}
40+
) where {T1 <: GroupTuple, T2 <: GroupTuple}
4141
return tuple_type_head(T1) × (ProductGroup{tuple_type_tail(T1)} × G2)
4242
end
4343
×(G1::Type{ProductGroup{Tuple{}}}, G2::Type{<:Group}) = ProductGroup{Tuple{G2}}
44-
function ×(G1::Type{ProductGroup{T}}, G2::Type{<:Group}) where {T<:GroupTuple}
44+
function ×(G1::Type{ProductGroup{T}}, G2::Type{<:Group}) where {T <: GroupTuple}
4545
return Base.tuple_type_head(T) × (ProductGroup{Base.tuple_type_tail(T)} × G2)
4646
end
47-
function ×(G1::Type{<:Group}, G2::Type{ProductGroup{T}}) where {T<:GroupTuple}
47+
function ×(G1::Type{<:Group}, G2::Type{ProductGroup{T}}) where {T <: GroupTuple}
4848
return ProductGroup{Base.tuple_type_cons(G1, T)}
4949
end
50-
×(G1::Type{<:Group}, G2::Type{<:Group}) = ProductGroup{Tuple{G1,G2}}
50+
×(G1::Type{<:Group}, G2::Type{<:Group}) = ProductGroup{Tuple{G1, G2}}
5151

5252
function type_repr(G::Type{<:ProductGroup})
5353
T = G.parameters[1]

0 commit comments

Comments
 (0)