Skip to content

♻️ refactor(potential): fit_log_spline uses interpax.approx_df again - #1091

Merged
nstarman merged 1 commit into
GalacticDynamics:mainfrom
nstarman:claude/interpax-0316-approx-df-eff539
Nov 23, 2026
Merged

nstarman merged 1 commit into
GalacticDynamics:mainfrom
nstarman:claude/interpax-0316-approx-df-eff539

Conversation

@nstarman

Copy link
Copy Markdown
Contributor

galax#1077 hand-wrote the not-a-knot tridiagonal solve in fit_log_spline because interpax.approx_df solved through lineax, which failed inside jax.shard_map once the values varied over a mapped axis while the knots did not. interpax 0.3.16 (released 2026-10-22) solves that system with jax.lax.linalg.tridiagonal_solve itself, so the workaround can go.

Changes

  • fit_log_spline returns interpax.approx_df(log_r, values, "cubic2", 0, bc_type="not-a-knot"). The inlined system and the n < 4 special case are removed. The docstring keeps the paragraph on why the end condition is not-a-knot, and notes that the shard_map case works from interpax 0.3.16 on.
  • interpax>=0.3.16 in galax.potential and galax.dynamics. uv.lock moves interpax 0.3.12 → 0.3.16, which adds jaxkd and drops interpax's own lineax dependency (diffrax still pulls in lineax).
  • Tests: test_knot_derivatives_inside_shard_map stays and now guards the interpax path. test_knot_derivatives_match_interpax is removed, since it would compare approx_df with itself. The CubicSpline equality test stays.

Checks

Follow-up (not in this PR)

eval_log_spline could become interpax.interp1d(..., "cubic", fx=..., extrap=True, even_spacing=True). That waits for f0uriest/interpax#213 to be released: today that path is ~10x slower than galax's helper, and with #213 it is ~3x faster.

Related interpax PRs from the same effort: f0uriest/interpax#210 (shard_map regression test) and f0uriest/interpax#211 (approx_df axis=-1 fix; galax passes axis=0, so it is unaffected).

🤖 Generated with Claude Code

interpax 0.3.16 solves the not-a-knot tridiagonal system with
`jax.lax.linalg.tridiagonal_solve` instead of `lineax`, so `approx_df`
works inside `jax.shard_map`. That removes the reason for the hand-written
solve added in GalacticDynamics#1077, and `fit_log_spline` now returns `approx_df`
directly. The interpax floor goes to 0.3.16 in galax.potential and
galax.dynamics; the lock moves interpax 0.3.12 -> 0.3.16 and adds jaxkd.

The shard_map test stays as the guard on the interpax path. The test that
compared `fit_log_spline` with `approx_df` is dropped, since the two are
now the same call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nstarman nstarman added this to the v0.2.0 milestone Nov 23, 2026
@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.27%. Comparing base (422d91a) to head (f5fed80).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1091      +/-   ##
==========================================
+ Coverage   98.20%   98.27%   +0.06%     
==========================================
  Files         214      219       +5     
  Lines        8685     9019     +334     
==========================================
+ Hits         8529     8863     +334     
  Misses        156      156              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nstarman
nstarman merged commit bebd33f into GalacticDynamics:main Nov 23, 2026
17 checks passed
@nstarman
nstarman deleted the claude/interpax-0316-approx-df-eff539 branch November 23, 2026 05:12
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