Skip to content

fix: resample invalid profile parameters - #568

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/profile-validation-resample-recovery
Aug 10, 2026
Merged

fix: resample invalid profile parameters#568
Jammy2211 merged 1 commit into
mainfrom
feature/profile-validation-resample-recovery

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Introduce a profile-validation exception that remains a conventional ValueError for direct API users while also being a PyAutoFit FitException.

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 both ValueError and autofit.exc.FitException. Existing ValueError handling 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 -s shipping gate
Full 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 raise ModelParameterException instead of bare ValueError.
  • autogalaxy.profiles.validate.validate_sersic_index() — invalid concrete values raise ModelParameterException instead of bare ValueError.
  • autogalaxy.profiles.validate.validate_ell_comps() — invalid concrete values raise ModelParameterException instead of bare ValueError.
  • autogalaxy.profiles.validate.validate_redshift() — invalid concrete values raise ModelParameterException instead of bare ValueError.

Migration

  • No migration is required for callers catching ValueError; ModelParameterException remains a subclass of it.
  • PyAutoFit searches now treat these validation failures as rejected/resampled candidates.

Generated by the PyAutoLabs agent workflow.

@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autogalaxy_workspace#209

@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace#483

@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autogalaxy_workspace_test#104

@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace PR: PyAutoLabs/autolens_workspace_test#256

@Jammy2211
Jammy2211 merged commit be61b8d into main Aug 10, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/profile-validation-resample-recovery branch August 10, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant