Skip to content

Commit f10f910

Browse files
committed
doc: improved docstrings of MPILinearOperator and MPIStackedLinearOperator
1 parent f1bc646 commit f10f910

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

pylops_mpi/LinearOperator.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,27 @@
1212

1313

1414
class MPILinearOperator:
15-
"""Common interface for performing matrix-vector products in distributed fashion.
15+
"""MPI-enabled PyLops Linear Operator
1616
17-
This class provides methods to perform matrix-vector product and adjoint matrix-vector
18-
products using MPI.
17+
Common interface for performing matrix-vector products in distributed fashion.
1918
20-
.. note:: End users of pylops-mpi should not use this class directly but simply
21-
use operators that are already implemented. This class is meant for
22-
developers only, it has to be used as the parent class of any new operator
23-
developed within pylops-mpi.
19+
In practice, this class provides methods to perform matrix-vector and
20+
adjoint matrix-vector products between any :obj:`pylops.LinearOperator`
21+
(which must be the same across ranks) and a :class:`pylops_mpi.DistributedArray`
22+
with ``Partition.BROADCAST`` and ``Partition.UNSAFE_BROADCAST`` partition. It
23+
internally handles the extraction of the local array from the distributed array
24+
and the creation of the output :class:`pylops_mpi.DistributedArray`.
25+
26+
Note that whilst this operator could also be used with different
27+
:obj:`pylops.LinearOperator` across ranks, and with a
28+
:class:`pylops_mpi.DistributedArray` with ``Partition.SCATTER``, it is however
29+
reccomended to use the :class:`pylops_mpi.basicoperators.MPIBlockDiag` operator
30+
instead as this can also handle distributed arrays with subcommunicators.
2431
2532
Parameters
2633
----------
27-
Op : :obj:`pylops.LinearOperator`, optional
28-
Linear Operator. Defaults to ``None``.
34+
Op : :obj:`pylops.LinearOperator`
35+
PyLops Linear Operator to wrap.
2936
shape : :obj:`tuple(int, int)`, optional
3037
Shape of the MPI Linear Operator. Defaults to ``None``.
3138
dtype : :obj:`str`, optional
@@ -35,7 +42,7 @@ class MPILinearOperator:
3542
3643
"""
3744

38-
def __init__(self, Op: Optional[LinearOperator] = None, shape: Optional[ShapeLike] = None,
45+
def __init__(self, Op: LinearOperator, shape: Optional[ShapeLike] = None,
3946
dtype: Optional[DTypeLike] = None, base_comm: MPI.Comm = MPI.COMM_WORLD):
4047
if Op:
4148
self.Op = Op

pylops_mpi/StackedLinearOperator.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@
1111

1212

1313
class MPIStackedLinearOperator(ABC):
14-
"""Common interface for performing matrix-vector products in distributed fashion
15-
for StackedLinearOperators.
14+
"""Stack of MPI-enabled PyLops Linear Operators
1615
17-
This class provides methods to perform matrix-vector product and adjoint matrix-vector
18-
products on a stack of :class:`pylops_mpi.MPILinearOperator` objects.
16+
Common interface for performing matrix-vector products in distributed fashion
17+
for a stack of :class:`pylops_mpi.MPILinearOperator` operators.
18+
19+
In practice, this class provides methods to perform matrix-vector and adjoint
20+
matrix-vector products on a stack of :class:`pylops_mpi.MPILinearOperator`
21+
operators, allowing the actual execution of each operator to be distributed,
22+
whilst dispatching the execution of the different operators in sequential order.
1923
2024
.. note:: End users of pylops-mpi should not use this class directly but simply
21-
use operators that are already implemented. This class is meant for
22-
developers only, it has to be used as the parent class of any new operator
23-
developed within pylops-mpi.
25+
use operators that are already implemented as extensions of this class.
26+
This class is meant for developers only, it has to be used as the parent
27+
class of any new stacked operator developed within pylops-mpi.
2428
2529
Parameters
2630
----------

0 commit comments

Comments
 (0)