Skip to content

Fixes to Python module#264

Merged
astrofrog merged 6 commits into
hyperion-rt:mainfrom
astrofrog:python-frontend-fixes
Jul 27, 2026
Merged

Fixes to Python module#264
astrofrog merged 6 commits into
hyperion-rt:mainfrom
astrofrog:python-frontend-fixes

Conversation

@astrofrog

Copy link
Copy Markdown
Contributor

This fixes a few bugs with the Python package:

  • PowerLawEnvelope power = -3 — the mass↔ρ₀ conversion computed (rmax**alpha - rmin**alpha) / alpha with alpha = 3 + power, dividing by zero at power = -3. Routed through integrate_powerlaw, which handles the limit.
  • FreezableClass per-instance attributes — the attribute registry was a class-level list shared by every instance, so registered attributes leaked between instances (and the list grew unbounded), defeating the frozen-attribute check. Now per-instance; also declares AmbientMedium.star before freezing (required once the registry is per-instance).
  • zero_density (AMR)zmin defaulted to +inf, so the reset mask covered every cell and zeroed the whole grid; it also referenced a nonexistent data attribute. Now defaults sensibly, operates on the grid's quantities, and returns the grid passed in.
  • Voronoi evaluate_function_average — divided the last cell's sample sum by a decremented count, biasing (or zeroing) that cell's average. Count corrected.
  • _discretize_sph C extension leaks_get_positions_widths never released its input array and returned its six output arrays with "O" (which adds references) instead of "N" (which steals them), leaking all seven arrays per call. Reference handling corrected, plus error-path cleanup.
  • Cylindrical auto-grid z walls — built n_z walls instead of n_z + 1, producing one fewer cell than requested and failing outright for small n_z. Now produces exactly n_z cells and reaches zmax.

@astrofrog
astrofrog force-pushed the python-frontend-fixes branch from 752d14f to 97c7a95 Compare July 26, 2026 22:53
@astrofrog
astrofrog marked this pull request as ready for review July 27, 2026 08:32
@astrofrog
astrofrog merged commit e23855c into hyperion-rt:main Jul 27, 2026
22 checks passed
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