diff --git a/src/boundarymps.jl b/src/boundarymps.jl index b37f4249..16a4a204 100644 --- a/src/boundarymps.jl +++ b/src/boundarymps.jl @@ -6,7 +6,7 @@ function contract_boundary_mps(tn::ITensorNetwork; kwargs...) dims = maximum(vertices(tn)) d1, d2 = dims vL = ITensorMPS.MPS([tn[i1, 1] for i1 in 1:d1]) - for i2 in 2:(d2 - 2) + for i2 in 2:(d2-2) T = ITensorMPS.MPO([tn[i1, i2] for i1 in 1:d1]) vL = contract(T, vL; kwargs...) end diff --git a/src/contract_approx/mincut.jl b/src/contract_approx/mincut.jl index 6c772894..86e1025d 100644 --- a/src/contract_approx/mincut.jl +++ b/src/contract_approx/mincut.jl @@ -99,9 +99,9 @@ function _distance(tn::ITensorNetwork, outinds::Vector) new_tensors = [ITensor(i) for i in outinds] tn = disjoint_union(ITensorNetwork(new_tensors), tn) distances = 0.0 - for i in 1:(length(new_tensors) - 1) + for i in 1:(length(new_tensors)-1) ds = dijkstra_shortest_paths(tn, [(i, 1)], weights(tn)) - for j in (i + 1):length(new_tensors) + for j in (i+1):length(new_tensors) distances += ds.dists[(j, 1)] end end diff --git a/src/graphs.jl b/src/graphs.jl index bce2c90d..6bd324c8 100644 --- a/src/graphs.jl +++ b/src/graphs.jl @@ -4,7 +4,7 @@ using ITensors: ITensor, hascommoninds function SimpleGraphs.SimpleGraph(itensors::Vector{ITensor}) nv_graph = length(itensors) graph = SimpleGraph(nv_graph) - for i in 1:(nv_graph - 1), j in (i + 1):nv_graph + for i in 1:(nv_graph-1), j in (i+1):nv_graph if hascommoninds(itensors[i], itensors[j]) add_edge!(graph, i => j) end diff --git a/src/indsnetwork.jl b/src/indsnetwork.jl index befc5cdc..ea36ab95 100644 --- a/src/indsnetwork.jl +++ b/src/indsnetwork.jl @@ -65,7 +65,7 @@ end return IndsNetwork{V,I}(g, link_space, site_space) end -@traitfn function IndsNetwork(g::G, link_space, site_space) where {G; IsUnderlyingGraph{G}} +@traitfn function IndsNetwork(g::G, link_space, site_space) where {G;IsUnderlyingGraph{G}} V = vertextype(g) return IndsNetwork{V}(g, link_space, site_space) end @@ -133,7 +133,7 @@ end return IndsNetwork{V}(g, link_space, site_space) end -@traitfn function IndsNetwork(g::G; kwargs...) where {G; IsUnderlyingGraph{G}} +@traitfn function IndsNetwork(g::G; kwargs...) where {G;IsUnderlyingGraph{G}} return IndsNetwork{vertextype(g)}(g; kwargs...) end diff --git a/src/lib/ITensorsExtensions/src/opsum.jl b/src/lib/ITensorsExtensions/src/opsum.jl index 783ed4fb..a6afb1ee 100644 --- a/src/lib/ITensorsExtensions/src/opsum.jl +++ b/src/lib/ITensorsExtensions/src/opsum.jl @@ -32,7 +32,7 @@ end function group_terms(ℋ::Sum, g) grouped_terms = group(ITensors.terms(ℋ)) do t findfirst(edges(g)) do e - to_tuple.(ITensors.sites(t)) ⊆ [src(e), dst(e)] + return to_tuple.(ITensors.sites(t)) ⊆ [src(e), dst(e)] end end return Sum(collect(sum.(grouped_terms))) diff --git a/src/solvers/sweep_plans/sweep_plans.jl b/src/solvers/sweep_plans/sweep_plans.jl index 69221995..0cc897d6 100644 --- a/src/solvers/sweep_plans/sweep_plans.jl +++ b/src/solvers/sweep_plans/sweep_plans.jl @@ -108,19 +108,19 @@ function default_sweep_plans( transform_operator_kwargs, kwargs..., ) - extracter, updater, inserter, transform_operator = - extend_or_truncate.((extracter, updater, inserter, transform_operator), nsweeps) - inserter_kwargs, updater_kwargs, extracter_kwargs, transform_operator_kwargs, kwargs = - expand.( - ( - inserter_kwargs, - updater_kwargs, - extracter_kwargs, - transform_operator_kwargs, - NamedTuple(kwargs), - ), - nsweeps, - ) + extracter, updater, inserter, transform_operator = extend_or_truncate.( + (extracter, updater, inserter, transform_operator), nsweeps + ) + inserter_kwargs, updater_kwargs, extracter_kwargs, transform_operator_kwargs, kwargs = expand.( + ( + inserter_kwargs, + updater_kwargs, + extracter_kwargs, + transform_operator_kwargs, + NamedTuple(kwargs), + ), + nsweeps, + ) sweep_plans = [] for i in 1:nsweeps sweep_plan = sweep_plan_func( @@ -187,7 +187,7 @@ function tdvp_sweep_plan( region_kwargs..., ), reverse_kwargs=(; - internal_kwargs=(; substep, time_step=-sub_time_step, t=t_evolved), + internal_kwargs=(; substep, time_step=(-sub_time_step), t=t_evolved), region_kwargs..., ), reverse_step, diff --git a/src/treetensornetworks/opsum_to_ttn/opsum_to_ttn.jl b/src/treetensornetworks/opsum_to_ttn/opsum_to_ttn.jl index 09098b68..042df8c8 100644 --- a/src/treetensornetworks/opsum_to_ttn/opsum_to_ttn.jl +++ b/src/treetensornetworks/opsum_to_ttn/opsum_to_ttn.jl @@ -289,7 +289,7 @@ function compress_ttn( H = ttn(sites0) # initialize TTN without the dummy indices added function qnblock(i::Index, q::QN) - for b in 2:(nblocks(i) - 1) + for b in 2:(nblocks(i)-1) flux(i, Block(b)) == q && return b end return error("Could not find block of QNIndex with matching QN") diff --git a/src/treetensornetworks/projttns/projttnsum.jl b/src/treetensornetworks/projttns/projttnsum.jl index 42ae6a05..553ac933 100644 --- a/src/treetensornetworks/projttns/projttnsum.jl +++ b/src/treetensornetworks/projttns/projttnsum.jl @@ -48,14 +48,14 @@ ITensors.product(P::ProjTTNSum, v::ITensor) = noprime(contract(P, v)) function ITensors.contract(P::ProjTTNSum, v::ITensor) res = mapreduce(+, zip(factors(P), terms(P))) do (f, p) - f * contract(p, v) + return f * contract(p, v) end return res end function contract_ket(P::ProjTTNSum, v::ITensor) res = mapreduce(+, zip(factors(P), terms(P))) do (f, p) - f * contract_ket(p, v) + return f * contract_ket(p, v) end return res end diff --git a/test/test_treetensornetworks/test_solvers/test_contract.jl b/test/test_treetensornetworks/test_solvers/test_contract.jl index 8255eaec..d073c7c7 100644 --- a/test/test_treetensornetworks/test_solvers/test_contract.jl +++ b/test/test_treetensornetworks/test_solvers/test_contract.jl @@ -29,12 +29,12 @@ using Test: @test, @test_broken, @testset rng = StableRNG(1234) psi = random_mps(rng, s; link_space=8) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 end - for j in 1:(N - 2) + for j in 1:(N-2) os += 0.5, "S+", j, "S-", j + 2 os += 0.5, "S-", j, "S+", j + 2 os += "Sz", j, "Sz", j + 2 diff --git a/test/test_treetensornetworks/test_solvers/test_dmrg.jl b/test/test_treetensornetworks/test_solvers/test_dmrg.jl index cf8a1caf..ada81f65 100644 --- a/test/test_treetensornetworks/test_solvers/test_dmrg.jl +++ b/test/test_treetensornetworks/test_solvers/test_dmrg.jl @@ -37,7 +37,7 @@ ITensors.disable_auto_fermion() s = siteinds("S=1/2", N) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 @@ -109,7 +109,7 @@ end cutoff = 1e-12 s = siteinds("S=1/2", N) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 @@ -147,7 +147,7 @@ end cutoff = 1e-12 s = siteinds("S=1/2", N) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 @@ -178,7 +178,7 @@ end s = siteinds("S=1/2", N) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 diff --git a/test/test_treetensornetworks/test_solvers/test_linsolve.jl b/test/test_treetensornetworks/test_solvers/test_linsolve.jl index dab969ed..ef5edc27 100644 --- a/test/test_treetensornetworks/test_solvers/test_linsolve.jl +++ b/test/test_treetensornetworks/test_solvers/test_linsolve.jl @@ -15,7 +15,7 @@ using Test: @test, @test_broken, @testset s = siteinds("S=1/2", N; conserve_qns=false) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 diff --git a/test/test_treetensornetworks/test_solvers/test_tdvp.jl b/test/test_treetensornetworks/test_solvers/test_tdvp.jl index 82dc7d38..4bdf61fb 100644 --- a/test/test_treetensornetworks/test_solvers/test_tdvp.jl +++ b/test/test_treetensornetworks/test_solvers/test_tdvp.jl @@ -27,7 +27,7 @@ using Test: @testset, @test s = siteinds("S=1/2", N) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 @@ -84,12 +84,12 @@ using Test: @testset, @test s = siteinds("S=1/2", N) os1 = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os1 += 0.5, "S+", j, "S-", j + 1 os1 += 0.5, "S-", j, "S+", j + 1 end os2 = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os2 += "Sz", j, "Sz", j + 1 end @@ -127,7 +127,7 @@ using Test: @testset, @test s = siteinds("S=1/2", N) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 @@ -164,7 +164,7 @@ using Test: @testset, @test s = siteinds("S=1/2", N; conserve_qns=false) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 @@ -232,7 +232,7 @@ using Test: @testset, @test s = siteinds("S=1/2", N; conserve_qns=true) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 @@ -241,7 +241,7 @@ using Test: @testset, @test H = mpo(os, s) gates = ITensor[] - for j in 1:(N - 1) + for j in 1:(N-1) s1 = s[j] s2 = s[j + 1] hj = @@ -324,7 +324,7 @@ using Test: @testset, @test s = siteinds("S=1/2", N) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1 @@ -341,7 +341,7 @@ using Test: @testset, @test H, -ttotal, state; - time_step=-tau, + time_step=(-tau), maxdim, cutoff, nsites, @@ -362,7 +362,7 @@ using Test: @testset, @test s = siteinds("S=1/2", N; conserve_qns=true) os = OpSum() - for j in 1:(N - 1) + for j in 1:(N-1) os += 0.5, "S+", j, "S-", j + 1 os += 0.5, "S-", j, "S+", j + 1 os += "Sz", j, "Sz", j + 1