Skip to content

Commit

Permalink
Merge pull request LoopKit#336 from LoopKit/dev
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
ps2 authored Dec 24, 2016
2 parents a659638 + 73b7302 commit 4637aba
Show file tree
Hide file tree
Showing 139 changed files with 2,108 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8
osx_image: xcode8.1
# xcode_sdk: iphonesimulator10.0
# xcode_project: Loop.xcodeproj
# xcode_scheme: Loop
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ github "LoopKit/xDripG5" ~> 0.8.0
github "i-schuetz/SwiftCharts" ~> 0.5.0
github "mddub/dexcom-share-client-swift" ~> 0.2.0
github "mddub/G4ShareSpy" ~> 0.3.1
github "ps2/rileylink_ios" ~> 0.12.6
github "ps2/rileylink_ios" ~> 0.12.9
github "amplitude/Amplitude-iOS" ~> 3.8.5
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github "amplitude/Amplitude-iOS" "v3.10.0"
github "amplitude/Amplitude-iOS" "v3.11.1"
github "mddub/G4ShareSpy" "v0.3.1"
github "LoopKit/LoopKit" "v1.1.0"
github "i-schuetz/SwiftCharts" "0.5"
github "i-schuetz/SwiftCharts" "0.5.1"
github "mddub/dexcom-share-client-swift" "v0.2.0"
github "ps2/rileylink_ios" "v0.12.6"
github "ps2/rileylink_ios" "v0.12.9"
github "LoopKit/xDripG5" "v0.8.0"
Binary file modified Carthage/Build/iOS/Amplitude.framework/Amplitude
Binary file not shown.
38 changes: 38 additions & 0 deletions Carthage/Build/iOS/Amplitude.framework/Headers/Amplitude.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Carthage/Build/iOS/Amplitude.framework/Info.plist
Binary file not shown.
Binary file modified Carthage/Build/iOS/CarbKit.framework/CarbKit
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/CarbKit.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/Crypto.framework/Crypto
Binary file not shown.
Binary file modified Carthage/Build/iOS/Crypto.framework/Info.plist
Binary file not shown.
Binary file modified Carthage/Build/iOS/G4ShareSpy.framework/G4ShareSpy
Binary file not shown.
Binary file modified Carthage/Build/iOS/G4ShareSpy.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/GlucoseKit.framework/GlucoseKit
Binary file not shown.
Binary file modified Carthage/Build/iOS/GlucoseKit.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/InsulinKit.framework/Info.plist
Binary file not shown.
Binary file modified Carthage/Build/iOS/InsulinKit.framework/InsulinKit
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/LoopKit.framework/Assets.car
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/LoopKit.framework/Info.plist
Binary file not shown.
Binary file modified Carthage/Build/iOS/LoopKit.framework/LoopKit
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/LoopKit.framework/TextFieldTableViewCell.nib
Binary file not shown.
Binary file modified Carthage/Build/iOS/MinimedKit.framework/Info.plist
Binary file not shown.
Binary file modified Carthage/Build/iOS/MinimedKit.framework/MinimedKit
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/NightscoutUploadKit.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/RileyLinkBLEKit.framework/Info.plist
Binary file not shown.
Binary file modified Carthage/Build/iOS/RileyLinkBLEKit.framework/RileyLinkBLEKit
Binary file not shown.
Binary file modified Carthage/Build/iOS/RileyLinkKit.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/RileyLinkKit.framework/RileyLinkKit
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/ShareClient.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/ShareClient.framework/ShareClient
Binary file not shown.
Binary file modified Carthage/Build/iOS/SwiftCharts.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/SwiftCharts.framework/SwiftCharts
Binary file not shown.
Binary file modified Carthage/Build/iOS/xDripG5.framework/Info.plist
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Carthage/Build/iOS/xDripG5.framework/xDripG5
Binary file not shown.
119 changes: 27 additions & 92 deletions DoseMathTests/DoseMathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,6 @@ class RecommendTempBasalTests: XCTestCase {
basalRateSchedule: basalRateSchedule
)

XCTAssertEqual(0, dose!.rate)
XCTAssertEqual(TimeInterval(minutes: 30), dose!.duration)

dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: nil,
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
allowPredictiveTempBelowRange: true
)

XCTAssertNil(dose)

let lastTempBasal = DoseEntry(
Expand All @@ -180,8 +167,7 @@ class RecommendTempBasalTests: XCTestCase {
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
allowPredictiveTempBelowRange: true
basalRateSchedule: basalRateSchedule
)

XCTAssertEqual(0, dose!.rate)
Expand All @@ -191,69 +177,16 @@ class RecommendTempBasalTests: XCTestCase {
func testCorrectLowAtMin() {
let glucose = loadGlucoseValueFixture("recommend_temp_basal_correct_low_at_min")

var dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: nil,
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule
)

XCTAssertEqualWithAccuracy(0.125, dose!.rate, accuracy: 1.0 / 40.0)
XCTAssertEqual(TimeInterval(minutes: 30), dose!.duration)

// Ignore due to existing dose
var lastTempBasal = DoseEntry(
type: .tempBasal,
startDate: glucose.first!.startDate.addingTimeInterval(TimeInterval(minutes: -11)),
endDate: glucose.first!.startDate.addingTimeInterval(TimeInterval(minutes: 19)),
value: 0.125,
unit: .unitsPerHour
)

dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: lastTempBasal,
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule
)

XCTAssertNil(dose)

// Cancel existing dose
lastTempBasal = DoseEntry(
type: .tempBasal,
startDate: glucose.first!.startDate.addingTimeInterval(TimeInterval(minutes: -11)),
endDate: glucose.first!.startDate.addingTimeInterval(TimeInterval(minutes: 19)),
value: 1.225,
unit: .unitsPerHour
)

dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: lastTempBasal,
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule
)

