From 09390e7ffb6c29be156b91336f3828b84369a3b8 Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Tue, 15 Dec 2015 09:39:28 +0000 Subject: [PATCH] daq: Fixed bug where an exception would be raised if merge_channles=False --- wlauto/instrumentation/daq/__init__.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/wlauto/instrumentation/daq/__init__.py b/wlauto/instrumentation/daq/__init__.py index 3e3517b6..21ad3200 100644 --- a/wlauto/instrumentation/daq/__init__.py +++ b/wlauto/instrumentation/daq/__init__.py @@ -303,16 +303,17 @@ class Daq(Instrument): except ConfigurationError, ex: raise ConfigError('DAQ configuration: ' + ex.message) # Re-raise as a WA error self.grouped_suffixes = defaultdict(str) - if isinstance(self.merge_channels, bool) and self.merge_channels: - # Create a dict of potential prefixes and a list of their suffixes - grouped_suffixes = {label[:-1]: label for label in sorted(self.labels) if len(label) > 1} - # Only merge channels if more than one channel has the same prefix and the prefixes - # are consecutive letters starting with 'a'. - self.label_map = {} - for channel, suffixes in grouped_suffixes.iteritems(): - if len(suffixes) > 1: - if "".join([s[-1] for s in suffixes]) in ascii_lowercase[:len(suffixes)]: - self.label_map[channel] = suffixes + if isinstance(self.merge_chnnels, bool): + if self.merge_channels: + # Create a dict of potential prefixes and a list of their suffixes + grouped_suffixes = {label[:-1]: label for label in sorted(self.labels) if len(label) > 1} + # Only merge channels if more than one channel has the same prefix and the prefixes + # are consecutive letters starting with 'a'. + self.label_map = {} + for channel, suffixes in grouped_suffixes.iteritems(): + if len(suffixes) > 1: + if "".join([s[-1] for s in suffixes]) in ascii_lowercase[:len(suffixes)]: + self.label_map[channel] = suffixes elif isinstance(self.merge_channels, dict): # Check if given channel names match labels @@ -323,7 +324,7 @@ class Daq(Instrument): self.label_map = self.merge_channels # pylint: disable=redefined-variable-type self.merge_channels = True else: # Should never reach here - raise AssertionError("Merge files is of invalid type") + raise AssertionError("``merge_channels`` is of invalid type") def before_overall_results_processing(self, context): if self._results: