From 1f91175e50be85b3701b3909fcc64a853ff8c066 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 6 Dec 2021 15:20:36 +0000 Subject: [PATCH] feat: check for non string names in Obs.__init__ optimized --- pyerrors/obs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyerrors/obs.py b/pyerrors/obs.py index 38faa276..c6c97197 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -78,8 +78,11 @@ class Obs: if name_length > 1: if name_length != len(set(names)): raise Exception('names are not unique.') - if not all(isinstance(x, str) for x in names): - raise TypeError('All names have to be strings.') + if not all(isinstance(x, str) for x in names): + raise TypeError('All names have to be strings.') + else: + if not isinstance(names[0], str): + raise TypeError('All names have to be strings.') if min(len(x) for x in samples) <= 4: raise Exception('Samples have to have at least 5 entries.')