Skip to content

Commit

Permalink
Fix bug when setting a target weight.
Browse files Browse the repository at this point in the history
  • Loading branch information
braniii committed Mar 21, 2024
1 parent b8c4600 commit db7d5da
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/lib/core/measurementInterpolation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class MeasurementInterpolation {
/// length of vectors
int get N => times.length;

/// length of displayed vectors
int get NDisplay => timesDisplay.length;

Vector? _times;
/// get vector containing the times given in [ms since epoch]
Vector get times => _times ??= _createTimes();
Expand Down Expand Up @@ -421,7 +424,7 @@ class MeasurementInterpolation {
/// final change Rate
double get finalChangeRate => _linearChangeRate(
N - 1 - _offsetInDays,
N - 1 - _offsetInDaysShown,
N - 1 - _offsetInDays + _offsetInDaysShown,
weightsGaussianExtrapol,
);

Expand All @@ -431,7 +434,7 @@ class MeasurementInterpolation {
return null;
}

final int idxLast = idxsMeasurements.last;
final int idxLast = NDisplay - 1 - _offsetInDaysShown;
final double slope = finalChangeRate;

// Crossing is in the past
Expand Down

0 comments on commit db7d5da

Please sign in to comment.