diff --git a/.github/workflows/FormatPullRequest.yml b/.github/workflows/FormatPullRequest.yml new file mode 100644 index 0000000..93875cc --- /dev/null +++ b/.github/workflows/FormatPullRequest.yml @@ -0,0 +1,14 @@ +name: "Format Pull Request" + +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: +permissions: + contents: write + pull-requests: write + +jobs: + format-pull-request: + name: "Format Pull Request" + uses: "ITensor/ITensorActions/.github/workflows/FormatPullRequest.yml@main" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6599365..46311a8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,9 @@ +ci: + skip: [julia-formatter] + repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: check-merge-conflict - id: check-toml @@ -9,6 +12,6 @@ repos: exclude_types: [markdown] # incompatible with Literate.jl - repo: "https://github.com/domluna/JuliaFormatter.jl" - rev: v1.0.62 + rev: v2.1.0 hooks: - id: "julia-formatter" diff --git a/Project.toml b/Project.toml index 3824dc6..dd0be7d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ITensorMPS" uuid = "0d1a4710-d33b-49a5-8f18-73bdf49b47e2" authors = ["Matthew Fishman ", "Miles Stoudenmire "] -version = "0.3.16" +version = "0.3.17" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/abstractmps.jl b/src/abstractmps.jl index a555772..2d962cb 100644 --- a/src/abstractmps.jl +++ b/src/abstractmps.jl @@ -694,7 +694,7 @@ end # TODO: change kwarg from `set_limits` to `preserve_ortho` function map!(f::Function, M::AbstractMPS; set_limits::Bool=true) for i in eachindex(M) - M[i, set_limits=set_limits] = f(M[i]) + M[i, set_limits = set_limits] = f(M[i]) end return M end @@ -1306,7 +1306,7 @@ of the orthogonality center to avoid numerical overflow in the case of diverging See also [`normalize!`](@ref), [`norm`](@ref), [`lognorm`](@ref). """ function normalize(M::AbstractMPS; (lognorm!)=[]) - return normalize!(deepcopy_ortho_center(M); (lognorm!)=lognorm!) + return normalize!(deepcopy_ortho_center(M); (lognorm!)=(lognorm!)) end """ @@ -2001,7 +2001,7 @@ function swapbondsites(ψ::AbstractMPS, b::Integer; ortho="right", kwargs...) elseif rightlim(ψ) > b + 2 ψ = orthogonalize(ψ, b + 1) end - ψ[b:(b + 1), orthocenter=orthocenter, perm=[2, 1], kwargs...] = ψ[b] * ψ[b + 1] + ψ[b:(b + 1), orthocenter = orthocenter, perm = [2, 1], kwargs...] = ψ[b] * ψ[b + 1] return ψ end diff --git a/src/lib/Experimental/src/dmrg.jl b/src/lib/Experimental/src/dmrg.jl index 8796936..6739c13 100644 --- a/src/lib/Experimental/src/dmrg.jl +++ b/src/lib/Experimental/src/dmrg.jl @@ -10,7 +10,7 @@ function dmrg( operator, init::MPS; updater=eigsolve_updater, (observer!)=default_observer(), kwargs... ) info_ref! = Ref{Any}() - info_observer! = values_observer(; info=info_ref!) + info_observer! = values_observer(; info=(info_ref!)) observer! = compose_observers(observer!, info_observer!) state = alternating_update(operator, init; updater, observer!, kwargs...) return info_ref![].eigval, state diff --git a/src/solvers/alternating_update.jl b/src/solvers/alternating_update.jl index 75ecc4b..6206123 100644 --- a/src/solvers/alternating_update.jl +++ b/src/solvers/alternating_update.jl @@ -104,7 +104,7 @@ function alternating_update( flush(stdout) end isdone = checkdone(; - state, sweep, outputlevel, observer=observer!, sweep_observer=sweep_observer! + state, sweep, outputlevel, observer=(observer!), sweep_observer=(sweep_observer!) ) isdone && break end diff --git a/src/solvers/sweep_update.jl b/src/solvers/sweep_update.jl index 46ffa3e..ac6cc24 100644 --- a/src/solvers/sweep_update.jl +++ b/src/solvers/sweep_update.jl @@ -302,7 +302,7 @@ function region_update!( end set_nsite!(reduced_operator, nsite - 1) position!(reduced_operator, state, b1) - internal_kwargs = (; current_time, time_step=-time_step, outputlevel) + internal_kwargs = (; current_time, time_step=(-time_step), outputlevel) bond_reduced_state, info = updater( reduced_operator, bond_reduced_state; internal_kwargs, updater_kwargs... ) @@ -437,7 +437,7 @@ function region_update!( bond_reduced_state = state[b1] set_nsite!(reduced_operator, nsite - 1) position!(reduced_operator, state, b1) - internal_kwargs = (; current_time, time_step=-time_step, outputlevel) + internal_kwargs = (; current_time, time_step=(-time_step), outputlevel) bond_reduced_state, info = updater( reduced_operator, bond_reduced_state; internal_kwargs, updater_kwargs... ) diff --git a/src/solvers/tdvp.jl b/src/solvers/tdvp.jl index 6ab1ff2..02d8c5c 100644 --- a/src/solvers/tdvp.jl +++ b/src/solvers/tdvp.jl @@ -79,7 +79,7 @@ function tdvp( nsweeps=nothing, nsteps=nsweeps, (step_observer!)=default_sweep_observer(), - (sweep_observer!)=step_observer!, + (sweep_observer!)=(step_observer!), kwargs..., ) time_step, nsteps = time_step_and_nsteps(t, time_step, nsteps) diff --git a/test/base/test_mpo.jl b/test/base/test_mpo.jl index 047e738..9116a26 100644 --- a/test/base/test_mpo.jl +++ b/test/base/test_mpo.jl @@ -562,7 +562,7 @@ end ψ = orthogonalize(ψ0, 2) A = prod(ITensors.data(ψ)[2:(N - 1)]) randn!(A) - ψ[2:(N - 1), orthocenter=3] = A + ψ[2:(N - 1), orthocenter = 3] = A @test prod(ψ) ≈ ψ[1] * A * ψ[N] @test maxlinkdim(ψ) == 4 @test ITensorMPS.orthocenter(ψ) == 3 @@ -728,7 +728,7 @@ end s = siteinds(H2; plev=1) C = combiner.(s; tags="X") H2 .*= C - H2H2 = prime(H2; tags=!ts"X") * dag(H2) + H2H2 = prime(H2; tags=(!ts"X")) * dag(H2) @test @disable_warn_order prod(HH) ≈ prod(H2H2) end diff --git a/test/base/test_mps.jl b/test/base/test_mps.jl index 10ca80d..ca7f3a1 100644 --- a/test/base/test_mps.jl +++ b/test/base/test_mps.jl @@ -1334,7 +1334,7 @@ end ψ = orthogonalize(ψ0, 2) A = prod(ITensorMPS.data(ψ)[2:(N - 1)]) randn!(A) - ψ[2:(N - 1), orthocenter=3] = A + ψ[2:(N - 1), orthocenter = 3] = A @test prod(ψ) ≈ ψ[1] * A * ψ[N] @test maxlinkdim(ψ) == 4 @test ITensorMPS.orthocenter(ψ) == 3 diff --git a/test/base/test_qnmpo.jl b/test/base/test_qnmpo.jl index 038f081..2e1eb78 100644 --- a/test/base/test_qnmpo.jl +++ b/test/base/test_qnmpo.jl @@ -337,6 +337,7 @@ test_combos = [(make_heisenberg_opsum, "S=1/2"), (make_hubbard_opsum, "Electron" @testset "QR/QL MPO tensors with complex block structures, H=$(test_combo[1])" for test_combo in test_combos + N, NNN = 10, 7 #10 lattice site, up 7th neight interactions sites = siteinds(test_combo[2], N; conserve_qns=true) H = test_combo[1](sites, NNN) diff --git a/test/base/test_solvers/test_tdvp.jl b/test/base/test_solvers/test_tdvp.jl index df6f4f3..b50c247 100644 --- a/test/base/test_solvers/test_tdvp.jl +++ b/test/base/test_solvers/test_tdvp.jl @@ -43,7 +43,7 @@ const elts = (Float32, Float64, Complex{Float32}, Complex{Float64}) total_time = elt(0.1) * im # matching total time and time step directions @test_throws "signs agree" tdvp(H, -total_time, ψ0; time_step) - @test_throws "signs agree" tdvp(H, total_time, ψ0; time_step=-time_step) + @test_throws "signs agree" tdvp(H, total_time, ψ0; time_step=(-time_step)) # total time is an integer of time steps @test_throws "integer" tdvp(H, total_time * 1.5, ψ0; time_step) end diff --git a/test/ext/ITensorMPSChainRulesCoreExt/test_optimization.jl b/test/ext/ITensorMPSChainRulesCoreExt/test_optimization.jl index 3835f95..b2965a4 100644 --- a/test/ext/ITensorMPSChainRulesCoreExt/test_optimization.jl +++ b/test/ext/ITensorMPSChainRulesCoreExt/test_optimization.jl @@ -124,7 +124,7 @@ include(joinpath(@__DIR__, "utils", "circuit.jl")) end @testset "State preparation (MPS)" begin - for gate in ["Ry"] #="Rx", =# + for gate in ["Ry"] nsites = 4 # Number of sites nlayers = 2 # Layers of gates in the ansatz gradtol = 1e-3 # Tolerance for stopping gradient descent