Msparse everywhere - #217
Merged
Merged
Conversation
Remove the duplicate `to_sparse_majorana()` method and add `to_dict()` to `PyMajoranaSparse` to provide the same dict-like functionality. This simplifies the API by having a single conversion method that can return either the structured `PyMajoranaSparse` object or a dict via `.to_dict()`. - Remove `to_sparse_majorana()` from FermionHamiltonian - Add `to_dict()` method to PyMajoranaSparse that returns simplified terms - Update test callers to use `to_majorana_sparse().to_dict()` - Update comment in functions.rs to reference new method Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…ethods Widens MajoranaEncoding.encode_annealed, .anneal_enumeration, .batch_pauli_weights, the hatt and encode_topphatt module functions, and their Python wrappers (TernaryTree.encode_annealed/.topphatt/.encode, hamiltonian_adaptive_ternary_tree) to accept a MajoranaSparse directly, matching the pattern already used by MajoranaEncoding.encode (#216). Also fixes TernaryTree.encode, whose type hint already claimed to accept MajoranaSparse but would raise a TypeError at the pyo3 boundary since encode_topphatt only accepted FermionHamiltonian. PyMajoranaSparse now carries the source Hamiltonian's n_modes, since the core MajoranaSparse type has no mode count of its own and several of these methods need one to compute defaults (temperature, n_modes). This also lets the ad-hoc index-range scan in MajoranaEncoding.encode be replaced with a direct mode-count comparison, mirroring the check already used for FermionHamiltonian inputs. Also removes the to_sparse_majorana stub left behind in core.pyi from the prior consolidation onto to_majorana_sparse, and adds the missing to_dict stub for MajoranaSparse. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
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.
Some functions forgotten in #216 , and deleting a confusingly similar
to_sparse_majoranawhich I had forgotten about .