1
1
use crate :: Flag ;
2
2
3
- /// Compares a single value to a higher resolution sequence, where the minimum value in the
4
- /// sequence (including an adjustment) should never be greater than the single value
3
+ /// Compares a single value to a higher resolution sequence, where the single value should never
4
+ /// be greater than the minimum value in the sequence (including an adjustment)
5
5
///
6
6
/// Returns:
7
7
/// - [`Flag::DataMissing`] if the single value is missing,
8
- /// - [`Flag::Fail`] if this invariant is broken (i.e the minimum of the sequence, plus the
9
- /// adjustment, is greater than the single value ),
8
+ /// - [`Flag::Fail`] if this invariant is broken (i.e the single value is greater than the minimum
9
+ /// of the sequence plus the adjustment ),
10
10
/// - [`Flag::DataMissing`] if any of the elements is missing, as we cannot be sure a missing data
11
11
/// point did not violate the invariant.
12
12
/// - [`Flag::Pass`] otherwise.
13
- pub fn min_greater_than_single (
13
+ pub fn single_greater_than_min (
14
14
single : Option < f32 > ,
15
15
sequence : & [ Option < f32 > ] ,
16
16
adjustment : f32 ,
@@ -46,12 +46,12 @@ pub fn min_greater_than_single(
46
46
}
47
47
} ;
48
48
49
- if min + adjustment > single {
49
+ if single > min + adjustment {
50
50
// if this condition evaluates to true, the invariant was invalidated
51
51
Flag :: Fail
52
52
} else if missing {
53
53
// if the condition was not met, but there was missing data in the sequence, we cannot say
54
- // for sure that the invariant wasn't validated
54
+ // for sure that the invariant wasn't invalidated
55
55
Flag :: DataMissing
56
56
} else {
57
57
Flag :: Pass
@@ -63,22 +63,22 @@ mod tests {
63
63
use super :: * ;
64
64
65
65
#[ test]
66
- fn test_min_greater_than_single ( ) {
66
+ fn test_single_greater_than_min ( ) {
67
67
assert_eq ! (
68
- min_greater_than_single( Some ( 1. ) , & [ Some ( 1. ) , Some ( 2. ) , Some ( 2. ) ] , 0.2 ) ,
69
- Flag :: Fail
70
- ) ;
71
- assert_eq ! (
72
- min_greater_than_single( Some ( 1. ) , & [ Some ( 1. ) , Some ( 2. ) , Some ( 2. ) ] , -0.2 ) ,
68
+ single_greater_than_min( Some ( 1. ) , & [ Some ( 1. ) , Some ( 2. ) , Some ( 2. ) ] , 0.2 ) ,
73
69
Flag :: Pass
74
70
) ;
75
71
assert_eq ! (
76
- min_greater_than_single ( Some ( 1. ) , & [ Some ( 1. ) , None , Some ( 2. ) ] , -0.2 ) ,
77
- Flag :: DataMissing
72
+ single_greater_than_min ( Some ( 1. ) , & [ Some ( 1. ) , Some ( 2. ) , Some ( 2. ) ] , -0.2 ) ,
73
+ Flag :: Fail
78
74
) ;
79
75
assert_eq ! (
80
- min_greater_than_single ( Some ( 1. ) , & [ Some ( 1. ) , None , Some ( 2. ) ] , 0.2 ) ,
76
+ single_greater_than_min ( Some ( 1. ) , & [ Some ( 1. ) , None , Some ( 2. ) ] , - 0.2 ) ,
81
77
Flag :: Fail
82
78
) ;
79
+ assert_eq ! (
80
+ single_greater_than_min( Some ( 1. ) , & [ Some ( 1. ) , None , Some ( 2. ) ] , 0.2 ) ,
81
+ Flag :: DataMissing
82
+ ) ;
83
83
}
84
84
}
0 commit comments