Skip to content

doc: improved docstrings of MPILinearOperator and MPIStackedLinearOperator #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions pylops_mpi/LinearOperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,27 @@


class MPILinearOperator:
"""Common interface for performing matrix-vector products in distributed fashion.
"""MPI-enabled PyLops Linear Operator

This class provides methods to perform matrix-vector product and adjoint matrix-vector
products using MPI.
Common interface for performing matrix-vector products in distributed fashion.

.. note:: End users of pylops-mpi should not use this class directly but simply
use operators that are already implemented. This class is meant for
developers only, it has to be used as the parent class of any new operator
developed within pylops-mpi.
In practice, this class provides methods to perform matrix-vector and
adjoint matrix-vector products between any :obj:`pylops.LinearOperator`
(which must be the same across ranks) and a :class:`pylops_mpi.DistributedArray`
with ``Partition.BROADCAST`` and ``Partition.UNSAFE_BROADCAST`` partition. It
internally handles the extraction of the local array from the distributed array
and the creation of the output :class:`pylops_mpi.DistributedArray`.

Note that whilst this operator could also be used with different
:obj:`pylops.LinearOperator` across ranks, and with a
:class:`pylops_mpi.DistributedArray` with ``Partition.SCATTER``, it is however
reccomended to use the :class:`pylops_mpi.basicoperators.MPIBlockDiag` operator
instead as this can also handle distributed arrays with subcommunicators.

Parameters
----------
Op : :obj:`pylops.LinearOperator`, optional
Linear Operator. Defaults to ``None``.
PyLops Linear Operator to wrap. Defaults to ``None``.
shape : :obj:`tuple(int, int)`, optional
Shape of the MPI Linear Operator. Defaults to ``None``.
dtype : :obj:`str`, optional
Expand Down
18 changes: 11 additions & 7 deletions pylops_mpi/StackedLinearOperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@


class MPIStackedLinearOperator(ABC):
"""Common interface for performing matrix-vector products in distributed fashion
for StackedLinearOperators.
"""Stack of MPI-enabled PyLops Linear Operators

This class provides methods to perform matrix-vector product and adjoint matrix-vector
products on a stack of :class:`pylops_mpi.MPILinearOperator` objects.
Common interface for performing matrix-vector products in distributed fashion
for a stack of :class:`pylops_mpi.MPILinearOperator` operators.

In practice, this class provides methods to perform matrix-vector and adjoint
matrix-vector products on a stack of :class:`pylops_mpi.MPILinearOperator`
operators, allowing the actual execution of each operator to be distributed,
whilst dispatching the execution of the different operators in sequential order.

.. note:: End users of pylops-mpi should not use this class directly but simply
use operators that are already implemented. This class is meant for
developers only, it has to be used as the parent class of any new operator
developed within pylops-mpi.
use operators that are already implemented as extensions of this class.
This class is meant for developers only, it has to be used as the parent
class of any new stacked operator developed within pylops-mpi.

Parameters
----------
Expand Down