Skip to content

Commit 9516efe

Browse files
committed
Clearer input parameter validation for nonsmooth problems
1 parent 3a8a0f2 commit 9516efe

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

dfols/solver.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,16 +954,21 @@ def solve(objfun, x0, h=None, lh=None, prox_uh=None, argsf=(), argsh=(), argspro
954954

955955
exit_info = None
956956
# Input & parameter checks
957-
if exit_info is None and h is not None and (lh is None or lh <= 0.0):
958-
exit_info = ExitInformation(EXIT_INPUT_ERROR, "lh is not None and lh must be positive")
957+
if exit_info is None and h is not None:
958+
if prox_uh is None:
959+
exit_info = ExitInformation(EXIT_INPUT_ERROR, "Must provide prox_uh input if h is not None")
960+
elif lh is None:
961+
exit_info = ExitInformation(EXIT_INPUT_ERROR, "Must provide lh input if h is not None")
962+
elif lh <= 0.0:
963+
exit_info = ExitInformation(EXIT_INPUT_ERROR, "lh must be strictly positive")
959964

960965
if exit_info is None and npt < n + 1:
961966
exit_info = ExitInformation(EXIT_INPUT_ERROR, "npt must be >= n+1 for linear models with inexact interpolation")
962967

963-
if exit_info is None and rhobeg < 0.0:
968+
if exit_info is None and rhobeg <= 0.0:
964969
exit_info = ExitInformation(EXIT_INPUT_ERROR, "rhobeg must be strictly positive")
965970

966-
if exit_info is None and rhoend < 0.0:
971+
if exit_info is None and rhoend <= 0.0:
967972
exit_info = ExitInformation(EXIT_INPUT_ERROR, "rhoend must be strictly positive")
968973

969974
if exit_info is None and rhobeg <= rhoend:

0 commit comments

Comments
 (0)