Skip to content

Conversation

@jorenham
Copy link
Member

@jorenham jorenham commented Jul 5, 2025

This fixes several issues in scipy.sparse.linalg.LinearOperator (docs), and closes #703.

  • worked around a mypy issue (overloaded __new__ ignored when introducing __init__ python/mypy#17251) that caused mypy to falsely reject calls to LinearOperator, and will now correctly return a _CustomLinearOperator.
  • .adjoint() and .H now return the correct LinearOperator specialization
  • fixed contravariance issue in the LinearOperator.__new__ annotations for the custom mat* functions.
  • avoid returning dtype union types for complex input in the public LinearOperator method.

@jorenham jorenham added this to the 1.16.0.3 milestone Jul 5, 2025
@jorenham jorenham merged commit babe194 into master Jul 5, 2025
19 checks passed
@jorenham jorenham deleted the scipy.linalg.LinearOperator.__new__/gh-703 branch July 5, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support sparse.linalg.LinearOperator subclass construction in __new__ by passing matvec

2 participants