Skip to content

Fix sparse storage of multidimensional tally results - #4030

Merged
GuySten merged 1 commit into
openmc-dev:developfrom
paulromano:fix-tally-sparse-storage
Jul 27, 2026
Merged

Fix sparse storage of multidimensional tally results#4030
GuySten merged 1 commit into
openmc-dev:developfrom
paulromano:fix-tally-sparse-storage

Conversation

@paulromano

Copy link
Copy Markdown
Contributor

Description

This fixes conversion of tally result arrays to SciPy LIL sparse arrays. SciPy sparse arrays are two-dimensional, but tally data is logically shaped by filter, nuclide, and score bins. The previous conversion attempted to construct a sparse array using the tally's three-dimensional shape and fails with current SciPy versions with the following exception:

ValueError: LIL arrays don't support 1D input. Use 2D

This PR now now stores tally data internally as a two-dimensional row sparse array. A single row avoids the per-row Python-list overhead that LIL storage would incur for a column with one row per tally bin. Existing tally accessors continue to return dense arrays reshaped to the logical tally dimensions, so the public data representation is unchanged.

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)

@nuclearkevin nuclearkevin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nuclearkevin nuclearkevin added the Merging Soon PR will be merged in < 24 hrs if no further comments are made. label Jul 26, 2026
@GuySten
GuySten merged commit 04e4c6d into openmc-dev:develop Jul 27, 2026
17 checks passed
@paulromano
paulromano deleted the fix-tally-sparse-storage branch July 28, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merging Soon PR will be merged in < 24 hrs if no further comments are made.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants