From 6af0771ca8459f006a41802fdc2a200717f72a4a Mon Sep 17 00:00:00 2001 From: mrava87 Date: Wed, 12 Feb 2025 20:23:57 +0000 Subject: [PATCH] bug: missing cols in callback of omp solver This commit changes the signature of the callback of the omp solver, which provided only the non-zero coefficients (in x) without their indices - added now in the second input parameter (col). --- pylops/optimization/cls_sparsity.py | 2 +- pylops/optimization/sparsity.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pylops/optimization/cls_sparsity.py b/pylops/optimization/cls_sparsity.py index 8a82a71a..fb5366be 100644 --- a/pylops/optimization/cls_sparsity.py +++ b/pylops/optimization/cls_sparsity.py @@ -914,7 +914,7 @@ def run( else False ) x, cols = self.step(x, cols, showstep) - self.callback(x) + self.callback(x, cols) return x, cols def finalize( diff --git a/pylops/optimization/sparsity.py b/pylops/optimization/sparsity.py index 40c56047..f612aa1b 100644 --- a/pylops/optimization/sparsity.py +++ b/pylops/optimization/sparsity.py @@ -166,8 +166,9 @@ def omp( and every N3 steps in between where N1, N2, N3 are the three element of the list. callback : :obj:`callable`, optional - Function with signature (``callback(x)``) to call after each iteration - where ``x`` is the current model vector + Function with signature (``callback(x, cols)``) to call after each iteration + where ``x`` contains the non-zero model coefficient and ``cols`` are the + indices where the current model vector is non-zero Returns -------