def explanation(self): min_unit = None for question in self.question.answers: normalized = convert.to_normalized(question.unit, 1) if min_unit is None or convert.to_normalized(min_unit, 1) > normalized: min_unit = question.unit if min_unit and min_unit != self.unit: converted_value = convert.convert(self.unit, self.value, min_unit) if converted_value.magnitude > 0.001: return convert.format_quantity(converted_value) else: # the value is below the required precision so we cannot use it return None else: return None
def normalized_value(self): return convert.to_normalized(self.unit, self.value)