Skip to content

Commit c7ba8c3

Browse files
committed
implement load data for Libre and Dexcom devices
1 parent ef0fad3 commit c7ba8c3

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

iglu_python/extension/load_data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def load_libre(file_path: str) -> pd.Series:
5454
# Convert 'time' column to datetime
5555
df['time'] = pd.to_datetime(df['time'], format=format)
5656

57+
# Convert glucose values to numeric
58+
df['glc'] = pd.to_numeric(df['glc'], errors='coerce')
59+
5760
# convert to mg/dL if needed
5861
if convert:
5962
df['glc'] = df['glc'] * 18.01559

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "iglu_python"
7-
version = "0.2.1"
7+
version = "0.2.4"
88
description = "Python implementation of the iglu package for continuous glucose monitoring data analysis"
99
readme = "README.md"
1010
requires-python = ">=3.11"

tests/test_load_data.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,18 @@ def test_load_dexcom_time_interval(test_data_paths):
197197
tolerance = pd.Timedelta(minutes=2) # Allow some variation
198198
# Check that most intervals are close to expected
199199
close_intervals = time_diffs[abs(time_diffs - expected_interval) <= tolerance]
200-
assert len(close_intervals) / len(time_diffs) > 0.8 # At least 80% should be close
200+
assert len(close_intervals) / len(time_diffs) > 0.8 # At least 80% should be close
201+
202+
def test_load_libre_numeric_values(test_data_paths):
203+
timeseries = load_libre(str(test_data_paths['libre_amer_01']))
204+
# Check that all values are numeric
205+
assert pd.api.types.is_numeric_dtype(timeseries)
206+
# Check that there are no NaN values (all should be valid numbers)
207+
assert not timeseries.isna().any()
208+
209+
def test_load_dexcom_numeric_values(test_data_paths):
210+
timeseries = load_dexcom(str(test_data_paths['dexcom_eur_01']))
211+
# Check that all values are numeric
212+
assert pd.api.types.is_numeric_dtype(timeseries)
213+
# Check that there are no NaN values (all should be valid numbers)
214+
assert not timeseries.isna().any()

0 commit comments

Comments
 (0)