Skip to content

Commit 0a0aa52

Browse files
committed
feature: added option for multiple rhs sigmas in L1
1 parent 0835b1a commit 0a0aa52

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pyproximal/proximal/L1.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _softthreshold(x, thresh):
3434

3535

3636
def _current_sigma(sigma, count):
37-
if isinstance(sigma, (int, float)):
37+
if not callable(sigma):
3838
return sigma
3939
else:
4040
return sigma(count)
@@ -48,11 +48,12 @@ class L1(ProxOperator):
4848
4949
Parameters
5050
----------
51-
sigma : :obj:`int`, optional
52-
Multiplicative coefficient of L1 norm. This can be a constant number or
51+
sigma : :obj:`float` or :obj:`list` or :obj:`np.ndarray` or :obj:`func`, optional
52+
Multiplicative coefficient of L1 norm. This can be a constant number, a list
53+
of values (for multidimensional inputs, acting on the second dimension) or
5354
a function that is called passing a counter which keeps track of how many
54-
times the ``prox`` method has been invoked before and
55-
returns the ``sigma`` to be used.
55+
times the ``prox`` method has been invoked before and returns a scalar (or a list of)
56+
``sigma`` to be used.
5657
g : :obj:`np.ndarray`, optional
5758
Vector to be subtracted
5859
@@ -95,7 +96,7 @@ def __init__(self, sigma=1., g=None):
9596
self.sigma = sigma
9697
self.g = g
9798
self.gdual = 0 if g is None else g
98-
if isinstance(sigma, (int, float)):
99+
if not callable(sigma):
99100
self.box = BoxProj(-sigma, sigma)
100101
else:
101102
self.box = BoxProj(-sigma(0), sigma(0))

0 commit comments

Comments
 (0)