Skip to content

Fix issue where glucose values outside of guardrails could be selected.#527

Merged
ps2 merged 4 commits into
devfrom
mmol-glucose-bounds
Feb 19, 2024
Merged

Fix issue where glucose values outside of guardrails could be selected.#527
ps2 merged 4 commits into
devfrom
mmol-glucose-bounds

Conversation

@ps2

@ps2 ps2 commented Feb 19, 2024

Copy link
Copy Markdown
Collaborator

Also fixes the crash described here: LoopKit/Loop#1864

@marionbarker

Copy link
Copy Markdown
Contributor

This does "fix" the crash but it also changes the minimum and maximum ranges available in mmol/L.
After applying this patch, the minimum and maximum range is reduced

  • before, the picker allowed 4.8 to 10.0 but would not allow single value correction settings that were at the minumum or maximum, i.e., 4.8-4.8 or 10.0-10.0
  • after, the picker allowed range is limited in 4.9 to 9.9 mmol/L
  • note the Glucose Safety lower limit remains at 3.7 mmol/L
mmol/L mg/dL
3.7 66.7
4.8 86.4
4.9 88.2
9.9 178.2
10.0 180.0

@ps2

ps2 commented Feb 19, 2024

Copy link
Copy Markdown
Collaborator Author

Yes, some previous values that appeared to be "acceptable" were actually below/above the guardrail values, due to rounding, causing this crash. As discussed in other tickets, making the guardrails configurable at a build level would be the way to allow the range to be extended.

@ps2 ps2 merged commit 7b639a5 into dev Feb 19, 2024
@ps2 ps2 deleted the mmol-glucose-bounds branch February 19, 2024 18:09
PorkShoulderHolder pushed a commit to replicahealth/LoopKit that referenced this pull request Feb 21, 2024
* [LOOP-4681] initial meals main screen UI; tab bar updates
loopkitdev pushed a commit to loopkitdev/LoopKit that referenced this pull request Jun 10, 2026
Three tests carried expectations that no longer match the tidepool-synced
LoopAlgorithm / LoopQuantity behavior the workspace now pins. None are
regressions:

- GuardrailTests.testMinCorrectionRangeValue / testPreMealCorrectionRange:
  expected 86.1 / 66.1, the deliberately-offset constants from LoopKit#527
  ("glucose values outside guardrails could be selected"). LoopKit#459
  ("Swift package prep") reverted the constants to clean 87 / 67 and
  moved boundary selectability into GlucoseValuePicker; these two test
  values were the only leftovers (testCorrectionRange already expects
  87). Updated to 87 / 67.

- LoopMathTests.testDecayEffect: decayEffect is now a continuous function
  of the (unaligned) sample timestamp, so the 10:13:20 sample interpolates
  instead of snapping to the 5-minute grid. (testDecayEffectWithEvenGlucose,
  aligned to :00, was already passing.) Updated to the continuous values
  with accuracy comparison.

- InsulinMathTests.testAppendedUnionOfPumpEvents: called filterDateRange
  on intentionally-unsorted pump events; filterDateRange now binary-searches
  and asserts ascending order. Production already sorts before any
  filterDateRange (DoseStore.getNormalizedPumpEventDoseEntries does
  reconciled().sorted), so the test now sorts its input to exercise the
  same precondition.

LoopKitTests: 459 tests, 0 failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants