Repository navigation
fix: galaxies_to_halo_arrays raises on max_n overflow, accepts max_n=None - #870
Merged
Merged
Conversation
…None A plane holding more halos than max_n used to drop the extras silently, while the negative-convergence sheets still removed their mass. Now an overflow raises a ValueError naming each plane, its count and the max_n needed, and max_n=None sizes the arrays to the fullest plane (across the whole batch in los_realizations_to_arrays). Adds halo_counts_per_plane_from. Closes #869 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 19, 2026
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.
Summary
galaxies_to_halo_arraysused to drop halos silently when a plane held more thanmax_nof them. The negative-convergence sheets are still computed for the full population, so the simulated image lost mass and nothing reported it. Measured onmaina79a6b2: a 1e6 M☉ line of sight dropped 3,708 of 10,389 halos atmax_n=1000.The fix changes three things:
max_nthat any plane exceeds raises aValueErrornaming each overflowing plane (index, redshift, halo count) and themax_nneeded.max_n=Nonesizes the arrays. The arrays are sized to the fullest plane. Inlos_realizations_to_arraysthat is the fullest plane across the whole batch, so every realisation shares a shape. An overflow there is prefixed with the realisation index.halo_counts_per_plane_fromlets callers pickmax_nup front.Callers that pass an integer
max_nlarge enough for every plane get identical arrays.Closes #869
Workspace
autolens_workspace's
los_halos/simulator_jax.pyused a fixedmax_n=200. With its own settings, the fullest plane holds 323–377 halos on every seed it draws (42, 100–107), so the example was silently dropping halos and would raise after this change. The companion workspace PR switches it tomax_n=None.Sibling
#868 (LOSSampler colossus) touches
los.pyandtest_los.pyonly. It has no overlap with this diff.Checks
mainfirst: 5 halos on one plane withmax_n=3kept 3 and raised nothing.test_autolens/lens/test_substructure_util.py, 10 passed (5 new; the witness istest__galaxies_to_halo_arrays__raises_when_a_plane_overflows_max_nand…__max_n_none_sizes_to_fullest_plane_and_keeps_every_halo).guides/galaxies.pyPASS.🤖 Generated with Claude Code