From 8af7709bd5ed37688f66f0642864959346147331 Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Mon, 11 May 2026 19:09:52 -0700 Subject: [PATCH 1/2] fix: raise ValueError when run_simplex exhausts maxiter Fixes #14584 Signed-off-by: SAY-5 --- linear_programming/simplex.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/linear_programming/simplex.py b/linear_programming/simplex.py index a8affe1b72d2..6762d4449506 100644 --- a/linear_programming/simplex.py +++ b/linear_programming/simplex.py @@ -302,7 +302,10 @@ def run_simplex(self) -> dict[Any, Any]: self.tableau = self.change_stage() else: self.tableau = self.pivot(row_idx, col_idx) - return {} + raise ValueError( + f"Simplex did not converge within {Tableau.maxiter} iterations. " + "The problem may be cycling or unbounded." + ) def interpret_tableau(self) -> dict[str, float]: """Given the final tableau, add the corresponding values of the basic From 9482f205d352350200c300b49552509f913a4844 Mon Sep 17 00:00:00 2001 From: SAY-5 Date: Tue, 12 May 2026 00:18:28 -0700 Subject: [PATCH 2/2] style: assign exception message to variable for EM102 --- linear_programming/simplex.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linear_programming/simplex.py b/linear_programming/simplex.py index 6762d4449506..4b1d916d31f7 100644 --- a/linear_programming/simplex.py +++ b/linear_programming/simplex.py @@ -302,10 +302,11 @@ def run_simplex(self) -> dict[Any, Any]: self.tableau = self.change_stage() else: self.tableau = self.pivot(row_idx, col_idx) - raise ValueError( + msg = ( f"Simplex did not converge within {Tableau.maxiter} iterations. " "The problem may be cycling or unbounded." ) + raise ValueError(msg) def interpret_tableau(self) -> dict[str, float]: """Given the final tableau, add the corresponding values of the basic