Add support for arbitrarily large spin states#1370
Merged
Conversation
Previously the spin state name was obtained using a dictionary mapping integer spin state to the name string. Only up to 11 unpaired electrons were supported this way. With this change, larger spins are named via n-multiplet (e.g. 12 unpaired electrons gives a 13-multiplet state).
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates molecular_data.py to support spin multiplicities greater than 12 by appending a generic _X-multiplet suffix, and adds corresponding unit tests. The reviewer pointed out an inconsistency where float-valued multiplicities (e.g., 2.0) are accepted if they are <= 12 (due to dictionary lookup behavior) but rejected if they are > 12 (due to strict type checking). The reviewer suggested normalizing and validating all integer-valued numeric types (including floats) before processing.
The multiplicity parameter of molecular_data is now checked in the constructor and a ValueError is thrown if a noninteger or negative value is used. Tests are added to check errors are correctly thrown.
mhucka
requested changes
Jun 23, 2026
The error in molecular_data when providing an incorrect multiplicity needs to remain a MoleculeNameError to ensure backwards compatibility. This error type now inherits from ValueError (which makes more sense physically).
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.
Fixes #809 Previously the spin state name was obtained using a dictionary mapping integer multiplicity to the name string. Only up to 11 unpaired electrons were supported this way, with an error thrown for anything larger. With this change, larger spins are named via n-multiplet (e.g. 12 unpaired electrons is named 13-multiplet).
Tests are added to check the naming for large spin states is correct, and that non-integer spin states still throw an error.