Repository navigation
Conversation
…rings Both docstrings stated the Hamiltonian with an overall minus sign on the coupling and field terms, but `second_q_op()` has always used the coefficients as given (and the migration guide documents that behaviour). Update the formulas to match the code and state explicitly that no sign is applied, so a ferromagnetic coupling is a negative J. Fixes qiskit-community#1380 Co-Authored-By: Claude Opus 5 <[email protected]>
edubraqd
requested review from
Panadestein,
fpietra,
ludmilaasb,
matteoacrossi,
mrossinek,
robertodr and
woodsp-ibm
as code owners
September 19, 2026 11:07
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1380
The docstrings of
HeisenbergModelandIsingModelwrite the Hamiltonian with an overall minus sign on the coupling and field terms, butsecond_q_op()builds the operator with the coefficients as given:Details and comments
I chose to fix the documentation rather than the code: the
+J/+hconvention has been the behaviour since the models were introduced, the 0.5 migration guide documents it (uniform_parameters(2.0, 4.0)→2.0 * Z_0 Z_1 + 4.0 * X_0 + ...), andtest_heisenberg_model.test_isingrelies on both models agreeing. Flipping the signs insecond_q_op()would silently change results for every existing user.Changes:
HeisenbergModelandIsingModeldocstring formulas now match the operator, with a sentence stating that no overall sign is applied (ferromagnetic coupling = negativeJ).fixes).ferromagneticadded to.pylintdictfor the spell check.No behaviour change;
test_heisenberg_modelandtest_ising_modelpass unchanged (8 tests). I could not run thespelltarget locally (pyenchant has noen_USdictionary on Windows), so CI will be the check for that one.AI disclosure: the change was prepared with the help of Claude (Claude Code); I reviewed and verified it.
🤖 Generated with Claude Code