fix: handle mixed BURN_STEP shapes in results reader (Serpent 2.2.3+)#539
Open
steps-re wants to merge 2 commits into
Open
fix: handle mixed BURN_STEP shapes in results reader (Serpent 2.2.3+)#539steps-re wants to merge 2 commits into
steps-re wants to merge 2 commits into
Conversation
Serpent 2.2.3 with ``set depmtx 1`` writes additional scalar and matrix declaration lines (e.g. ``flx = 2;``, ``N0 = zeros(n, 1);``) between the time header and the first N0 isotope entry. The reader raised a ``SerpentToolsException`` when it hit these unrecognized lines. Add a loop in ``DepmtxReader._read`` that advances past any lines which do not match ``NDENS_REGEX`` before starting to parse the N0 block. The fix is backward-compatible: files without extra lines are parsed identically. Add a regression test that prepends ``flx`` and ``N0 = zeros`` lines to the existing ``depmtx_ref.m`` fixture and verifies the parsed arrays match the reference reader output exactly. Fixes CORE-GATECH-GROUP#533 Signed-off-by: Mike German <mike@stepsventures.com>
Serpent 2.2.3 writes BURN_STEP as a 3-element vector for burnup steps BURN_STEP (idx, [1: 3]) = [ 0 1 0 ] but as a scalar for decay steps BURN_STEP (idx, 1) = 19 ListOfArrays enforced consistent shapes and raised ValueError when these were mixed, crashing the results reader on any file that included decay steps. Change ListOfArrays to warn (UserWarning) on the first shape mismatch and switch to ragged (object-dtype) storage rather than raising. Existing files with consistent shapes are unaffected. Three unit tests added to verify correct warning emission, correct object-array output for ragged data, and absence of duplicate warnings after the first mismatch. Fixes CORE-GATECH-GROUP#537 Signed-off-by: Mike German <mike@stepsventures.com>
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
Serpent 2.2.3 changed how
BURN_STEPis written in*_res.mfiles. For burnup steps it emits a 3-element vector, but for decay steps it emits a scalar:ListOfArraysenforced consistent shapes across all appended rows, so reading any*_res.mfile with decay steps crashed with:Fix
Modified
ListOfArrays.appendto:UserWarningon the first shape mismatch (once, not on every step)Files with consistent shapes (all prior Serpent versions) are completely unaffected — the code path is unchanged for them.
Tests
Three new unit tests added to
test_results.py:test_list_of_arrays_consistent_shapes— stacked 2-D array for uniform shapestest_list_of_arrays_ragged_warns_and_stores— singleUserWarning+ correct object array for mixed shapestest_list_of_arrays_ragged_no_extra_warning— no duplicate warnings after first mismatchAll 7 results tests pass.
Fixes #537
Signed-off-by: Mike German mike@stepsventures.com