From edfc36c783b4963d131945c39dac1107c41b465d Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Sun, 15 Jun 2025 12:14:34 -0400 Subject: [PATCH 1/4] Update formatter action --- .github/workflows/FormatCheck.yml | 32 ++++++++----------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index 34b40bf3f..e998dd5db 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -1,32 +1,16 @@ -name: FormatCheck +name: "Format Check" on: push: branches: + - 'main' - 'master' tags: '*' pull_request: - branches: - - 'master' -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - version: - - '1' # automatically expands to the latest stable 1.x release of Julia - os: - - ubuntu-latest - arch: - - x64 - steps: - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - uses: actions/checkout@v4 - - name: Install JuliaFormatter and format - run: | - julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' - julia -e 'using JuliaFormatter; format(".", verbose=true)' +jobs: + format-check: + name: "Format Check" + uses: "QuantumKitHub/.github/.github/workflows/formatcheck.yml@main" + with: + juliaformatter-version: "2" From 8133147b5b7336d356e447e21b03de5a692973b6 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Sun, 15 Jun 2025 12:18:42 -0400 Subject: [PATCH 2/4] Formatting changes --- examples/classic2d/1.hard-hexagon/main.jl | 12 +++++----- examples/quantum1d/7.xy-finiteT/main.jl | 4 ++-- src/algorithms/approximate/fvomps.jl | 2 +- src/algorithms/changebonds/optimalexpand.jl | 6 ++--- src/algorithms/changebonds/randexpand.jl | 4 ++-- src/algorithms/changebonds/svdcut.jl | 8 +++---- src/algorithms/excitation/chepigaansatz.jl | 2 +- src/algorithms/groundstate/dmrg.jl | 4 ++-- .../groundstate/gradient_grassmann.jl | 2 +- src/algorithms/groundstate/idmrg.jl | 8 +++---- src/algorithms/toolbox.jl | 2 +- src/environments/qp_envs.jl | 4 ++-- src/states/infinitemps.jl | 10 ++++----- src/states/quasiparticle_state.jl | 4 ++-- src/states/windowmps.jl | 2 +- test/algorithms.jl | 8 ++++--- test/setup.jl | 22 ++++++++++++------- 17 files changed, 56 insertions(+), 48 deletions(-) diff --git a/examples/classic2d/1.hard-hexagon/main.jl b/examples/classic2d/1.hard-hexagon/main.jl index bc8466947..fe2d8b88c 100644 --- a/examples/classic2d/1.hard-hexagon/main.jl +++ b/examples/classic2d/1.hard-hexagon/main.jl @@ -39,10 +39,10 @@ Additionally, we can compute the entanglement entropy as well as the correlation D = 10 V = virtual_space(D) ψ₀ = InfiniteMPS([P], [V]) -ψ, envs, = leading_boundary(ψ₀, mpo, - VUMPS(; verbosity=0, - alg_eigsolve=MPSKit.Defaults.alg_eigsolve(; - ishermitian=false))) # use non-hermitian eigensolver +ψ, envs = leading_boundary(ψ₀, mpo, + VUMPS(; verbosity=0, + alg_eigsolve=MPSKit.Defaults.alg_eigsolve(; + ishermitian=false))) # use non-hermitian eigensolver F = real(expectation_value(ψ, mpo)) S = real(first(entropy(ψ))) ξ = correlation_length(ψ) @@ -63,13 +63,13 @@ function scaling_simulations(ψ₀, mpo, Ds; verbosity=0, tol=1e-6, correlations = similar(Ds, Float64) alg = VUMPS(; verbosity, tol, alg_eigsolve) - ψ, envs, = leading_boundary(ψ₀, mpo, alg) + ψ, envs = leading_boundary(ψ₀, mpo, alg) entropies[1] = real(entropy(ψ)[1]) correlations[1] = correlation_length(ψ) for (i, d) in enumerate(diff(Ds)) ψ, envs = changebonds(ψ, mpo, OptimalExpand(; trscheme=truncdim(d)), envs) - ψ, envs, = leading_boundary(ψ, mpo, alg, envs) + ψ, envs = leading_boundary(ψ, mpo, alg, envs) entropies[i + 1] = real(entropy(ψ)[1]) correlations[i + 1] = correlation_length(ψ) end diff --git a/examples/quantum1d/7.xy-finiteT/main.jl b/examples/quantum1d/7.xy-finiteT/main.jl index 349cfcb22..405f5e82a 100644 --- a/examples/quantum1d/7.xy-finiteT/main.jl +++ b/examples/quantum1d/7.xy-finiteT/main.jl @@ -29,7 +29,7 @@ J = 1 / 2 T = ComplexF64 symmetry = U1Irrep -function XY_hamiltonian(::Type{T}=ComplexF64, ::Type{S}=Trivial; J=1 / 2, +function XY_hamiltonian((::Type{T})=ComplexF64, (::Type{S})=Trivial; J=1 / 2, N) where {T<:Number,S<:Sector} spin = 1 // 2 term = J * (S_xx(T, S; spin) + S_yy(T, S; spin)) @@ -90,7 +90,7 @@ D = 64 V_init = symmetry === Trivial ? ℂ^32 : U1Space(i => 10 for i in -1:(1 // 2):1) psi_init = FiniteMPS(N, physicalspace(H, 1), V_init) trscheme = truncdim(D) -psi, envs, = find_groundstate(psi_init, H, DMRG2(; trscheme, maxiter=5)); +psi, envs = find_groundstate(psi_init, H, DMRG2(; trscheme, maxiter=5)); E_0 = expectation_value(psi, H, envs) / N println("Numerical:\t", real(E_0)) diff --git a/src/algorithms/approximate/fvomps.jl b/src/algorithms/approximate/fvomps.jl index f9db19dbc..8fed206c2 100644 --- a/src/algorithms/approximate/fvomps.jl +++ b/src/algorithms/approximate/fvomps.jl @@ -9,7 +9,7 @@ function approximate!(ψ::AbstractFiniteMPS, Oϕ, alg::DMRG2, ϵ = 0.0 for pos in [1:(length(ψ) - 1); (length(ψ) - 2):-1:1] AC2′ = AC2_projection(pos, ψ, Oϕ, envs) - al, c, ar, = tsvd!(AC2′; trunc=alg.trscheme) + al, c, ar = tsvd!(AC2′; trunc=alg.trscheme) AC2 = ψ.AC[pos] * _transpose_tail(ψ.AR[pos + 1]) ϵ = max(ϵ, norm(al * c * ar - AC2) / norm(AC2)) diff --git a/src/algorithms/changebonds/optimalexpand.jl b/src/algorithms/changebonds/optimalexpand.jl index 98f33f212..722b70ac3 100644 --- a/src/algorithms/changebonds/optimalexpand.jl +++ b/src/algorithms/changebonds/optimalexpand.jl @@ -31,7 +31,7 @@ function changebonds(ψ::InfiniteMPS, H::InfiniteMPOHamiltonian, alg::OptimalExp VL = leftnull(ψ.AL[i]) VR = rightnull!(_transpose_tail(ψ.AR[i + 1])) intermediate = normalize!(adjoint(VL) * AC2 * adjoint(VR)) - U, _, V, = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) + U, _, V = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) AL′[i] = VL * U AR′[i + 1] = V * VR @@ -57,7 +57,7 @@ function changebonds(ψ::MultilineMPS, H, alg::OptimalExpand, envs=environments( VL = leftnull(ψ.AL[i, j]) VR = rightnull!(_transpose_tail(ψ.AR[i, j + 1])) intermediate = normalize!(adjoint(VL) * AC2 * adjoint(VR)) - U, _, V, = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) + U, _, V = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) AL′[i, j] = VL * U AR′[i, j + 1] = V * VR @@ -88,7 +88,7 @@ function changebonds!(ψ::AbstractFiniteMPS, H, alg::OptimalExpand, envs=environ #Use this nullspaces and SVD decomposition to determine the optimal expansion space intermediate = normalize!(adjoint(NL) * AC2 * adjoint(NR)) - _, _, V, = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) + _, _, V = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) ar_re = V * NR ar_le = zerovector!(similar(ar_re, codomain(ψ.AC[i]) ← space(V, 1))) diff --git a/src/algorithms/changebonds/randexpand.jl b/src/algorithms/changebonds/randexpand.jl index f54c88134..fa2bb1223 100644 --- a/src/algorithms/changebonds/randexpand.jl +++ b/src/algorithms/changebonds/randexpand.jl @@ -29,7 +29,7 @@ function changebonds(ψ::InfiniteMPS, alg::RandExpand) VL = leftnull(ψ.AL[i]) VR = rightnull!(_transpose_tail(ψ.AR[i + 1])) intermediate = normalize!(adjoint(VL) * AC2 * adjoint(VR)) - U, _, V, = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) + U, _, V = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) AL′[i] = VL * U AR′[i + 1] = V * VR @@ -53,7 +53,7 @@ function changebonds!(ψ::AbstractFiniteMPS, alg::RandExpand) #Use this nullspaces and SVD decomposition to determine the optimal expansion space intermediate = normalize!(adjoint(NL) * AC2 * adjoint(NR)) - _, _, V, = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) + _, _, V = tsvd!(intermediate; trunc=alg.trscheme, alg=alg.alg_svd) ar_re = V * NR ar_le = zerovector!(similar(ar_re, codomain(ψ.AC[i]) ← space(V, 1))) diff --git a/src/algorithms/changebonds/svdcut.jl b/src/algorithms/changebonds/svdcut.jl index 85497a2ea..142591921 100644 --- a/src/algorithms/changebonds/svdcut.jl +++ b/src/algorithms/changebonds/svdcut.jl @@ -20,7 +20,7 @@ function changebonds(ψ::AbstractFiniteMPS, alg::SvdCut; kwargs...) end function changebonds!(ψ::AbstractFiniteMPS, alg::SvdCut; normalize::Bool=true) for i in (length(ψ) - 1):-1:1 - U, S, V, = tsvd(ψ.C[i]; trunc=alg.trscheme, alg=alg.alg_svd) + U, S, V = tsvd(ψ.C[i]; trunc=alg.trscheme, alg=alg.alg_svd) AL′ = ψ.AL[i] * U ψ.AC[i] = (AL′, complex(S)) AR′ = _transpose_front(V * _transpose_tail(ψ.AR[i + 1])) @@ -44,7 +44,7 @@ function changebonds!(mpo::FiniteMPO, alg::SvdCut) O_left = transpose(mpo[1], ((3, 1, 2), (4,))) local O_right for i in 2:length(mpo) - U, S, V, = tsvd!(O_left; trunc=alg.trscheme, alg=alg.alg_svd) + U, S, V = tsvd!(O_left; trunc=alg.trscheme, alg=alg.alg_svd) @inbounds mpo[i - 1] = transpose(U, ((2, 3), (1, 4))) if i < length(mpo) @plansor O_left[-3 -1 -2; -4] := S[-1; 1] * V[1; 2] * mpo[i][2 -2; -3 -4] @@ -55,7 +55,7 @@ function changebonds!(mpo::FiniteMPO, alg::SvdCut) # right to left for i in (length(mpo) - 1):-1:1 - U, S, V, = tsvd!(O_right; trunc=alg.trscheme, alg=alg.alg_svd) + U, S, V = tsvd!(O_right; trunc=alg.trscheme, alg=alg.alg_svd) @inbounds mpo[i + 1] = transpose(V, ((1, 4), (2, 3))) if i > 1 @plansor O_right[-1; -3 -4 -2] := mpo[i][-1 -2; -3 2] * U[2; 1] * S[1; -4] @@ -84,7 +84,7 @@ function changebonds(ψ::InfiniteMPS, alg::SvdCut) ncr = ψ.C[1] for i in 1:length(ψ) - U, ncr, = tsvd(ψ.C[i]; trunc=alg.trscheme, alg=alg.alg_svd) + U, ncr = tsvd(ψ.C[i]; trunc=alg.trscheme, alg=alg.alg_svd) copied[i] = copied[i] * U copied[i + 1] = _transpose_front(U' * _transpose_tail(copied[i + 1])) end diff --git a/src/algorithms/excitation/chepigaansatz.jl b/src/algorithms/excitation/chepigaansatz.jl index ea908de19..e4f9db246 100644 --- a/src/algorithms/excitation/chepigaansatz.jl +++ b/src/algorithms/excitation/chepigaansatz.jl @@ -117,7 +117,7 @@ function excitations(H, alg::ChepigaAnsatz2, ψ::FiniteMPS, envs=environments(ψ # map back to finitemps ψs = map(AC2s) do ac ψ′ = copy(ψ) - AL, C, AR, = tsvd!(ac; trunc=alg.trscheme) + AL, C, AR = tsvd!(ac; trunc=alg.trscheme) normalize!(C) ψ′.AC[pos] = (AL, complex(C)) ψ′.AC[pos + 1] = (complex(C), _transpose_front(AR)) diff --git a/src/algorithms/groundstate/dmrg.jl b/src/algorithms/groundstate/dmrg.jl index 27164c133..1815babb8 100644 --- a/src/algorithms/groundstate/dmrg.jl +++ b/src/algorithms/groundstate/dmrg.jl @@ -121,7 +121,7 @@ function find_groundstate!(ψ::AbstractFiniteMPS, H, alg::DMRG2, envs=environmen Hac2 = AC2_hamiltonian(pos, ψ, H, ψ, envs) _, newA2center = fixedpoint(Hac2, ac2, :SR, alg_eigsolve) - al, c, ar, = tsvd!(newA2center; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(newA2center; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) v = @plansor ac2[1 2; 3 4] * conj(al[1 2; 5]) * conj(c[5; 6]) * conj(ar[6; 3 4]) @@ -137,7 +137,7 @@ function find_groundstate!(ψ::AbstractFiniteMPS, H, alg::DMRG2, envs=environmen Hac2 = AC2_hamiltonian(pos, ψ, H, ψ, envs) _, newA2center = fixedpoint(Hac2, ac2, :SR, alg_eigsolve) - al, c, ar, = tsvd!(newA2center; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(newA2center; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) v = @plansor ac2[1 2; 3 4] * conj(al[1 2; 5]) * conj(c[5; 6]) * conj(ar[6; 3 4]) diff --git a/src/algorithms/groundstate/gradient_grassmann.jl b/src/algorithms/groundstate/gradient_grassmann.jl index 0e44c86a1..16a1f86ca 100644 --- a/src/algorithms/groundstate/gradient_grassmann.jl +++ b/src/algorithms/groundstate/gradient_grassmann.jl @@ -34,7 +34,7 @@ struct GradientGrassmann{O<:OptimKit.OptimizationAlgorithm,F} <: Algorithm function GradientGrassmann(; method=ConjugateGradient, (finalize!)=OptimKit._finalize!, tol=Defaults.tol, maxiter=Defaults.maxiter, - verbosity=Defaults.verbosity - 1) + verbosity=(Defaults.verbosity - 1)) if isa(method, OptimKit.OptimizationAlgorithm) # We were given an optimisation method, just use it. m = method diff --git a/src/algorithms/groundstate/idmrg.jl b/src/algorithms/groundstate/idmrg.jl index 0d0fd1843..a7910c974 100644 --- a/src/algorithms/groundstate/idmrg.jl +++ b/src/algorithms/groundstate/idmrg.jl @@ -133,7 +133,7 @@ function find_groundstate(ost::InfiniteMPS, H, alg::IDMRG2, envs=environments(os h_ac2 = AC2_hamiltonian(pos, ψ, H, ψ, envs) _, ac2′ = fixedpoint(h_ac2, ac2, :SR, alg_eigsolve) - al, c, ar, = tsvd!(ac2′; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(ac2′; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[pos] = al @@ -152,7 +152,7 @@ function find_groundstate(ost::InfiniteMPS, H, alg::IDMRG2, envs=environments(os h_ac2 = AC2_hamiltonian(0, ψ, H, ψ, envs) _, ac2′ = fixedpoint(h_ac2, ac2, :SR, alg_eigsolve) - al, c, ar, = tsvd!(ac2′; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(ac2′; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[end] = al @@ -175,7 +175,7 @@ function find_groundstate(ost::InfiniteMPS, H, alg::IDMRG2, envs=environments(os h_ac2 = AC2_hamiltonian(pos, ψ, H, ψ, envs) _, ac2′ = fixedpoint(h_ac2, ac2, :SR, alg_eigsolve) - al, c, ar, = tsvd!(ac2′; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(ac2′; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[pos] = al @@ -194,7 +194,7 @@ function find_groundstate(ost::InfiniteMPS, H, alg::IDMRG2, envs=environments(os ac2 = AC2(ψ, 0; kind=:ACAR) h_ac2 = AC2_hamiltonian(0, ψ, H, ψ, envs) _, ac2′ = fixedpoint(h_ac2, ac2, :SR, alg_eigsolve) - al, c, ar, = tsvd!(ac2′; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(ac2′; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[end] = al diff --git a/src/algorithms/toolbox.jl b/src/algorithms/toolbox.jl index 66fc44122..08fea07c7 100644 --- a/src/algorithms/toolbox.jl +++ b/src/algorithms/toolbox.jl @@ -119,7 +119,7 @@ Find the closest fractions of π, differing at most ```tol_angle``` """ function approx_angles(spectrum; tol_angle=0.1) angles = angle.(spectrum) ./ π # ∈ ]-1, 1] - angles_approx = rationalize.(angles, tol=tol_angle) # ∈ [-1, 1] + angles_approx = rationalize.(angles; tol=tol_angle) # ∈ [-1, 1] # Remove the effects of the branchcut. angles_approx[findall(angles_approx .== -1)] .= 1 # ∈ ]-1, 1] diff --git a/src/environments/qp_envs.jl b/src/environments/qp_envs.jl index 3e06d7c67..273d1f030 100644 --- a/src/environments/qp_envs.jl +++ b/src/environments/qp_envs.jl @@ -100,10 +100,10 @@ function environments(exci::InfiniteQP, H::InfiniteMPOHamiltonian, @sync begin Threads.@spawn $lBs[1] = left_excitation_transfer_system($lBs[1], $H, $exci; - solver=$solver) + solver=($solver)) Threads.@spawn $rBs[end] = right_excitation_transfer_system($rBs[end], $H, $exci; - solver=$solver) + solver=($solver)) end lB_cur = lBs[1] diff --git a/src/states/infinitemps.jl b/src/states/infinitemps.jl index af3820384..3594c7b8f 100644 --- a/src/states/infinitemps.jl +++ b/src/states/infinitemps.jl @@ -89,11 +89,11 @@ struct InfiniteMPS{A<:GenericMPSTensor,B<:MPSBondTensor} <: AbstractMPS # verify that the virtual spaces are compatible space(AL[i], 1) == dual(space(AL[i - 1], N)) && - space(AR[i], 1) == dual(space(AR[i - 1], N)) && - space(AC[i], 1) == space(AL[i], 1) && - space(AC[i], N) == space(AR[i], N) && - space(C[i], 1) == dual(space(AL[i], N)) && - space(AR[i], 1) == dual(space(C[i - 1], 2)) || + space(AR[i], 1) == dual(space(AR[i - 1], N)) && + space(AC[i], 1) == space(AL[i], 1) && + space(AC[i], N) == space(AR[i], N) && + space(C[i], 1) == dual(space(AL[i], N)) && + space(AR[i], 1) == dual(space(C[i - 1], 2)) || throw(SpaceMismatch("incompatible virtual spaces at site $i")) # verify that the spaces are non-zero dim(space(AL[i])) > 0 && dim(space(C[i])) > 0 || diff --git a/src/states/quasiparticle_state.jl b/src/states/quasiparticle_state.jl index ed1b81d9e..ae6a99ca6 100644 --- a/src/states/quasiparticle_state.jl +++ b/src/states/quasiparticle_state.jl @@ -80,10 +80,10 @@ function RightGaugedQP(datfun, left_gs, right_gs=left_gs; end #gauge dependent code -function Base.similar(v::LeftGaugedQP, ::Type{T}=scalartype(v)) where {T<:Number} +function Base.similar(v::LeftGaugedQP, (::Type{T})=scalartype(v)) where {T<:Number} return LeftGaugedQP(v.left_gs, v.right_gs, v.VLs, similar.(v.Xs, T), v.momentum) end -function Base.similar(v::RightGaugedQP, ::Type{T}=scalartype(v)) where {T<:Number} +function Base.similar(v::RightGaugedQP, (::Type{T})=scalartype(v)) where {T<:Number} return RightGaugedQP(v.left_gs, v.right_gs, similar.(v.Xs, T), v.VRs, v.momentum) end diff --git a/src/states/windowmps.jl b/src/states/windowmps.jl index 147b1d295..22bf3d191 100644 --- a/src/states/windowmps.jl +++ b/src/states/windowmps.jl @@ -44,7 +44,7 @@ struct WindowMPS{A<:GenericMPSTensor,B<:MPSBondTensor} <: AbstractFiniteMPS ψᵣ::InfiniteMPS{A,B}=copy(ψₗ)) where {A<:GenericMPSTensor, B<:MPSBondTensor} left_virtualspace(ψₗ, 1) == left_virtualspace(ψₘ, 1) && - right_virtualspace(ψₘ, length(ψₘ)) == right_virtualspace(ψᵣ, length(ψₘ)) || + right_virtualspace(ψₘ, length(ψₘ)) == right_virtualspace(ψᵣ, length(ψₘ)) || throw(SpaceMismatch("Mismatch between window and environment virtual spaces")) return new{A,B}(ψₗ, ψₘ, ψᵣ) end diff --git a/test/algorithms.jl b/test/algorithms.jl index 4a10af9d3..f7379c6c0 100644 --- a/test/algorithms.jl +++ b/test/algorithms.jl @@ -351,6 +351,7 @@ end @testset "Finite TimeDependent LazySum $(alg isa TDVP ? "TDVP" : "TDVP2")" for alg in algs + ψ, envs = timestep(ψ₀, Ht(1.0), 0.0, dt, alg) E = expectation_value(ψ, Ht(1.0), envs) @@ -363,6 +364,7 @@ end MultipliedOperator(H, 1.45) @testset "Finite TimeDependent LazySum (fix negative t issue) $(alg isa TDVP ? "TDVP" : "TDVP2")" for alg in algs + ψ, envs = timestep(ψ₀, Ht2, 0.0, dt, alg) E = expectation_value(ψ, Ht2(0.0), envs) @@ -489,7 +491,7 @@ end fin_en = map([20, 10]) do len H = force_planar(transverse_field_ising(; L=len)) ψ = FiniteMPS(rand, ComplexF64, len, ℙ^2, ℙ^10) - ψ, envs, = find_groundstate(ψ, H; verbosity) + ψ, envs = find_groundstate(ψ, H; verbosity) # find energy with quasiparticle ansatz energies_QP, ϕs = @inferred excitations(H, QuasiparticleAnsatz(), ψ, envs) @@ -658,7 +660,7 @@ end for λ in [1.05, 2.0, 4.0] H = hamiltonian(λ) ψ = InfiniteMPS([ℂ^2], [ℂ^16]) - ψ, envs, = find_groundstate(ψ, H, VUMPS(; maxiter=100, verbosity=0)) + ψ, envs = find_groundstate(ψ, H, VUMPS(; maxiter=100, verbosity=0)) numerical_susceptibility = fidelity_susceptibility(ψ, H, [H_X], envs; maxiter=10) @test numerical_susceptibility[1, 1] ≈ analytical_susceptibility(λ) atol = 1e-2 @@ -668,7 +670,7 @@ end Hfin = open_boundary_conditions(hamiltonian(λ), L) H_Xfin = open_boundary_conditions(H_X, L) ψ = FiniteMPS(rand, ComplexF64, L, ℂ^2, ℂ^16) - ψ, envs, = find_groundstate(ψ, Hfin, DMRG(; verbosity=0)) + ψ, envs = find_groundstate(ψ, Hfin, DMRG(; verbosity=0)) numerical_susceptibility = fidelity_susceptibility(ψ, Hfin, [H_Xfin], envs; maxiter=10) return numerical_susceptibility[1, 1] / L diff --git a/test/setup.jl b/test/setup.jl index 4689a2aff..6e93e0f99 100644 --- a/test/setup.jl +++ b/test/setup.jl @@ -86,7 +86,8 @@ end # Toy models # ---------------------------- -function S_x(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where {T<:Number} +function S_x((::Type{Trivial})=Trivial, (::Type{T})=ComplexF64; + spin=1 // 2) where {T<:Number} return if spin == 1 // 2 TensorMap(T[0 1; 1 0], ℂ^2 ← ℂ^2) elseif spin == 1 @@ -95,7 +96,8 @@ function S_x(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where { throw(ArgumentError("spin $spin not supported")) end end -function S_y(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where {T<:Number} +function S_y((::Type{Trivial})=Trivial, (::Type{T})=ComplexF64; + spin=1 // 2) where {T<:Number} return if spin == 1 // 2 TensorMap(T[0 -im; im 0], ℂ^2 ← ℂ^2) elseif spin == 1 @@ -104,7 +106,8 @@ function S_y(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where { throw(ArgumentError("spin $spin not supported")) end end -function S_z(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where {T<:Number} +function S_z((::Type{Trivial})=Trivial, (::Type{T})=ComplexF64; + spin=1 // 2) where {T<:Number} return if spin == 1 // 2 TensorMap(T[1 0; 0 -1], ℂ^2 ← ℂ^2) elseif spin == 1 @@ -113,17 +116,20 @@ function S_z(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where { throw(ArgumentError("spin $spin not supported")) end end -function S_xx(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where {T<:Number} +function S_xx((::Type{Trivial})=Trivial, (::Type{T})=ComplexF64; + spin=1 // 2) where {T<:Number} return S_x(Trivial, T; spin) ⊗ S_x(Trivial, T; spin) end -function S_yy(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where {T<:Number} +function S_yy((::Type{Trivial})=Trivial, (::Type{T})=ComplexF64; + spin=1 // 2) where {T<:Number} return S_y(Trivial, T; spin) ⊗ S_y(Trivial, T; spin) end -function S_zz(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1 // 2) where {T<:Number} +function S_zz((::Type{Trivial})=Trivial, (::Type{T})=ComplexF64; + spin=1 // 2) where {T<:Number} return S_z(Trivial, T; spin) ⊗ S_z(Trivial, T; spin) end -function transverse_field_ising(::Type{T}=ComplexF64; g=1.0, L=Inf) where {T<:Number} +function transverse_field_ising((::Type{T})=ComplexF64; g=1.0, L=Inf) where {T<:Number} X = S_x(Trivial, T; spin=1 // 2) ZZ = S_zz(Trivial, T; spin=1 // 2) @@ -156,7 +162,7 @@ function heisenberg_XXX(::Type{SU2Irrep}; spin=1, L=Inf) end end -function heisenberg_XXX(::Type{Trivial}=Trivial, ::Type{T}=ComplexF64; spin=1, +function heisenberg_XXX((::Type{Trivial})=Trivial, (::Type{T})=ComplexF64; spin=1, L=Inf) where {T<:Number} h = ones(T, SU2Space(spin => 1)^2 ← SU2Space(spin => 1)^2) for (c, b) in blocks(h) From 2dba5bfe938d4406d0c8118f7812363df690b71c Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Wed, 18 Jun 2025 08:00:29 -0400 Subject: [PATCH 3/4] Remove format suggestions --- .github/workflows/Format.yml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .github/workflows/Format.yml diff --git a/.github/workflows/Format.yml b/.github/workflows/Format.yml deleted file mode 100644 index a1c8cf4f1..000000000 --- a/.github/workflows/Format.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: Format suggestions -on: - pull_request: -jobs: - code-style: - runs-on: ubuntu-latest - steps: - - uses: julia-actions/julia-format@v4 \ No newline at end of file From 2a8725a4f09404057bd00ae781a131505dc470be Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Mon, 30 Jun 2025 12:54:21 +0200 Subject: [PATCH 4/4] Fix formatting after rebase --- src/algorithms/approximate/idmrg.jl | 4 ++-- src/algorithms/statmech/idmrg.jl | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/algorithms/approximate/idmrg.jl b/src/algorithms/approximate/idmrg.jl index adb4aeec3..8f51c60b4 100644 --- a/src/algorithms/approximate/idmrg.jl +++ b/src/algorithms/approximate/idmrg.jl @@ -75,7 +75,7 @@ function approximate!(ψ::MultilineMPS, toapprox::Tuple{<:MultilineMPO,<:Multili for row in 1:size(ψ, 1) AC2′ = AC2_projection(CartesianIndex(row, site), ψ, toapprox, envs; kind=:ACAR) - al, c, ar, = tsvd!(AC2′; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(AC2′; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[row + 1, site] = al @@ -95,7 +95,7 @@ function approximate!(ψ::MultilineMPS, toapprox::Tuple{<:MultilineMPO,<:Multili for row in 1:size(ψ, 1) AC2′ = AC2_projection(CartesianIndex(row, site), ψ, toapprox, envs; kind=:ALAC) - al, c, ar, = tsvd!(AC2′; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(AC2′; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[row + 1, site] = al diff --git a/src/algorithms/statmech/idmrg.jl b/src/algorithms/statmech/idmrg.jl index 515cb805d..beecbac5b 100644 --- a/src/algorithms/statmech/idmrg.jl +++ b/src/algorithms/statmech/idmrg.jl @@ -80,7 +80,7 @@ function leading_boundary(ψ::MultilineMPS, operator, alg::IDMRG2, _, ac2′ = fixedpoint(h, ac2, :LM, alg_eigsolve) for row in 1:size(ψ, 1) - al, c, ar, = tsvd!(ac2′[row]; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(ac2′[row]; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[row + 1, site] = al @@ -104,7 +104,7 @@ function leading_boundary(ψ::MultilineMPS, operator, alg::IDMRG2, _, ac2′ = fixedpoint(h, ac2, :LM, alg_eigsolve) for row in 1:size(ψ, 1) - al, c, ar, = tsvd!(ac2′[row]; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(ac2′[row]; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[row + 1, site] = al @@ -129,7 +129,7 @@ function leading_boundary(ψ::MultilineMPS, operator, alg::IDMRG2, _, ac2′ = fixedpoint(h, ac2, :LM, alg_eigsolve) for row in 1:size(ψ, 1) - al, c, ar, = tsvd!(ac2′[row]; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(ac2′[row]; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[row + 1, site] = al @@ -151,7 +151,7 @@ function leading_boundary(ψ::MultilineMPS, operator, alg::IDMRG2, _, ac2′ = fixedpoint(h, ac2, :LM, alg_eigsolve) for row in 1:size(ψ, 1) - al, c, ar, = tsvd!(ac2′[row]; trunc=alg.trscheme, alg=alg.alg_svd) + al, c, ar = tsvd!(ac2′[row]; trunc=alg.trscheme, alg=alg.alg_svd) normalize!(c) ψ.AL[row + 1, end] = al