From 91add666e7553c004ba13053b63ed24b4f435eb3 Mon Sep 17 00:00:00 2001 From: briandesilva Date: Sat, 26 Dec 2020 13:02:08 -0800 Subject: [PATCH] Bug fix: Fix Koopman.predict for 1D inputs --- pykoopman/koopman.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pykoopman/koopman.py b/pykoopman/koopman.py index 21ee2fb..d37d2e5 100644 --- a/pykoopman/koopman.py +++ b/pykoopman/koopman.py @@ -194,7 +194,7 @@ def simulate(self, x0, u=None, n_steps=1): y = empty((n_steps, self.n_input_features_), dtype=self.koopman_matrix.dtype) if u is None: y[0] = self.predict(x0) - elif u is not None: + else: y[0] = self.predict(x0, u[0]) if isinstance(self.observables, TimeDelay): @@ -207,10 +207,12 @@ def simulate(self, x0, u=None, n_steps=1): else: if u is None: for k in range(n_steps - 1): - y[k + 1] = self.predict(y[k]) + y[k + 1] = self.predict(y[k].reshape(1, -1)) else: for k in range(n_steps - 1): - y[k + 1] = self.predict(y[k], u[k + 1]) + y[k + 1] = self.predict( + y[k].reshape(1, -1), u[k + 1].reshape(1, -1) + ) return y