Skip to content

[BUG] error in error message when unknown strategy for FISTA #220

Description

@mathurinm

System setup
With the develop branch

Describe the bug
Passing an unknown restart strategy to ForwardBackward does not say it is unknown, but raises a lower level error.

File ~/workspace/ModOpt/modopt/opt/algorithms/forward_backward.py:106, in FISTA.__init__(self, restart_strategy, min_beta, s_greedy, xi_restart, a_cd, p_lazy, q_lazy, r_lazy, **kwargs)
    102 else:
    103     message = 'Restarting strategy must be one of {0}.'
    104     raise ValueError(
    105         message.format(
--> 106             ', '.join(self._restarting_strategies),
    107         ),
    108     )
    109 self._t_now = 1.0
    110 self._t_prev = 1.0

TypeError: sequence item 6: expected str instance, NoneType found

To Reproduce

import numpy as np

from modopt.opt.algorithms import ForwardBackward
from modopt.opt.proximity import SparseThreshold
from modopt.opt.linear import Identity
from modopt.opt.gradient import GradBasic


X = np.random.randn(10, 20)
y = np.random.randn(10)

lmbd = 0.5 * np.max(np.abs(X.T @ y))

restart_strategy = "nonexistentstrategy"
min_beta = None
s_greedy = None
p_lazy = 1 / 30
q_lazy = 1 / 10


def op(w):
    return X @ w


fb = ForwardBackward(
    x=np.zeros(X.shape[1]),
    grad=GradBasic(
        input_data=y, op=op,
        trans_op=lambda res: X.T@res,
        input_data_writeable=True,
    ),
    prox=SparseThreshold(Identity(), lmbd),
    beta_param=1.0,
    min_beta=min_beta,
    metric_call_period=None,
    restart_strategy=restart_strategy,
    xi_restart=0.96,
    s_greedy=s_greedy,
    p_lazy=p_lazy,
    q_lazy=q_lazy,
    auto_iterate=False,
    progress=False,
    cost=None,
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions