Skip to content

Commit 23d8bad

Browse files
committed
deviation: test with empty inputs
1 parent 3782c9a commit 23d8bad

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/deviation.rs

+20
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,24 @@ mod tests {
363363

364364
// TODO: gkl_div
365365
}
366+
367+
#[test]
368+
fn test_deviations_with_empty_inputs() {
369+
let a: Array1<f64> = array![];
370+
371+
assert_eq!(a.count_eq(&a), 0);
372+
assert_eq!(a.count_neq(&a), 0);
373+
assert_eq!(a.sq_l2_dist(&a), 0.);
374+
assert_eq!(a.l2_dist(&a), 0.);
375+
assert_eq!(a.l1_dist(&a), 0.);
376+
assert_eq!(a.linf_dist(&a), 0.);
377+
378+
assert!(a.mean_abs_dev(&a).is_nan());
379+
assert_eq!(a.max_abs_dev(&a), 0.);
380+
assert!(a.mean_sq_dev(&a).is_nan());
381+
assert!(a.root_mean_sq_dev(&a).is_nan());
382+
assert!(a.peak_signal_to_noise_ratio(&a, 0.).is_nan());
383+
384+
// TODO: gkl_div
385+
}
366386
}

0 commit comments

Comments
 (0)