Fix multiplicity parity validation - #914
Open
calvinp0 wants to merge 5 commits into
Open
Conversation
calvinp0
force-pushed
the
fix_multiplicity_parity_validation
branch
from
July 20, 2026 15:49
e721949 to
1ccaaf7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #914 +/- ##
==========================================
+ Coverage 63.54% 63.57% +0.03%
==========================================
Files 114 114
Lines 38363 38391 +28
Branches 10033 10041 +8
==========================================
+ Hits 24377 24407 +30
Misses 11066 11066
+ Partials 2920 2918 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
arc/species/species.py:1617
- The warning message uses total_electrons as if it were the actual electron count (e.g., “species with 16 electrons and net charge +1 has 15 electrons”), which is internally inconsistent and can confuse users. Consider clarifying that total_electrons is the neutral electron count / atomic-number sum, and that n_electrons is the actual electron count after applying charge.
f'Impossible multiplicity for species {self.label}: a species with '
f'{total_electrons} electrons and a net charge of {self.charge} has '
f'{n_electrons} electrons, which requires an {parity_word} multiplicity, '
f'but a multiplicity of {self.multiplicity} was requested. '
f'Valid nearby multiplicities would be {valid}. '
arc/species/species.py:1612
- The PR description says the parity check raises SpeciesError for inconsistent electron-count/multiplicity combinations, but the implementation only logs a warning and continues constructing the species. Please align behavior and documentation: either raise SpeciesError here (and update tests accordingly) or update the PR description/intent to reflect warning-only validation.
if n_electrons % 2 != (self.multiplicity - 1) % 2:
lower = self.multiplicity - 1
valid = [m for m in (lower, self.multiplicity + 1) if m >= 1]
parity_word = 'odd' if n_electrons % 2 == 0 else 'even'
logger.warning(
alongd
reviewed
Jul 26, 2026
calvinp0
force-pushed
the
fix_multiplicity_parity_validation
branch
3 times, most recently
from
July 26, 2026 08:46
7d8ad7a to
6b4e87d
Compare
…eciesError); fail fast on unrecognized atom symbols
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.
This pull request introduces a parity check for spin multiplicity and electron count in
ARCSpecies, ensuring that the specified multiplicity is physically possible given the species' composition and charge. It also adds robust testing for this logic and fixes a test case for nitrogen to use the correct multiplicity and Molpro input. Additionally, it improves code clarity by importingNUMBER_BY_SYMBOLwhere needed.Validation of multiplicity and electron count:
check_multiplicity_paritymethod toARCSpeciesthat verifies the parity of the electron count and multiplicity, raising aSpeciesErrorif they are inconsistent. This method is called during initialization. [1] [2]get_number_of_electronsmethod inARCSpeciesto count electrons from the molecule or xyz.Testing improvements:
test_check_multiplicity_paritytospecies_test.pyto ensure the parity check works and raises errors for impossible combinations.Bug fixes and test corrections:
molpro_test.pyto usemultiplicity=4(quartet) and adjusted the Molpro input file templates accordingly. [1] [2]Code clarity:
NUMBER_BY_SYMBOLinspecies.pyto support electron counting.