From a7f98cc5a5272f366ce9d56c8507a4501be5b183 Mon Sep 17 00:00:00 2001 From: Philipp Schlegel Date: Sun, 10 Jan 2021 16:14:06 +0000 Subject: [PATCH] neurons.has_...: fix issue with empty data --- navis/core/neurons.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/navis/core/neurons.py b/navis/core/neurons.py index b11b43ef..fef01be9 100644 --- a/navis/core/neurons.py +++ b/navis/core/neurons.py @@ -151,14 +151,19 @@ def __getattr__(self, key): key = key[key.index('_') + 1:] if hasattr(self, key): data = getattr(self, key) - if isinstance(data, pd.DataFrame) and not data.empty: - return True + if isinstance(data, pd.DataFrame): + if not data.empty: + return True + else: + return False # This is necessary because np.any does not like strings elif isinstance(data, str): if data == 'NA' or not data: return False return True - elif np.any(data): + elif utils.is_iterable(data) and len(data) > 0: + return True + elif data: return True return False elif key.startswith('n_'):