fix: raise the documented TypeError for wrong-type design and local_solver - #250
Merged
Conversation
…olver The .pyi documents TypeError for a wrong-type argument, but two paths disagreed. extract_design mapped a failed Effect-list extraction through value_err, so solve/solve_batch/Solver raised ValueError for a design that is neither a 2-D uint32 array nor a list of Effect. And AdditiveSchwarz typed local_solver as Option<Py<PyAny>>, accepting any object at construction and deferring the TypeError to the downcast inside extract_preconditioner_config at solve time. Typing the field Option<Py<PyLocalSolverConfig>> makes PyO3 generate the check at construction, which retires the manual downcast branch. LocalSolverConfig is not subclassable, so the accepted set is unchanged: no input that previously succeeded now fails, only already-failing paths change how they fail.
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.
Closes #248.
solve/solve_batch/SolverraisedValueErrorfor adesignthat is neither a 2-Duint32array nor a list ofEffect, andAdditiveSchwarzaccepted any object aslocal_solver, deferring theTypeErrorto solve time. Both now raise theTypeErrorthe stub already documents, andlocal_solveris validated at construction.Typing the field
Option<Py<PyLocalSolverConfig>>moves the check into PyO3's generated argument extraction, which retires the manual downcast inextract_preconditioner_config._within.pyineeded no change — it was already correct on both counts.LocalSolverConfigis not subclassable, so the accepted set is unchanged: no input that previously succeeded now fails. The four new tests were verified to fail against the pre-fix binary (ValueErrorfordesign,DID NOT RAISEfor the constructor).