Skip to content

D1s multi index sequence#3952

Open
jon-proximafusion wants to merge 2 commits into
openmc-dev:developfrom
shimwell:d1s-multi-index-sequence
Open

D1s multi index sequence#3952
jon-proximafusion wants to merge 2 commits into
openmc-dev:developfrom
shimwell:d1s-multi-index-sequence

Conversation

@jon-proximafusion
Copy link
Copy Markdown
Contributor

@jon-proximafusion jon-proximafusion commented Jun 1, 2026

Summary

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 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:

  • index is now an iterable of ints; the default is (-1,) (was -1).
  • The function always returns 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

tally, = d1s.apply_time_correction(dose_tally, factors, [-1])

The existing test, the user-guide example, and a new multi-index test are updated accordingly. A .. versionchanged:: 0.16.0 note 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 existing test_apply_time_correction is updated to unpack the list.

Note: the D1S unit tests call model.run() and require a compiled OpenMC plus nuclear data, so they were not executed locally — CI will cover them.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 18) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

shimwell and others added 2 commits June 1, 2026 11:48
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants