Handle equivalency of Celsius and Kelvin

This commit is contained in:
Lukas Klass 2020-07-20 16:27:59 +02:00
parent af38be02bf
commit a55fff0d35

View File

@ -82,6 +82,9 @@ class Entry(object):
else:
return "Expected parameter '" + name + "' with unit '" + unit.to_string() + "' but got no unit."
if not attr.unit.is_equivalent(unit):
if unit == u.K and attr.unit == u.Celsius:
setattr(self, name, attr.to(u.K, equivalencies=u.temperature()))
else:
return "Expected parameter '" + name + "' with unit equivalent to '" + unit.to_string() + \
"' but got unit '" + attr.unit.to_string() + "'."
return None