From 5ef99f2cff14f00da46d9ca011acdee8b5596779 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Wed, 2 Aug 2017 16:59:10 +0100 Subject: [PATCH] Instrument/MeasurementType: Allow for converting to the same type When trying to convert measurments to a standarised type some inputs may already be of the correct type and will now return the same value unchanged. --- devlib/instrument/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devlib/instrument/__init__.py b/devlib/instrument/__init__.py index f1a89e0..46f9c3e 100644 --- a/devlib/instrument/__init__.py +++ b/devlib/instrument/__init__.py @@ -48,6 +48,8 @@ class MeasurementType(object): if not isinstance(to, MeasurementType): msg = 'Unexpected conversion target: "{}"' raise ValueError(msg.format(to)) + if to.name == self.name: + return value if not to.name in self.conversions: msg = 'No conversion from {} to {} available' raise ValueError(msg.format(self.name, to.name))