dropna method

Drop all nan values from the time series.

Implementation

TimeSeries<SleepSummary> dropna() {
  final List<SleepSummary> newValues = values
      .whereIndexed((int index, SleepSummary element) =>
          values[index].sleepStart != ZonedDateTime.now().nan)
      .toList();
  final List<ZonedDateTime> newTimestamps = timestamps
      .whereIndexed((int index, ZonedDateTime element) =>
          values[index].sleepStart != ZonedDateTime.now().nan)
      .toList();
  final List<SleepSummary> newConfidenceIntervalLow = confidenceIntervalLow
      .whereIndexed((int index, SleepSummary element) =>
          values[index].sleepStart != ZonedDateTime.now().nan)
      .toList();
  final List<SleepSummary> newConfidenceIntervalHigh = confidenceIntervalHigh
      .whereIndexed((int index, SleepSummary element) =>
          values[index].sleepStart != ZonedDateTime.now().nan)
      .toList();
  final List<double> newConfidence = confidence
      .whereIndexed((int index, double element) =>
          values[index].sleepStart != ZonedDateTime.now().nan)
      .toList();

  return TimeSeries<SleepSummary>(
    values: newValues,
    timestamps: newTimestamps,
    confidenceIntervalLow: newConfidenceIntervalLow,
    confidenceIntervalHigh: newConfidenceIntervalHigh,
    confidence: newConfidence,
  );
}