v0.5.5: try to fix tests
This commit is contained in:
parent
483a3c3d61
commit
8225ac8e70
7 changed files with 140 additions and 13 deletions
|
|
@ -154,9 +154,12 @@ impl ChestCompressions {
|
|||
}
|
||||
|
||||
fn pleth_wave(&self) -> f64 {
|
||||
// A delayed, deliberately weak mechanical pleth pulse.
|
||||
let phase = (self.phase - 0.26).rem_euclid(1.0);
|
||||
smooth_step(phase / 0.27) * (1.0 - smooth_step((phase - 0.27) / 0.62))
|
||||
// A delayed, low-amplitude pulse for effective CPR. Using a bounded
|
||||
// within-compression phase instead of wrapping the delay prevents
|
||||
// a pulse's trailing portion leaking into the *next* compression.
|
||||
let phase = self.phase - 0.25;
|
||||
if phase <= 0.0 { return 0.0; }
|
||||
smooth_step(phase / 0.22) * (1.0 - smooth_step((phase - 0.35) / 0.35))
|
||||
}
|
||||
|
||||
fn ecg_artifact(&self, time: f64) -> f64 {
|
||||
|
|
@ -751,8 +754,12 @@ mod tests {
|
|||
assert_eq!(sim.spo2_quality(&p), Spo2Quality::Poor);
|
||||
assert_eq!(sim.spo2_status(&p), Spo2Status::Available);
|
||||
assert!(sim.spo2_pulse_rate(&p).is_some_and(|v| (90..=110).contains(&v)));
|
||||
assert!(sim.samples.iter().rev().take(400).any(|s| s.pleth > 0.05 && s.pleth_valid));
|
||||
assert!(sim.samples.iter().rev().take(400).all(|s| s.pleth_quality == Spo2Quality::Poor));
|
||||
let recent: Vec<_> = sim.samples.iter().rev().take(400).collect();
|
||||
let max_valid_pleth = recent.iter().filter(|s| s.pleth_valid)
|
||||
.map(|s| s.pleth).fold(0.0_f64, f64::max);
|
||||
assert!(max_valid_pleth > 0.05,
|
||||
"good CPR in VF must generate valid pleth pulses; max valid amplitude={max_valid_pleth:.4}");
|
||||
assert!(recent.iter().all(|s| s.pleth_quality == Spo2Quality::Poor));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue