Skip to content

Cone of uncertainty: cap to shortest predBG array to match Trio #637

@bjorkert

Description

@bjorkert

Background

The cone of uncertainty for Trio predictions is currently rendered out to the longest of the available predBG arrays (ZT, IOB, COB, UAM).

Graphs.swift (in updateOpenAPSPredictionDisplay()):

let maxLength = min(allArrays.map { $0.count }.max()!, toLoad + 1)

At indices past the end of a shorter array, that array simply stops contributing to min/max. This causes the cone to visibly "deform" at the tail — the band narrows or shifts as contributing arrays drop out one by one, which doesn't match how Trio draws its cone.

Proposal

If the goal is to be visually identical to Trio, cap the cone length at the shortest of the (up to 4) available predBG arrays:

let minLength = min(allArrays.map { $0.count }.min()!, toLoad + 1)

This way every point in the cone is computed from the same set of contributing arrays, and the band ends cleanly when the first array runs out instead of deforming.

Open questions

  • Confirm this matches Trio's actual rendering behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions