Skip to content

Early validation of jac argument of `JacobianLinearOperator#167

Merged
patrick-kidger merged 2 commits intopatrick-kidger:mainfrom
jpbrodrick89:jpb/validate_jac_early
Jun 28, 2025
Merged

Early validation of jac argument of `JacobianLinearOperator#167
patrick-kidger merged 2 commits intopatrick-kidger:mainfrom
jpbrodrick89:jpb/validate_jac_early

Conversation

@jpbrodrick89
Copy link
Contributor

As discussed in #166 the static jac kwarg of JacobianLinearOperator is now validated in __init__ to fail fast. Should I remove the later validation in the methods? My gut feel is it's safer to keep them in, just in case self.jac is incorrectly modified.

PS I'm not sure why ruff relinted in the way it did, my initial draft was:

        assert jac in [None, "fwd", "bwd"], (
            f"jac argument of JacobianLinearOperator must be fwd, bwd or None, got {jac}"
       )

but it got re-formatted.

Copy link
Owner

@patrick-kidger patrick-kidger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this! Nits aside this LGTM.

As for Ruff, it pretty-formats using the Wadler-Lindig algorithm internally; this leads to a waterfall-then-horizontal approach to laying things out.

@patrick-kidger patrick-kidger merged commit 51f54cb into patrick-kidger:main Jun 28, 2025
2 checks passed
@patrick-kidger
Copy link
Owner

Awesome, LGTM! Thanks for the contribution, and merged :)

jpbrodrick89 added a commit to jpbrodrick89/lineax that referenced this pull request Jan 27, 2026
…k-kidger#167)

* Early validation of `jac` argument of `JacobianLinearOperator

* address nits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants