Skip to content

df.streamspraydf: allow callable, time-dependent progenitor_mass#880

Open
jobovy wants to merge 1 commit into
mainfrom
streamspraydf-massfn
Open

df.streamspraydf: allow callable, time-dependent progenitor_mass#880
jobovy wants to merge 1 commit into
mainfrom
streamspraydf-massfn

Conversation

@jobovy
Copy link
Copy Markdown
Owner

@jobovy jobovy commented May 12, 2026

Summary

  • progenitor_mass on basestreamspraydf / chen24spraydf / fardal15spraydf now accepts either a scalar/Quantity (existing behaviour) or a callable M(t) of the progenitor-time coordinate (t=0 is now, t<0 is past).
  • Quantity input and/or output of the callable are auto-detected with the four-branch pattern from AnyAxisymmetricRazorThinDiskPotential.
  • Internally the value is stored as self._progenitor_mass_fn and evaluated at each particle's stripping time in _calc_rtide and in the Chen24 escape-velocity calculation. The legacy self._progenitor_mass attribute is kept, pinned to the present-day mass.
  • New tests in tests/test_streamspraydf.py (callable=scalar equivalence, evolving-mass tidal-radius scaling, attribute back-compat, vectorisation) and in tests/test_quantity.py (all three Quantity in/out combinations, both spray models).
  • Tutorial notebook gains a worked example contrasting constant-mass and growing-mass progenitors.

Test plan

  • pytest tests/test_streamspraydf.py — 27 passed
  • pytest tests/test_quantity.py -k 'streamspraydf or progmass' — 7 passed (3 new + 4 existing)
  • jupyter nbconvert --to notebook --execute --inplace doc/source/tutorials/streams/streamspraydf.ipynb — executes cleanly
  • pre-commit hooks pass

🤖 Generated with Claude Code

`progenitor_mass` now accepts either a scalar/Quantity (existing
behaviour) or a callable `M(t)` of the progenitor-time coordinate
(t=0 = now, t<0 = past). Quantity input and/or output are
auto-detected with the same four-branch pattern used by
`AnyAxisymmetricRazorThinDiskPotential`.

Internally the value is stored as `self._progenitor_mass_fn`, evaluated
at the per-particle stripping time in `_calc_rtide` and in
`chen24spraydf.spray_df`'s escape-velocity calculation. The legacy
`self._progenitor_mass` attribute is retained, pinned to the present-day
mass for backward compatibility.

Tests added in test_streamspraydf.py (callable=scalar equivalence,
evolving-mass tidal-radius scaling, attribute back-compat,
array-input vectorisation) and in test_quantity.py for all three
Quantity in/out combinations. Tutorial notebook gains a worked example.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.92%. Comparing base (9d0d8c5) to head (37c5b2e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #880   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files         225      225           
  Lines       33875    33911   +36     
  Branches      710      710           
=======================================
+ Hits        33848    33884   +36     
  Misses         27       27           

☔ View full report in Codecov by Sentry.
📢 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.

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