Commit a571caa2 authored by payno's avatar payno
Browse files

[MetricSystem] add __str__ function

parent f30087b6
Pipeline #41116 passed with stages
in 19 minutes and 12 seconds
......@@ -124,6 +124,28 @@ class MetricSystem(_Enum):
else:
raise ValueError("Cannot convert: %s" % value)
def __str__(self):
if self == MetricSystem.METER:
return "m"
elif self == MetricSystem.CENTIMETER:
return "cm"
elif self == MetricSystem.MILLIMETER:
return "mm"
elif self == MetricSystem.MICROMETER:
return "um"
elif self == MetricSystem.NANOMETER:
return "nm"
elif self == MetricSystem.KILOELECTRONVOLT:
return "keV"
elif self == MetricSystem.ELECTRONVOLT:
return "eV"
elif self == MetricSystem.JOULE:
return "J"
elif self == MetricSystem.KILOJOULE:
return "kJ"
else:
raise ValueError("Cannot convert: %s" % value)
m = MetricSystem.METER
meter = MetricSystem.METER
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment