Skip to content

Commit 20783f3

Browse files
committed
format yas style
1 parent f577315 commit 20783f3

29 files changed

+1294
-1056
lines changed

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "yas"

docs/make.jl

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
using Documenter
22
using TensorOperations
33

4-
makedocs(modules=[TensorOperations],
5-
sitename = "TensorOperations.jl",
6-
authors = "Jutho Haegeman",
7-
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"),
8-
pages = [
9-
"Home" => ["index.md",
10-
"indexnotation.md",
11-
"functions.md",
12-
"cache.md",
13-
"implementation.md"]
14-
])
4+
makedocs(; modules=[TensorOperations],
5+
sitename="TensorOperations.jl",
6+
authors="Jutho Haegeman",
7+
format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true"),
8+
pages=["Home" => ["index.md",
9+
"indexnotation.md",
10+
"functions.md",
11+
"cache.md",
12+
"implementation.md"]])
1513

1614
# Documenter can also automatically deploy documentation to gh-pages.
1715
# See "Hosting Documentation" and deploydocs() in the Documenter manual
1816
# for more information.
19-
deploydocs(repo = "github.com/Jutho/TensorOperations.jl.git")
17+
deploydocs(; repo="github.com/Jutho/TensorOperations.jl.git")

src/TensorOperations.jl

Lines changed: 118 additions & 113 deletions
Large diffs are not rendered by default.

src/functions/inplace.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
tensorcopy!(A, IA, C, IC) = tensorcopy!(A, tuple(IA...), C, tuple(IC...))
55
tensoradd!(α, A, IA, β, C, IC) = tensoradd!(α, A, tuple(IA...), β, C, tuple(IC...))
66
tensortrace!(α, A, IA, β, C, IC) = tensortrace!(α, A, tuple(IA...), β, C, tuple(IC...))
7-
tensorcontract!(α, A, IA, conjA, B, IB, conjB, β, C, IC) =
8-
tensorcontract!(α, A, tuple(IA...), conjA, B, tuple(IB...), conjB, β, C, tuple(IC...))
9-
tensorproduct!(α, A, IA, B, IB, β, C, IC) = tensorproduct!(α, A, tuple(IA...), B, tuple(IB...), β, C, tuple(IC...))
10-
7+
function tensorcontract!(α, A, IA, conjA, B, IB, conjB, β, C, IC)
8+
return tensorcontract!(α, A, tuple(IA...), conjA, B, tuple(IB...), conjB, β, C,
9+
tuple(IC...))
10+
end
11+
function tensorproduct!(α, A, IA, B, IB, β, C, IC)
12+
return tensorproduct!(α, A, tuple(IA...), B, tuple(IB...), β, C, tuple(IC...))
13+
end
1114

1215
"""
1316
tensorcopy!(A, IA, C, IC)
@@ -30,7 +33,7 @@ See also: [`tensorcopy`](@ref)
3033
"""
3134
function tensoradd!(α, A, IA::Tuple, β, C, IC::Tuple)
3235
indCinA = add_indices(IA, IC)
33-
add!(α, A, :N, β, C, indCinA)
36+
return add!(α, A, :N, β, C, indCinA)
3437
end
3538

3639
"""
@@ -60,9 +63,10 @@ or in the interaction of either `labelsA` or `labelsB` with `labelsC`, for indic
6063
in which the open indices should be match to the indices of the output array `C`.
6164
"""
6265
function tensorcontract!(α, A, IA::Tuple, conjA, B, IB::Tuple, conjB, β, C, IC::Tuple)
63-
64-
conjA == 'N' || conjA == 'C' || throw(ArgumentError("Value of conjA should be 'N' or 'C' instead of $conjA"))
65-
conjB == 'N' || conjB == 'C' || throw(ArgumentError("Value of conjB should be 'N' or 'C' instead of $conjB"))
66+
conjA == 'N' || conjA == 'C' ||
67+
throw(ArgumentError("Value of conjA should be 'N' or 'C' instead of $conjA"))
68+
conjB == 'N' || conjB == 'C' ||
69+
throw(ArgumentError("Value of conjB should be 'N' or 'C' instead of $conjB"))
6670
CA = conjA == 'N' ? :N : :C
6771
CB = conjB == 'N' ? :N : :C
6872

@@ -78,5 +82,5 @@ Replaces C with `β C + α A * B` without any indices being contracted.
7882
"""
7983
function tensorproduct!(α, A, IA::Tuple, B, IB::Tuple, β, C, IC::Tuple)
8084
isempty(intersect(IA, IB)) || throw(LabelError("not a valid tensor product"))
81-
tensorcontract!(α, A, IA, 'N', B, IB, 'N', β, C, IC)
85+
return tensorcontract!(α, A, IA, 'N', B, IB, 'N', β, C, IC)
8286
end

src/functions/ncon.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ over are labelled by increasing integers, i.e. first the contraction correspondi
2525
See also the macro version [`@ncon`](@ref).
2626
"""
2727
function ncon(tensors, network,
28-
conjlist = fill(false, length(tensors)), sym = nothing ;
29-
order = nothing, output = nothing)
28+
conjlist=fill(false, length(tensors)), sym=nothing;
29+
order=nothing, output=nothing)
3030
# length(tensors) >= 2 ||
3131
# throw(ArgumentError("do not use `ncon` for less than two tensors"))
3232
length(tensors) == length(network) == length(conjlist) ||
@@ -41,7 +41,7 @@ function ncon(tensors, network,
4141
end
4242
end
4343
if output === nothing
44-
output = sort(outputindices; rev = true)
44+
output = sort(outputindices; rev=true)
4545
else
4646
for a in output
4747
a in outputindices ||
@@ -59,7 +59,7 @@ function ncon(tensors, network,
5959
return tensortrace(tensors[1], network[1], output)
6060
end
6161
end
62-
(tensors,network) = resolve_traces(tensors,network);
62+
(tensors, network) = resolve_traces(tensors, network)
6363
tree = order === nothing ? ncontree(network) : indexordertree(network, order)
6464

6565
if sym !== nothing
@@ -82,7 +82,7 @@ function ncon(tensors, network,
8282
symcontract = nothing
8383
end
8484
contract!(true, A, CA, B, CB, false, C,
85-
oindA, cindA, oindB, cindB, indCinoAB, (), symcontract)
85+
oindA, cindA, oindB, cindB, indCinoAB, (), symcontract)
8686
return C
8787
end
8888

@@ -116,6 +116,6 @@ function contracttree(tensors, network, conjlist, tree, sym)
116116
symcontract = nothing
117117
end
118118
contract!(true, A, CA, B, CB, false, C,
119-
oindA, cindA, oindB, cindB, indCinoAB, (), symcontract)
119+
oindA, cindA, oindB, cindB, indCinoAB, (), symcontract)
120120
return C, IC, :N
121121
end

src/functions/simple.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
# type unstable; better use tuples instead
66
tensorcopy(A, IA, IC=IA) = tensorcopy(A, tuple(IA...), tuple(IC...))
77
tensoradd(A, IA, B, IB, IC=IA) = tensoradd(A, tuple(IA...), B, tuple(IB...), tuple(IC...))
8-
tensortrace(A, IA, IC = unique2(IA)) = tensortrace(A, tuple(IA...), tuple(IC...))
9-
tensorcontract(A, IA, B, IB, IC = symdiff(IA, IB)) =
10-
tensorcontract(A, tuple(IA...), B, tuple(IB...), tuple(IC...))
11-
tensorproduct(A, IA, B, IB, IC = vcat(IA, IB)) = tensorproduct(A, tuple(IA...), B, tuple(IB...), tuple(IC...))
8+
tensortrace(A, IA, IC=unique2(IA)) = tensortrace(A, tuple(IA...), tuple(IC...))
9+
function tensorcontract(A, IA, B, IB, IC=symdiff(IA, IB))
10+
return tensorcontract(A, tuple(IA...), B, tuple(IB...), tuple(IC...))
11+
end
12+
function tensorproduct(A, IA, B, IB, IC=vcat(IA, IB))
13+
return tensorproduct(A, tuple(IA...), B, tuple(IB...), tuple(IC...))
14+
end
1215

1316
"""
1417
tensorcopy(A, IA, IC = IA)
@@ -106,7 +109,7 @@ this is a special case of `tensorcontract` with no indices being contracted over
106109
This method checks whether the indices indeed specify a tensor product instead of
107110
a genuine contraction.
108111
"""
109-
function tensorproduct(A, IA::Tuple, B, IB::Tuple, IC::Tuple = (IA..., IB...))
112+
function tensorproduct(A, IA::Tuple, B, IB::Tuple, IC::Tuple=(IA..., IB...))
110113
isempty(intersect(IA, IB)) || throw(IndexError("not a valid tensor product"))
111-
tensorcontract(A, IA, B, IB, IC)
114+
return tensorcontract(A, IA, B, IB, IC)
112115
end

0 commit comments

Comments
 (0)