Fixes to Python module#264
Merged
Merged
Conversation
… so power equals -3 no longer divides by zero
…lass-level list and declare AmbientMedium.star before freezing
… it operate on grid quantities instead of the nonexistent data attribute while returning the AMR grid passed in
… decremented sample count
astrofrog
force-pushed
the
python-frontend-fixes
branch
from
July 26, 2026 22:53
752d14f to
97c7a95
Compare
astrofrog
marked this pull request as ready for review
July 27, 2026 08:32
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.
This fixes a few bugs with the Python package:
power = -3— the mass↔ρ₀ conversion computed(rmax**alpha - rmin**alpha) / alphawithalpha = 3 + power, dividing by zero atpower = -3. Routed throughintegrate_powerlaw, which handles the limit.FreezableClassper-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 declaresAmbientMedium.starbefore freezing (required once the registry is per-instance).zero_density(AMR) —zmindefaulted to+inf, so the reset mask covered every cell and zeroed the whole grid; it also referenced a nonexistentdataattribute. Now defaults sensibly, operates on the grid's quantities, and returns the grid passed in.evaluate_function_average— divided the last cell's sample sum by a decremented count, biasing (or zeroing) that cell's average. Count corrected._discretize_sphC extension leaks —_get_positions_widthsnever 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.n_zwalls instead ofn_z + 1, producing one fewer cell than requested and failing outright for smalln_z. Now produces exactlyn_zcells and reacheszmax.