Re-enable FHI-aims total energy mapping#183
Conversation
Re-enables the `total_energies` mapping for FHI-aims parser that was disabled in commit 0e00561 (PR #150, March 2026). The parser's `get_energies()` method has remained functional, only the schema mapping annotation was commented out. Changes: - Replace commented `m_annotations.setdefault()` syntax with active `add_mapping_annotation()` for consistency with other parsers - Add comprehensive test coverage for `total_energies` extraction - Verify all 5 geometry optimization outputs populate energies - Test energy value accuracy and contributions/components structure Impact analysis: - Parser method `get_energies()` verified working (parser.py:289-301) - MD parser utils handle both empty and populated energies defensively - No existing tests affected (no prior energy tests existed) - Test data contains valid energy values across all outputs - Follows same pattern as VASP, GPAW, QE, and other parsers The energy mapping was intentionally deferred during the convergence targets migration. This PR completes that migration for energies as a standalone, minimal change.
- Break long lines to comply with 88 char limit - Reformat test assertions for readability - All tests still passing
Coverage Report for CI Build 26894435401Coverage increased (+0.2%) to 74.352%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This PR re-enables the FHI-aims total_energies schema mapping by restoring an active mapping annotation (using add_mapping_annotation) and adds unit tests to verify total energy extraction and contribution structure for a geometry optimization run.
Changes:
- Re-enabled
outputs.Outputs.total_energiesmapping annotation in the FHI-aims schema package. - Added a new
test_total_energies()to validate extracted total energies across all geometry optimization steps, including units and contribution presence.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/nomad_simulation_parsers/schema_packages/fhiaims.py |
Restores total_energies mapping annotation using add_mapping_annotation under the FHI-aims text mapping key. |
tests/parsers/test_fhiaims_parser.py |
Adds coverage ensuring total_energies are populated for each output step and validates the first-step reference value and contributions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Check each output has total_energies | ||
| for i, output in enumerate(outputs): | ||
| assert output.total_energies is not None, f'Output {i} has no total_energies' |
There was a problem hiding this comment.
Aren't is not None assertions on total_energies and contributions vacuous?
afaik, SubSection with repeats=True never returns None on access, but it returns an empty MSubSectionList
There was a problem hiding this comment.
(source: metainfo.py:3487-3494)
def __get__(self, obj, cls=None):
if obj is None:
return self
if self.repeats:
return obj.__dict__.setdefault(self.name, MSubSectionList(obj, self))
# non-repeating:
return obj.__dict__.get(self.name, None)
EBB2675
left a comment
There was a problem hiding this comment.
LGTM, one nit on dead is not None assertions in the tests
Purpose
Re-enables the
total_energiesmapping for FHI-aims parser that was disabled in commit 0e00561 (PR #150, March 2026). The parser'sget_energies()method has remained functional - only the schema mapping annotation was commented out.Scope
Included
total_energiesmapping annotation infhiaims.pyOut of scope
Context & Links
Why it was disabled: During the convergence targets migration (#150), the energy mapping was intentionally commented out using the old
m_annotations.setdefault()syntax. The commit message stated: "Future migration to dict-basedm_defmapping annotations should be tracked separately (see PR #162 for reference)."Related PRs:
Investigation notes: See
.investigation-notes.mdin branch (not committed) for detailed impact analysis.Reviewer Notes
Key changes:
m_annotations.setdefault()with activeadd_mapping_annotation()for consistency with other parsers (VASP, GPAW, QE all use this pattern)test_total_energies()validates:Risk assessment: LOW
get_energies()already works (parser.py:289-301)total_energiesis empty before appending)Status
Breaking Changes
Dependencies / Blockers
Testing / Validation
test_total_energies()with comprehensive validation