XCTAssertEqualWithAccuracy(0.125, dose!.rate, accuracy: 1.0 / 40.0)
XCTAssertEqual(TimeInterval(minutes: 30), dose!.duration)

// Continue existing dose
lastTempBasal = DoseEntry(
var lastTempBasal = DoseEntry(
type: .tempBasal,
startDate: glucose.first!.startDate.addingTimeInterval(TimeInterval(minutes: -21)),
endDate: glucose.first!.startDate.addingTimeInterval(TimeInterval(minutes: 9)),
value: 0.125,
unit: .unitsPerHour
)

dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
var dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: lastTempBasal,
maxBasalRate: maxBasalRate,
Expand All @@ -262,8 +195,8 @@ class RecommendTempBasalTests: XCTestCase {
basalRateSchedule: basalRateSchedule
)

XCTAssertEqualWithAccuracy(0.125, dose!.rate, accuracy: 1.0 / 40.0)
XCTAssertEqual(TimeInterval(minutes: 30), dose!.duration)
XCTAssertEqual(0, dose!.rate)
XCTAssertEqual(TimeInterval(minutes: 0), dose!.duration)

// Allow predictive temp below range
dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
Expand All @@ -272,8 +205,7 @@ class RecommendTempBasalTests: XCTestCase {
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
allowPredictiveTempBelowRange: true
basalRateSchedule: basalRateSchedule
)

XCTAssertNil(dose)
Expand All @@ -292,8 +224,7 @@ class RecommendTempBasalTests: XCTestCase {
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
allowPredictiveTempBelowRange: true
basalRateSchedule: basalRateSchedule
)

XCTAssertEqual(0, dose!.rate)
Expand All @@ -319,6 +250,7 @@ class RecommendTempBasalTests: XCTestCase {
func testStartLowEndHigh() {
let glucose = loadGlucoseValueFixture("recommend_temp_basal_start_low_end_high")

// Allow predictive temp below range
var dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: nil,
Expand All @@ -328,20 +260,6 @@ class RecommendTempBasalTests: XCTestCase {
basalRateSchedule: basalRateSchedule
)

XCTAssertEqual(0, dose!.rate)
XCTAssertEqual(TimeInterval(minutes: 30), dose!.duration)

// Allow predictive temp below range
dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: nil,
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
allowPredictiveTempBelowRange: true
)

XCTAssertNil(dose)

let lastTempBasal = DoseEntry(
Expand All @@ -358,8 +276,7 @@ class RecommendTempBasalTests: XCTestCase {
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule,
allowPredictiveTempBelowRange: true
basalRateSchedule: basalRateSchedule
)

XCTAssertEqual(0, dose!.rate)
Expand Down Expand Up @@ -445,6 +362,23 @@ class RecommendTempBasalTests: XCTestCase {
XCTAssertEqual(TimeInterval(minutes: 30), dose!.duration)
}

func testVeryLowAndRising() {
let glucose = loadGlucoseValueFixture("recommend_tamp_basal_very_low_end_in_range")

let dose = DoseMath.recommendTempBasalFromPredictedGlucose(glucose,
atDate: glucose.first!.startDate,
lastTempBasal: nil,
maxBasalRate: maxBasalRate,
glucoseTargetRange: glucoseTargetRange,
insulinSensitivity: self.insulinSensitivitySchedule,
basalRateSchedule: basalRateSchedule
)

XCTAssertEqual(0.0, dose!.rate)
XCTAssertEqual(TimeInterval(minutes: 30), dose!.duration)
}


func testNoInputGlucose() {
let dose = DoseMath.recommendTempBasalFromPredictedGlucose([],
lastTempBasal: nil,
Expand Down Expand Up @@ -712,4 +646,5 @@ class RecommendBolusTests: XCTestCase {

XCTAssertEqual(0, dose)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{"date": "2015-07-19T18:00:00", "amount": 60},
{"date": "2015-07-19T18:30:00", "amount": 50},
{"date": "2015-07-19T19:00:00", "amount": 60},
{"date": "2015-07-19T19:30:00", "amount": 70},
{"date": "2015-07-19T20:00:00", "amount": 100}
]
2 changes: 1 addition & 1 deletion DoseMathTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.2</string>
<string>1.2.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Loading

0 comments on commit 4637aba

Please sign in to comment.