From 0d0b3c87debc8fac3c281426ea71ce1153167843 Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Mon, 13 Jun 2022 11:06:02 +0200 Subject: [PATCH 1/4] add small help for the metric argument. --- modopt/opt/algorithms/base.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/modopt/opt/algorithms/base.py b/modopt/opt/algorithms/base.py index b236013b..6caafed1 100644 --- a/modopt/opt/algorithms/base.py +++ b/modopt/opt/algorithms/base.py @@ -22,7 +22,7 @@ class SetUp(Observable): metric_call_period : int, optional Metric call period (default is ``5``) metrics : dict, optional - Metrics to be used (default is ``\{\}``) + Metrics to be used (default is ``None``) verbose : bool, optional Option for verbose output (default is ``False``) progress : bool, optional @@ -34,6 +34,30 @@ class SetUp(Observable): use_gpu : bool, optional Option to use available GPU + Notes + ----- + If provided, the ``metrics`` argument should be a nested dictionary of the + following form: + + ..code-block:: python + + metrics = { + "metric_name": { + "metric": callable, + "mapping": {"x_new": "test"}, + "cst_kwargs": {"ref": ref_image}, + "early_stopping": False, + } + } + + Where `callable` is a function with arguments being for instance + `test` and `ref`. The mapping of the argument uses the same keys as the + output of `get_notify_observer_kwargs`, `cst_kwargs` defines constant + arguments that will always be passed to the metric call. + If `early_stopping` is True, the metric will be used to check for + convergence of the algorithm, in that case it is recommended to have + ``metric_call_period = 1`` + See Also -------- modopt.base.observable.Observable : parent class From bed2cce9e426a14cff823d2d278f623a7da6057b Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Tue, 14 Jun 2022 12:47:26 +0200 Subject: [PATCH 2/4] RST validation --- modopt/opt/algorithms/base.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/modopt/opt/algorithms/base.py b/modopt/opt/algorithms/base.py index 6caafed1..b3d3f75a 100644 --- a/modopt/opt/algorithms/base.py +++ b/modopt/opt/algorithms/base.py @@ -12,7 +12,7 @@ class SetUp(Observable): - r"""Algorithm Set-Up. + """Algorithm Set-Up. This class contains methods for checking the set-up of an optimisation algorithm and produces warnings if they do not comply. @@ -37,18 +37,16 @@ class SetUp(Observable): Notes ----- If provided, the ``metrics`` argument should be a nested dictionary of the - following form: - - ..code-block:: python - - metrics = { - "metric_name": { - "metric": callable, - "mapping": {"x_new": "test"}, - "cst_kwargs": {"ref": ref_image}, - "early_stopping": False, + following form:: + + metrics = { + "metric_name": { + "metric": callable, + "mapping": {"x_new": "test"}, + "cst_kwargs": {"ref": ref_image}, + "early_stopping": False, + } } - } Where `callable` is a function with arguments being for instance `test` and `ref`. The mapping of the argument uses the same keys as the From 89bd52a59cba0c42f231177420df0daa13e0a932 Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Fri, 17 Jun 2022 15:09:38 +0200 Subject: [PATCH 3/4] use single quote --- modopt/opt/algorithms/base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modopt/opt/algorithms/base.py b/modopt/opt/algorithms/base.py index b3d3f75a..a2b57ec3 100644 --- a/modopt/opt/algorithms/base.py +++ b/modopt/opt/algorithms/base.py @@ -40,11 +40,11 @@ class SetUp(Observable): following form:: metrics = { - "metric_name": { - "metric": callable, - "mapping": {"x_new": "test"}, - "cst_kwargs": {"ref": ref_image}, - "early_stopping": False, + 'metric_name': { + 'metric': callable, + 'mapping': {'x_new': 'test'}, + 'cst_kwargs': {'ref': ref_image}, + 'early_stopping': False, } } From fc76042eebee1b9c77de50bc3557de12878d0410 Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Fri, 17 Jun 2022 15:09:53 +0200 Subject: [PATCH 4/4] use double backticks. --- modopt/opt/algorithms/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modopt/opt/algorithms/base.py b/modopt/opt/algorithms/base.py index a2b57ec3..c5a4b101 100644 --- a/modopt/opt/algorithms/base.py +++ b/modopt/opt/algorithms/base.py @@ -48,11 +48,11 @@ class SetUp(Observable): } } - Where `callable` is a function with arguments being for instance - `test` and `ref`. The mapping of the argument uses the same keys as the - output of `get_notify_observer_kwargs`, `cst_kwargs` defines constant + Where ``callable`` is a function with arguments being for instance + ``test`` and ``ref``. The mapping of the argument uses the same keys as the + output of ``get_notify_observer_kwargs``, ``cst_kwargs`` defines constant arguments that will always be passed to the metric call. - If `early_stopping` is True, the metric will be used to check for + If ``early_stopping`` is True, the metric will be used to check for convergence of the algorithm, in that case it is recommended to have ``metric_call_period = 1``