From fc9bcc0ec21034f3e3fd848a85db2c7c4dbb8c65 Mon Sep 17 00:00:00 2001 From: Daveismus <55088389+Daveismus@users.noreply.github.com> Date: Fri, 30 Aug 2024 10:26:07 +0200 Subject: [PATCH] Add Hack for stats.IQR get method for avoiding panicking (#1603) Co-authored-by: David Brielbeck --- river/stats/iqr.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/river/stats/iqr.py b/river/stats/iqr.py index c5d56c38de..583a1260a3 100644 --- a/river/stats/iqr.py +++ b/river/stats/iqr.py @@ -61,6 +61,10 @@ def update(self, x): self._is_updated = True def get(self): + # HACK: Avoid crash if get is called before update + # panicked at 'index out of bounds: the len is 0 but the index is 0' + if not self._is_updated: + return None return self._iqr.get() def __repr__(self):