From 1e54660e75b5254317c5947671c793fb802793f9 Mon Sep 17 00:00:00 2001 From: GeorgiosEfstathiadis <54844705+GeorgeEfstathiadis@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:56:24 -0500 Subject: [PATCH] Add check for length of input in preprocess_bout (#235) --- forest/oak/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/forest/oak/base.py b/forest/oak/base.py index a2e484e6..3fccb03e 100644 --- a/forest/oak/base.py +++ b/forest/oak/base.py @@ -55,6 +55,13 @@ def preprocess_bout(t_bout: np.ndarray, x_bout: np.ndarray, y_bout: np.ndarray, - t_bout_interp: resampled timestamp (in Unix) - vm_bout_interp: vector magnitude of acceleration """ + + if ( + len(t_bout) < 2 or len(x_bout) < 2 or + len(y_bout) < 2 or len(z_bout) < 2 + ): + return np.array([]), np.array([]) + t_bout_interp = t_bout - t_bout[0] t_bout_interp = np.arange(t_bout_interp[0], t_bout_interp[-1], (1/fs)) t_bout_interp = t_bout_interp + t_bout[0]