From 2eebf83ff6ed630ba0dead46a591105e3eee6985 Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Fri, 22 Dec 2023 00:47:38 -0600 Subject: [PATCH] Fix center Spread logic to work as intended instead of just returning one index --- control/control_sparsectrl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control/control_sparsectrl.py b/control/control_sparsectrl.py index 5328cac..c3bb217 100644 --- a/control/control_sparsectrl.py +++ b/control/control_sparsectrl.py @@ -144,7 +144,7 @@ class SparseSpreadMethod(SparseMethod): if full_length-hint_length < 3: return list(np.linspace(0, full_length-1, hint_length+1, endpoint=True, dtype=int))[:-1] # otherwise, get linspace of 2 greater than needed, then cut off first and last - return list(np.linspace(0, full_length-1, hint_length, endpoint=True, dtype=int))[1:-1] + return list(np.linspace(0, full_length-1, hint_length+2, endpoint=True, dtype=int))[1:-1] return ValueError(f"Unrecognized spread: {self.spread}")