Protocols¶
This module provides various protocols used throughout the package.
A typing.Protocol is an interface that a class can fulfill structurally, without
explicitly inheriting from it. For example, any class that implements a __len__ method
satisfies Sized, whether or not it says so anywhere in its class hierarchy.
The protocols in this module follow the same idea, but each one centers on a single, otherwise
unremarkable dunder-style method (for example _linear_operator_). A class implementing that
one method thereby satisfies the corresponding protocol – SupportsLinearOperator in
this example – and becomes usable wherever that protocol is expected, without any explicit
registration. Note that “protocol” is sometimes also used loosely to refer to the type-agnostic
dispatch function built on top of a protocol (for example linear_operator()) rather than
the interface itself; the distinction should be clear from context.
Most protocols below follow this pattern paired with a small, type-agnostic helper function that dispatches to the protocol method on whatever object it is given:
Protocol |
Method |
Helper function |
|---|---|---|
|
||
|
||
|
||
|
||
|
– |
|
|
|
A mirror of the |
|
A package-specific extension of |
|
A Protocol indicating support for efficient commutator generation. |
|
An equivalent of the |
|
A mirror of the |
|
An equivalent of the |