Replace jnp.interp with interpax.interp1d in thermo.py#24
Merged
cgiovanetti merged 1 commit intomainfrom Jan 28, 2026
Merged
Conversation
Follow-up to PR #16 which replaced jnp.interp with interpax in abundances.py. This change applies the same improvement to thermo.py for consistency and better performance. Changes: - Import interpax module - Flip QED correction tables at load time (instead of at each call) for monotonically increasing x coordinates required by interpax - Replace 6 jnp.interp calls with interpax.interp1d: - rho_EM_std: 2 calls for QED corrections - p_EM_std: 1 call for QED correction - rho_plus_p_EM_std: 1 call for QED correction - G_nue_with_me: 1 call for collision factor interpolation - G_numt_with_me: 1 call for collision factor interpolation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cgiovanetti
approved these changes
Jan 28, 2026
Owner
cgiovanetti
left a comment
There was a problem hiding this comment.
Checked timing is also improved with this change
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
Follow-up to #16 as suggested by @cgiovanetti. This PR replaces
jnp.interpwithinterpax.interp1dinthermo.pyfor consistency withabundances.pyand better performance.Changes:
jnp.interpcalls withinterpax.interp1d(0.0, 1.0)for collision factor tables (matching original behavior)Functions updated:
rho_EM_std: QED correctionsp_EM_std: QED correctionrho_plus_p_EM_std: QED correctionG_nue_with_me: Collision factor interpolationG_numt_with_me: Collision factor interpolationCaveat
For the collision factor interpolations (
G_nue_with_me,G_numt_with_me), the original code usedleft=f_tab[0,1], right=f_tab[-1,1]to extrapolate with boundary values. Sinceinterpax.interp1drequires theextrapparameter to be concrete values (not traced JAX arrays), I hardcodedextrap=(0.0, 1.0)based on the current data files:If these data files are ever updated with different boundary values, the hardcoded extrapolation values would need to be updated accordingly.
Test plan
pytest pytest/test_abundances.pypasses🤖 Generated with Claude Code