Skip to content

Three code fixes carved out of the docs pass (#449) - #489

Merged
lkdvos merged 4 commits into
mainfrom
ld-small-fixes
Jul 31, 2026
Merged

Three code fixes carved out of the docs pass (#449)#489
lkdvos merged 4 commits into
mainfrom
ld-small-fixes

Conversation

@lkdvos

@lkdvos lkdvos commented Jul 30, 2026

Copy link
Copy Markdown
Member

Three unrelated code fixes that were buried in the documentation pass of #449, carved out so that PR can stay documentation-only. One commit each, with a test and a changelog entry.

  1. correlator throws on unordered sites. The i < j guard used @error, which only logs and then falls through into the contraction, returning a number that is not the requested correlator. Now an ArgumentError. Behaviour change, so ### Changed.
  2. excitations on an InfiniteMPO with a quasiparticle input. EffectiveExcitationHamiltonian(H_eff, ...) read H_eff on the line assigning it, so the method threw UndefVarError on every call — a dead path rather than a silently wrong result, so no past computation is suspect. Fixed to pass H, which reproduces the MultilineMPO route exactly.
  3. isfinite for WindowMPOHamiltonian. The trait dispatches on the type and this one was missing, so isfinite threw a MethodError.

Tests for all three pass; the new excitations testset errors against the unfixed source. Full suite not run.

Spotted but not done here: WindowMPOHamiltonian also lacks GeometryStyle and OperatorStyle.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/operators/windowhamiltonian.jl 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/algorithms/correlators.jl 100.00% <100.00%> (+9.52%) ⬆️
...c/algorithms/excitation/quasiparticleexcitation.jl 80.00% <100.00%> (+5.71%) ⬆️
src/operators/windowhamiltonian.jl 93.93% <0.00%> (-2.94%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

lkdvos and others added 4 commits July 31, 2026 12:02
`first(js) > i || @error "..."` only logged the problem and then let the function
continue into a contraction that is not the requested correlator, so an unordered
(or equal) site pair returned a meaningless number instead of failing. Make it an
`ArgumentError`, and document the ordering requirement in the docstring.

All three `correlator` signatures funnel their arguments through the range method,
so the test covers each of them.

Carved out of #449 to keep that PR documentation-only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`excitations(H::InfiniteMPO, ::QuasiparticleAnsatz, ϕ₀::InfiniteQP, lenvs, renvs)`
constructed its effective Hamiltonian as
`EffectiveExcitationHamiltonian(H_eff, lenvs, renvs, E)`. `H_eff` is the local being
assigned on that very line, so the read hit an uninitialized slot and every call through
this method threw `UndefVarError: H_eff not defined in local scope` — the path was dead
rather than silently wrong. The momentum entry point is unaffected, since for an
`MPO` it converts to a `MultilineMPO` and dispatches to the `MultilineQP` method.

The regression test uses the classical Ising transfer matrix rather than the six-vertex
model of the neighbouring testset: with the latter the quasiparticle eigenproblem is only
loosely converged (the eigenpair residual is ~1e-2 on both entry points), while for the
former the two entry points agree to ~1e-11.

Carved out of #449 to keep that PR documentation-only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`Base.isfinite(O::AbstractMPO) = isfinite(typeof(O))` requires every concrete operator
type to define the trait, and `WindowMPOHamiltonian` did not, so both `isfinite(H)` and
`isfinite(typeof(H))` threw a `MethodError`. A window Hamiltonian acts on a finite
number of sites, so the trait is `true`, matching how it otherwise behaves as a finite
Hamiltonian; it is spelled and placed like the `FiniteMPO(Hamiltonian)` definitions.

Carved out of #449 to keep that PR documentation-only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lkdvos
lkdvos marked this pull request as ready for review July 31, 2026 16:02
@lkdvos
lkdvos merged commit 0ff11c3 into main Jul 31, 2026
1 of 7 checks passed
@lkdvos
lkdvos deleted the ld-small-fixes branch July 31, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant