Skip to content

Commit e432821

Browse files
miriamkwclaude
andcommitted
Fix cross-platform compilation and API compatibility
- Resolved type compatibility issues between macOS and Linux - Fixed get_loop_recommendations function return type (string vs bytes) - Used mixed types approach for getDynamicCarbsOnBoard (Double for carbRatio, LoopQuantity for ISF) - 15/16 tests now pass on macOS (only getDynamicCarbsOnBoard has remaining unit conversion issue) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3d8f7d4 commit e432821

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

Sources/LoopAlgorithmToPython/LoopAlgorithmToPython.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ public func getDynamicCarbsOnBoard(jsonData: UnsafePointer<Int8>?) -> Double {
438438
let startDate = dateFormatter.date(from: input.inputICE[0].startAt)!
439439
let endDate = dateFormatter.date(from: input.inputICE.last!.startAt)!
440440

441-
// Create schedule values with Double values as expected by the function
441+
// Mixed types: Double for carbRatio, LoopQuantity for ISF (as required by API)
442442
let carbRatio = [AbsoluteScheduleValue(startDate: startDate, endDate: endDate, value: input.carbRatio)]
443-
let isf = [AbsoluteScheduleValue(startDate: startDate, endDate: endDate, value: input.sensitivity)]
443+
let isf = [AbsoluteScheduleValue(startDate: startDate, endDate: endDate, value: LoopQuantity(unit: LoopUnit(from: "mg/dL"), doubleValue: input.sensitivity))]
444444

445445
let statuses = [carbEntries[0]].map(
446446
to: inputICE,

loop_to_python_api/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ def get_loop_recommendations(json_file, len=72):
148148
swift_lib.getLoopRecommendations.argtypes = [ctypes.c_char_p]
149149
swift_lib.getLoopRecommendations.restype = ctypes.c_char_p
150150

151-
return swift_lib.getLoopRecommendations(json_bytes)
151+
result = swift_lib.getLoopRecommendations(json_bytes).decode('utf-8')
152+
return result
152153

153154
def add_insulin_counteraction_effect_to_df(df, basal, isf, cr, insulin_type='novolog', batch_size=300, overlap=72):
154155
"""
271 KB
Binary file not shown.

0 commit comments

Comments
 (0)