Skip to content

Commit 1d9c4ba

Browse files
committed
doc: minor documentation improvements
1 parent d3fe7f1 commit 1d9c4ba

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

docs/source/addingsolver.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ note that the ``setup`` method returns the created starting guess ``x`` (does no
8383
.. code-block:: python
8484
8585
def setup(self, y, x0=None, niter=None, tol=1e-4, show=False):
86-
8786
self.y = y
8887
self.tol = tol
8988
self.niter = niter

pylops/optimization/callback.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,32 @@ class Callbacks:
2929
3030
All methods take two input parameters: the solver itself, and the vector ``x``.
3131
32-
Moreover, some callback may be used to implement custom stopping criteria for the solvers.
33-
This can be done by adding a boolean attribute `stop` to the callback object, which will
34-
be initially set to `False`. As soon as the callback sets this attribute to `True`, the
32+
Moreover, some callback may be used to implement custom stopping criteria for the solver.
33+
This can be done by adding a boolean attribute ``stop`` to the callback object, which will
34+
be initially set to ``False``. As soon as the callback sets this attribute to ``True``, the
3535
``run`` method of the solver will stop iterating and return the current model vector.
3636
3737
Examples
3838
--------
3939
>>> import numpy as np
4040
>>> from pylops.basicoperators import MatrixMult
41-
>>> from pylops.optimization.solver import CG
41+
>>> from pylops.optimization.basic import CG
4242
>>> from pylops.optimization.callback import Callbacks
43+
>>>
4344
>>> class StoreIterCallback(Callbacks):
4445
... def __init__(self):
4546
... self.stored = []
4647
... def on_step_end(self, solver, x):
4748
... self.stored.append(solver.iiter)
48-
>>> cb_sto = StoreIterCallback()
49+
>>>
4950
>>> Aop = MatrixMult(np.random.normal(0., 1., 36).reshape(6, 6))
5051
>>> Aop = Aop.H @ Aop
5152
>>> y = Aop @ np.ones(6)
53+
>>> cb_sto = StoreIterCallback()
5254
>>> cgsolve = CG(Aop, callbacks=[cb_sto, ])
5355
>>> xest = cgsolve.solve(y=y, x0=np.zeros(6), tol=0, niter=6, show=False)[0]
54-
>>> xest
55-
array([1., 1., 1., 1., 1., 1.])
56+
>>> xest, cb_sto.stored
57+
(array([1., 1., 1., 1., 1., 1.]), [1, 2, 3, 4, 5, 6])
5658
5759
"""
5860

pylops/optimization/cls_basic.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ def solve(
305305
niter : :obj:`int`, optional
306306
Number of iterations
307307
tol : :obj:`float`, optional
308-
Tolerance on residual norm
308+
Absolute tolerance on residual norm. Stops the solver when the
309+
residual norm is below this value.
309310
preallocate : :obj:`bool`, optional
310311
.. versionadded:: 2.6.0
311312
@@ -446,7 +447,8 @@ def setup(
446447
damp : :obj:`float`, optional
447448
Damping coefficient
448449
tol : :obj:`float`, optional
449-
Tolerance on residual norm
450+
Absolute tolerance on residual norm. Stops the solver when the
451+
residual norm is below this value.
450452
preallocate : :obj:`bool`, optional
451453
.. versionadded:: 2.6.0
452454
@@ -670,7 +672,8 @@ def solve(
670672
damp : :obj:`float`, optional
671673
Damping coefficient
672674
tol : :obj:`float`, optional
673-
Tolerance on residual norm
675+
Absolute tolerance on residual norm. Stops the solver when the
676+
residual norm is below this value.
674677
preallocate : :obj:`bool`, optional
675678
.. versionadded:: 2.6.0
676679

0 commit comments

Comments
 (0)