Conversation
- Result.positions_likelihood_from: when PYAUTO_TEST_MODE is active and the
resolved positions are empty / contain NaN / contain inf, substitute
[(1.0, 0.0), (-1.0, 0.0)] so the threshold and PositionsLH still build.
Outside test mode the behaviour is unchanged.
- PointSolver.solve: when PYAUTO_SMALL_DATASETS=1, return [(1.0, 0.0),
(0.0, 1.0)] immediately and skip the triangle-tiling solve. Lets simulator
scripts drop their os.environ.pop("PYAUTO_SMALL_DATASETS") workarounds.
- Adds one unit test for the test-mode fallback path.
Closes #477.
This was referenced Apr 28, 2026
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace#102 |
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
Fixes a
ValueError: zero-size array to reduction operation fmaxinResult.positions_likelihood_fromwhenPYAUTO_TEST_MODE=2produces unphysical mass models that back-trace to empty / NaN image-plane positions. Also collapses theos.environ.pop("PYAUTO_SMALL_DATASETS")workaround that simulator scripts use aroundPointSolver.solveby short-circuiting the solver itself when small-datasets mode is on.Closes #477.
API Changes
No public API signature changes. Two test-mode-only behavior additions, both gated on env vars and inert in production:
Result.positions_likelihood_fromnow substitutes[(1.0, 0.0), (-1.0, 0.0)]whenPYAUTO_TEST_MODEis set and the resolved positions are empty / NaN / inf.PointSolver.solvenow short-circuits to[(1.0, 0.0), (0.0, 1.0)]whenPYAUTO_SMALL_DATASETS=1is set, skipping the triangle-tiling solve.Outside test mode / smoke-test mode neither branch is reached. See full details below.
Test Plan
test__positions_likelihood_from__test_mode_fallbackexercises the empty-positions path withPYAUTO_TEST_MODE=2.test_autolens/analysis/test_result.pyandtest_autolens/point/triangles/suites still pass (21 tests).PYAUTO_TEST_MODE=2 python scripts/imaging/features/pixelization/delaunay.pyno longer crashes at the originalresult.py:333error site (a separate downstreamborder_relocator.py:450bug surfaces, tracked separately).PYAUTO_SMALL_DATASETS=1— workspace cleanup PR will remove theos.environ.popworkarounds.Full API Changes (for automation & release notes)
Removed
Added
Renamed
Changed Signature
Changed Behaviour
autolens.analysis.result.Result.positions_likelihood_from— whenPYAUTO_TEST_MODEis set (any non-zero value) and the resolvedpositionsarray is empty (shape[0] < 2), or contains NaN, or contains inf, substitutes the synthetic pair[(1.0, 0.0), (-1.0, 0.0)]and emits a singlelogger.warningbefore computing the threshold. Outside test mode no change.autolens.point.solver.point_solver.PointSolver.solve— whenPYAUTO_SMALL_DATASETS=1is set, returnsaa.Grid2DIrregular(values=[(1.0, 0.0), (0.0, 1.0)])immediately, skippingsuper().solve_triangles(...)and downstream filtering. Outside small-datasets mode no change.Migration
PointSolver.solvewithos.environ.pop("PYAUTO_SMALL_DATASETS", None)/ restore can now delete that workaround. A follow-up workspace PR removes it fromscripts/group/simulator.py,scripts/group/features/multi_gaussian_expansion/simulator.py, andscripts/group/features/no_lens_light/simulator.py.🤖 Generated with Claude Code