P2.2 Analytic disk potentials: backend-agnostic namespace-swap#894
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/backends #894 +/- ##
===============================================
Coverage 99.92% 99.92%
===============================================
Files 228 228
Lines 34213 34405 +192
Branches 712 708 -4
===============================================
+ Hits 34186 34379 +193
+ Misses 27 26 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Complete the backend-agnostic migration of the analytic disk family so the entire files (not just the main compute methods) are free of numpy. in the compute path: - KuzminDiskPotential._mass: numpy.sqrt -> xp.sqrt; drop unused numpy import. - RazorThinExponentialDiskPotential._mass: numpy.pi/numpy.exp -> math.pi/xp.exp. _z2deriv: numpy.infty (deprecated) -> math.inf. Bessel/quadrature methods (_evaluate, _Rforce, _zforce, _R2deriv) remain scipy.special-blocked (i0/i1/k0/k1/kn/iv) and are left as-is. - MiyamotoNagaiPotential: replace the numpy-only scalar fast-paths (`xp is numpy and isinstance(R, float) and sqrtbz == asqrtbz`) in _zforce, _dens, _z2deriv, _Rzderiv with a backend-agnostic config branch on `self._a == 0.0`. This is the a==0 simplification; it equals the general formula to ULP for b>0 and avoids the general formula's 0/0 (asqrtbz/sqrtbz) at the a==0, b==0, z==0 singular point under all backends (previously NaN for arrays, finite only for numpy scalars). Leftover numpy. in these files is config-time-only (leggauss nodes, astropy unit parsing, scalar setup constants) or genuinely scipy.special. Tests (tests/test_backend_disk.py): add numpy/jax/torch parity + grad-vs-FD for the migrated _mass methods, z==0 kink parity for Kuzmin _zforce/_Rzderiv/_z2deriv, MiyamotoNagai a==0 branch parity, and finite-value parity at the MiyamotoNagai a==0,b==0,z==0 singular point. Full module: 181 passed (numpy+jax+torch); numpy potential sanity (forceAsDeriv, 2ndDeriv, mass_axi, mass_axi_negz, poisson_surfdens) all pass with the C ext built. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jobovy
added a commit
that referenced
this pull request
Jun 10, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jobovy
added a commit
that referenced
this pull request
Jun 12, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jobovy
added a commit
that referenced
this pull request
Jun 13, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jobovy
added a commit
that referenced
this pull request
Jun 15, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jobovy
added a commit
that referenced
this pull request
Jun 17, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jobovy
added a commit
that referenced
this pull request
Jun 19, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jobovy
added a commit
that referenced
this pull request
Jun 19, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jobovy
added a commit
that referenced
this pull request
Jun 25, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
Part of the P2.x potential namespace-swap series (→ #892).
Migrated: MiyamotoNagai, KuzminDisk, FlattenedPower, IsothermalDisk, KGPotential, RazorThinExponentialDisk (
_surfdens). MN3ExponentialDisk is backend-agnostic transitively (delegates to MN).Deferred: KuzminKutuzovStaeckel (coords transform — out of family scope), RingPotential (ellipk/ellipe), RazorThin forces (Bessel), DoubleExponentialDisk (scipy).
Hazards fixed: MN
isinstance(R,float)a==0 fast-path gated onxp is numpy(numpy byte-identical; tracers always take the general autodiff-safe formula);numpy.fabs→xp.abs(torch);numpy.pi→math.pi.Tests:
tests/test_backend_disk.py— 138 passed (numpy/jax/torch parity + grad-vs-FD). Numpy path byte-identical.🤖 Generated with Claude Code