From 4d801520ab22c3b421582c7ef03a20b432b26747 Mon Sep 17 00:00:00 2001 From: mrava87 Date: Mon, 15 Dec 2025 21:51:12 +0000 Subject: [PATCH] patch: fix https://github.com/PyLops/pyproximal/issues/230 --- pyproximal/proximal/L1.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pyproximal/proximal/L1.py b/pyproximal/proximal/L1.py index 6849d74..6fbf6bc 100644 --- a/pyproximal/proximal/L1.py +++ b/pyproximal/proximal/L1.py @@ -51,13 +51,17 @@ class L1(ProxOperator): r"""L1 norm proximal operator. Proximal operator of the :math:`\ell_1` norm: - :math:`\sigma\|\mathbf{x} - \mathbf{g}\|_1 = \sigma \sum |x_i - g_i|`. + + - :math:`\sigma\|\mathbf{x} - \mathbf{g}\|_1 = \sigma \sum_i |x_i - g_i|` for + 1-dimensional arrays; + - :math:`\sum_j \sigma_j \|\mathbf{X}_j - \mathbf{g}\|_1 = \sum_j \sigma_j \sum_i |x_{i,j} - g_i|` + for 2-dimensional arrays. Parameters ---------- sigma : :obj:`float` or :obj:`np.ndarray` or :obj:`func`, optional Multiplicative coefficient of L1 norm. This can be a constant number, a list - of values (for multidimensional inputs, acting on the second dimension) or + of values (for 2-dimensional inputs, acting on the second dimension) or a function that is called passing a counter which keeps track of how many times the ``prox`` method has been invoked before and returns a scalar (or a list of) ``sigma`` to be used. @@ -117,8 +121,8 @@ def __init__( def __call__(self, x: NDArray) -> float: sigma = _current_sigma(self.sigma, self.count) if self.g is None: - return float(sigma * np.sum(np.abs(x))) - return float(sigma * np.sum(np.abs(x - self.g))) + return float(np.sum(sigma * np.sum(np.abs(x), axis=0))) + return float(np.sum(sigma * np.sum(np.abs(x - self.g), axis=0))) def _increment_count(func: Callable[..., Any]) -> Callable[..., Any]: """Increment counter"""