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
1 changed files with 4 additions and 1 deletions

View File

@ -82,7 +82,10 @@ class Entry(object):
else:
return "Expected parameter '" + name + "' with unit '" + unit.to_string() + "' but got no unit."
if not attr.unit.is_equivalent(unit):
return "Expected parameter '" + name + "' with unit equivalent to '" + unit.to_string() + \
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