From 7937635ca25e8d2a82ddc5e89bfbe0ae3ba0e429 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Mon, 6 Dec 2021 15:02:15 +0000 Subject: [PATCH] feat: check for name doublers in Obs.__init__ optimized --- pyerrors/obs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyerrors/obs.py b/pyerrors/obs.py index c1fcc8ca..38faa276 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -74,8 +74,10 @@ class Obs: if idl is not None: if len(idl) != len(names): raise Exception('Length of idl incompatible with samples and names.') - if len(names) != len(set(names)): - raise Exception('names are not unique.') + name_length = len(names) + 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 min(len(x) for x in samples) <= 4: