Skip to content

frontends/swift: add SpeciesFractions-derived fields and fix scalar conversion - #5497

Open
Stanley-Lee-glitch wants to merge 1 commit into
yt-project:mainfrom
Stanley-Lee-glitch:swift-species-fractions
Open

frontends/swift: add SpeciesFractions-derived fields and fix scalar conversion#5497
Stanley-Lee-glitch wants to merge 1 commit into
yt-project:mainfrom
Stanley-Lee-glitch:swift-species-fractions

Conversation

@Stanley-Lee-glitch

@Stanley-Lee-glitch Stanley-Lee-glitch commented Jul 28, 2026

Copy link
Copy Markdown

PR Summary

This PR adds derived per-species fraction fields for the SWIFT frontend by unpacking the packed SpeciesFractions particle field. For each ion and molecule in the chemistry network, it exposes:

  • _fraction_raw: the original value stored in the snapshot.
  • _fraction: a normalized fraction for ions (normalized within each parent element), while molecules are exposed as aliases of the corresponding raw values.

In addition, this PR fixes several array-to-scalar conversion issues in SwiftDataset by converting HDF5 scalar arrays to Python scalars using np.asarray(...).item(). This avoids failures when metadata are returned as NumPy arrays instead of scalar values.

PR Checklist

  • New features are documented, with docstrings and narrative docs
  • Adds a test for any bugs fixed. Adds tests for new features.

…s, array to scalar bug fixed in data_structure
@Stanley-Lee-glitch
Stanley-Lee-glitch marked this pull request as draft July 28, 2026 09:43
@Stanley-Lee-glitch
Stanley-Lee-glitch marked this pull request as ready for review July 28, 2026 09:46
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.

1 participant