We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f98349b commit c03c213Copy full SHA for c03c213
src/deviation.rs
@@ -10,6 +10,10 @@ where
10
fn count_eq(&self, other: &ArrayBase<S, D>) -> usize
11
where
12
A: PartialEq;
13
+
14
+ fn count_neq(&self, other: &ArrayBase<S, D>) -> usize
15
+ where
16
+ A: PartialEq;
17
}
18
19
impl<A, S, D> DeviationExt<A, S, D> for ArrayBase<S, D>
@@ -31,6 +35,13 @@ where
31
35
32
36
c
33
37
38
39
40
41
+ A: PartialEq,
42
+ {
43
+ self.len() - self.count_eq(other)
44
+ }
34
45
46
47
#[cfg(test)]
@@ -50,4 +61,17 @@ mod tests {
50
61
assert_eq!(b.count_eq(&c), 0);
51
62
assert_eq!(d.count_eq(&e), 4);
52
63
64
65
+ #[test]
66
+ fn test_count_neq() {
67
+ let a = array![1, 2, 3, 4, 5, 6, 7];
68
+ let b = array![1, 3, 3, 4, 6, 7, 8];
69
+ let c = array![2, 4, 4, 5, 7, 8, 9];
70
+ let d = array![[1, 2], [3, 4], [5, 6]];
71
+ let e = array![[1, 2], [4, 3], [5, 6]];
72
73
+ assert_eq!(a.count_neq(&b), 4);
74
+ assert_eq!(b.count_neq(&c), 7);
75
+ assert_eq!(d.count_neq(&e), 2);
76
53
77
0 commit comments