Add ifail enum#4275
Open
chris-ashe wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4275 +/- ##
==========================================
+ Coverage 49.41% 49.45% +0.03%
==========================================
Files 151 151
Lines 29282 29304 +22
==========================================
+ Hits 14471 14493 +22
Misses 14811 14811 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a typed IntEnum for solver ifail exit conditions (SolverOutputCondition) and updates several runtime and test call sites to use the enum instead of hard-coded numeric values, improving readability and consistency around solver status handling.
Changes:
- Added
SolverOutputConditionenum to centralize solver output (ifail) codes. - Replaced
ifail == 1/ifail != 1checks withSolverOutputCondition.CONVERGEDin core, tracking, and vary-run utilities. - Updated regression/integration tests to assert against the enum values.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tracking/tracking_data.py | Uses SolverOutputCondition.CONVERGED for strict convergence checks when reading MFILEs. |
| tests/regression/test_process_input_files.py | Updates regression assertion to use SolverOutputCondition.CONVERGED. |
| tests/integration/test_vmcon.py | Replaces numeric ifail expectations with enum values. |
| process/data_structure/numerics.py | Adds the new SolverOutputCondition IntEnum definition. |
| process/core/solver/solver_handler.py | Uses enum values in VMCON retry logic and imports the enum. |
| process/core/scan.py | Uses enum values in optimisation/solver status reporting and VMCON error handling. |
| process/core/io/vary_run/tools.py | Uses enum values when determining feasibility/convergence from MFILE contents. |
| process/core/io/vary_run/config.py | Uses enum values to report convergence status and generate README status messages. |
| process/core/final.py | Uses enum value for final feasible/unfeasible output header selection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
73
to
74
| # First solution attempt failed (ifail != 1): supply ifail value | ||
| # to next attempt |
Comment on lines
+6
to
+9
| class SolverOutputCondition(IntEnum): | ||
| """Enum for the possible conditions that can be returned by the solvers. | ||
| This is for the `ifail` condition | ||
| """ |
Comment on lines
+13
to
+32
| IMPROPER_INPUT = 0 | ||
| """Solver failed due to improper input (e.g. invalid parameters, or failure to | ||
| satisfy solver preconditions)""" | ||
| CONVERGED = 1 | ||
| """Solver converged successfully""" | ||
|
|
||
| MAX_ITERATIONS = 2 | ||
| """Solver failed to converge within the maximum number of iterations""" | ||
|
|
||
| MAX_LINE_SEARCHES = 3 | ||
| """Line search required 10 function calls without finding a better solution""" | ||
|
|
||
| UPHILL_SEARCH = 4 | ||
| """Uphill search direction was calculated""" | ||
|
|
||
| NO_SOLUTION = 5 | ||
| """No feasible solution or bad approximation of Hessian""" | ||
|
|
||
| SINGLE_MATRIX_OR_BOUNDS = 6 | ||
| """Singular matrix in quadratic subproblem or restriction by artificial bounds""" |
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.
Description
Checklist
I confirm that I have completed the following checks: