@Test @DisplayName("should handle NaN values without fail") void errorProneSensorValue() { double arr[] = { NaN, 0.3, 0.56, 0.34, 0.78, 0.28, NaN, 0.35, NaN }; double value = filter.filterValue(0.37); for (double reading : arr) { value = filter.filterValue(reading); } assertThat(value, not(NaN)); }
public double filterValue(double nextRawValue) { double calibratedValue; calibratedValue = Double.isNaN(nextRawValue) ? currentValue : calibrateValue(nextRawValue); currentValue = calibratedValue; return calibratedValue; }
LowPassFilter implements Filter { public double filterValue(double nextRawValue) { double calibratedValue; calibratedValue = Double.isNaN(nextRawValue) ? currentValue : calibrateValue(nextRawValue); currentValue = calibratedValue; return calibratedValue; } }
LowPassFilter implements Filter { public double filterValue(double nextRawValue) { double calibratedValue; calibratedValue = Double.isNaN(nextRawValue) ? currentValue : calibrateValue(nextRawValue); currentValue = calibratedValue; return calibratedValue; } LowPassFilter(double weight); }
LowPassFilter implements Filter { public double filterValue(double nextRawValue) { double calibratedValue; calibratedValue = Double.isNaN(nextRawValue) ? currentValue : calibrateValue(nextRawValue); currentValue = calibratedValue; return calibratedValue; } LowPassFilter(double weight); double filterValue(double nextRawValue); }
LowPassFilter implements Filter { public double filterValue(double nextRawValue) { double calibratedValue; calibratedValue = Double.isNaN(nextRawValue) ? currentValue : calibrateValue(nextRawValue); currentValue = calibratedValue; return calibratedValue; } LowPassFilter(double weight); double filterValue(double nextRawValue);  }