D1s multi index sequence#3952
Open
jon-proximafusion wants to merge 2 commits into
Open
Conversation
apply_time_correction now takes a sequence of time indices and returns a list of derived tallies, one per index. The tally arrays are read and reshaped once and shared across all indices, so post-processing a D1S mesh tally at many shutdown times no longer re-reads and re-reshapes the data on every call. The per-index math is unchanged, so each derived tally is bit-for-bit identical to the previous single-index result. This is a small breaking change: the function always returns a list (one tally per index) and the default index is now (-1,) rather than -1. The existing test, docs example, and the new multi-index test are updated to unpack the returned list.
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
apply_time_correctionnow takes a sequence of time indices and returns a list of derived tallies, one per index. The tally arrays are read and reshaped once and shared across all indices, so post-processing a D1S mesh tally at many shutdown times no longer re-reads and re-reshapes the data on every call.The per-index math is unchanged from
develop, so each derived tally is bit-for-bit identical to the previous single-index result.API change (small, intentional break)
This favours a clean, type-stable signature over a polymorphic
int | Sequence[int]→Tally | list[Tally]API:indexis now an iterable of ints; the default is(-1,)(was-1).list[openmc.Tally], one per index, in order.Callers that want a single time unpack the one-element list:
I have another version of this PR without breaking api changes but I think that is worse overall
The existing test, the user-guide example, and a new multi-index test are updated accordingly. A
.. versionchanged:: 0.16.0note documents the break in the docstring.Testing
Adds
test_apply_time_correction_multi_index, which checks that each element of a multi-index call matches the corresponding single-index call (mean, std_dev, filters, and sum/sum_sq), that unordered/partial index sequences are honored in order, and that the original tally is left unmodified. The existingtest_apply_time_correctionis updated to unpack the list.Checklist