From 21723b0d0b97a71aad8aafeb5d413015b2909320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Thu, 28 Dec 2017 12:23:54 +0000 Subject: accucheck_reports: fix bug for mg/dL native meters. This was mixing up the units in the conversion. While fixing the bug, remove the confusing two-parameter form of convert_glucose_unit. --- glucometerutils/common.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'glucometerutils/common.py') 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) -- cgit v1.2.3