Skip to content

refactor: move Abstract/AutoLinearOperator to separate files to avoid circular imports - #233

Merged
jpbrodrick89 merged 3 commits into
devfrom
jpb/refactor-AbstractLinearSolver
Jun 27, 2026
Merged

refactor: move Abstract/AutoLinearOperator to separate files to avoid circular imports#233
jpbrodrick89 merged 3 commits into
devfrom
jpb/refactor-AbstractLinearSolver

Conversation

@jpbrodrick89

@jpbrodrick89 jpbrodrick89 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

@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/

Comment thread lineax/_solve.py Outdated
@jpbrodrick89 jpbrodrick89 added the refactor Tidy things up label Jun 23, 2026
@patrick-kidger

Copy link
Copy Markdown
Owner

No strong feelings! Seems reasonable to me :)

@jpbrodrick89
jpbrodrick89 merged commit 2a4f654 into dev Jun 27, 2026
1 check passed
@patrick-kidger
patrick-kidger deleted the jpb/refactor-AbstractLinearSolver branch June 27, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Tidy things up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants