fix: resample invalid profile parameters - #568
Merged
Merged
Conversation
This was referenced Aug 10, 2026
Collaborator
Author
|
Workspace PR: PyAutoLabs/autogalaxy_workspace#209 |
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace#483 |
Collaborator
Author
|
Workspace PR: PyAutoLabs/autogalaxy_workspace_test#104 |
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace_test#256 |
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
Introduce a profile-validation exception that remains a conventional
ValueErrorfor direct API users while also being a PyAutoFitFitException.Apply it to scale-radius, Sersic-index, ellipticity-component, and redshift guards so physically invalid non-linear-search candidates are rejected through the existing resample path instead of terminating the search.
Add regression coverage for both the dual exception contract and PyAutoFit's returned resample figure of merit.
API Changes
Invalid concrete profile parameters now raise
autogalaxy.exc.ModelParameterException, a subclass of bothValueErrorandautofit.exc.FitException. ExistingValueErrorhandling remains compatible; model-fitting code now rejects these candidates through PyAutoFit's established resampling behavior.See full details below.
Test Plan
pytest -q -s test_autogalaxy/profiles/test_validate.py(41 passed)pytest -q -s test_autogalaxy(1090 passed, 4 skipped)python -m pytest test_autogalaxy/ -x -sshipping gateFull API Changes (for automation & release notes)
Added
autogalaxy.exc.ModelParameterException— reports physically invalid concrete model parameters while satisfying both direct-user and non-linear-search exception contracts.Changed Behaviour
autogalaxy.profiles.validate.validate_scale_radius()— invalid concrete values raiseModelParameterExceptioninstead of bareValueError.autogalaxy.profiles.validate.validate_sersic_index()— invalid concrete values raiseModelParameterExceptioninstead of bareValueError.autogalaxy.profiles.validate.validate_ell_comps()— invalid concrete values raiseModelParameterExceptioninstead of bareValueError.autogalaxy.profiles.validate.validate_redshift()— invalid concrete values raiseModelParameterExceptioninstead of bareValueError.Migration
ValueError;ModelParameterExceptionremains a subclass of it.Generated by the PyAutoLabs agent workflow.