From 753ba5f90e3ee38cf337ac954376fe1d21bbff9b Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 29 Oct 2021 12:38:34 +0100 Subject: [PATCH] order of idx check in Obs.__init__ exchanged to favor the standard case --- pyerrors/pyerrors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyerrors/pyerrors.py b/pyerrors/pyerrors.py index 89452b0a..ad7d752c 100644 --- a/pyerrors/pyerrors.py +++ b/pyerrors/pyerrors.py @@ -69,7 +69,9 @@ class Obs: self.idl = {} if 'idl' in kwargs: for name, idx in sorted(zip(names, kwargs.get('idl'))): - if isinstance(idx, (list, np.ndarray)): + if isinstance(idx, range): + self.idl[name] = idx + elif isinstance(idx, (list, np.ndarray)): dc = np.unique(np.diff(idx)) if np.any(dc < 0): raise Exception("Unsorted idx for idl[%s]" % (name)) @@ -77,8 +79,6 @@ class Obs: self.idl[name] = range(idx[0], idx[-1] + dc[0], dc[0]) else: self.idl[name] = list(idx) - elif type(idx) is range: - self.idl[name] = idx else: raise Exception('incompatible type for idl[%s].' % (name)) else: