1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-04-05 09:20:03 +01:00

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.
This commit is contained in:
Marc Bonnici 2017-08-02 16:59:10 +01:00
parent 9b465c2766
commit 5ef99f2cff

View File

@ -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))