refactor: move Abstract/AutoLinearOperator to separate files to avoid circular imports - #233
Merged
Merged
Conversation
jpbrodrick89
commented
Jun 18, 2026
Owner
|
No strong feelings! Seems reasonable to me :) |
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.
@patrick-kidger the current setup has been causing me headaches trying to come up with more elegant designs for the jvp fast paths I tried out in #217 (such as creating private type aliases for subsets of solvers in _solve.py for type hinting and isinstance checking that depend on having access to solvers at module level). Moving AbstractLinearOperator solves a lot as it depends on nothing. We now have the much cleaner dependency tree
AbstractLinearOperator (now in _solver/base.py) -> concrete solvers (in _solver/) -> AutoLinearSolver (now in _solver/auto.py) -> linear_solve(_p) (still in _solve.py)
Is there any good reason not to move AbstractLinearOperator to its own file? It seems to clean up a lot. There is now just one circular import in GMRES which uses linear_solve internally which is generally a case worth special treatment (and actually one on the laundry list of moderate inefficiencies to address).
Moving AutoLinearSolver doesn't actually solve any problem, I just couldn't see a reason not to do it and I like the conceptual neatness of having all solvers in
_solver/