summaryrefslogtreecommitdiffstats
path: root/glucometerutils/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'glucometerutils/common.py')
-rw-r--r--glucometerutils/common.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/glucometerutils/common.py b/glucometerutils/common.py
index 31584b4..318fc86 100644
--- a/glucometerutils/common.py
+++ b/glucometerutils/common.py
@@ -28,7 +28,7 @@ class MeasurementMethod(enum.Enum):
CGM = 'CGM' # Continuous Glucose Monitoring
-def convert_glucose_unit(value, from_unit, to_unit=None):
+def convert_glucose_unit(value, from_unit, to_unit):
"""Convert the given value of glucose level between units.
Args:
@@ -38,14 +38,14 @@ def convert_glucose_unit(value, from_unit, to_unit=None):
Returns:
The converted representation of the blood glucose level.
-
- Raises:
- exceptions.InvalidGlucoseUnit: If the parameters are incorrect.
"""
+ from_unit = Unit(from_unit)
+ to_unit = Unit(to_unit)
+
if from_unit == to_unit:
return value
- if from_unit is Unit.MG_DL:
+ if from_unit == Unit.MG_DL:
return round(value / 18.0, 2)
else:
return round(value * 18.0, 0)