From cfd85e26c71b0996f43913f28c5c7c807dde1850 Mon Sep 17 00:00:00 2001 From: Amruta Wavdhane Date: Fri, 12 Jun 2026 12:54:31 +0530 Subject: [PATCH 1/2] fix(simplex): raise error instead of silent failure on max iterations --- linear_programming/simplex.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linear_programming/simplex.py b/linear_programming/simplex.py index a8affe1b72d2..a7b0d102b009 100644 --- a/linear_programming/simplex.py +++ b/linear_programming/simplex.py @@ -302,7 +302,9 @@ 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 4c2b04b031379e3318d6f29b4920e65085ee7dcf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 12 Jun 2026 07:25:43 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 a7b0d102b009..6762d4449506 100644 --- a/linear_programming/simplex.py +++ b/linear_programming/simplex.py @@ -304,7 +304,8 @@ def run_simplex(self) -> dict[Any, Any]: self.tableau = self.pivot(row_idx, col_idx) raise ValueError( f"Simplex did not converge within {Tableau.maxiter} iterations. " - "The problem may be cycling or unbounded.") + "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