From 7393ab757e6ce4ab31ff8a71e741180444769e5f Mon Sep 17 00:00:00 2001 From: Ionela Voinescu Date: Fri, 8 Dec 2017 10:00:05 +0000 Subject: [PATCH] instrument: convert channel labels in valid Python identifiers Channel labels can contain punctuation which is not accepted in Python identifiers. Signed-off-by: Ionela Voinescu --- devlib/instrument/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devlib/instrument/__init__.py b/devlib/instrument/__init__.py index 0d2c1ed..f7c9ea1 100644 --- a/devlib/instrument/__init__.py +++ b/devlib/instrument/__init__.py @@ -18,6 +18,7 @@ import logging import collections from devlib.utils.types import numeric +from devlib.utils.types import identifier # Channel modes describe what sort of measurement the instrument supports. @@ -172,7 +173,8 @@ class MeasurementsCsv(object): if self.channels is None: self._load_channels() headings = [chan.label for chan in self.channels] - self.data_tuple = collections.namedtuple('csv_entry', headings) + self.data_tuple = collections.namedtuple('csv_entry', + map(identifier, headings)) def measurements(self): return list(self.iter_measurements())