fix Batch modes
This commit is contained in:
@@ -1399,15 +1399,18 @@ impl BatchMode {
|
|||||||
pub fn apply(&self, samples: &[f64]) -> f64 {
|
pub fn apply(&self, samples: &[f64]) -> f64 {
|
||||||
match self {
|
match self {
|
||||||
BatchMode::Sum => samples.iter().sum(),
|
BatchMode::Sum => samples.iter().sum(),
|
||||||
|
/// Both c-charp and rust return NaN for 0.0/0.0 so we're good here
|
||||||
BatchMode::Average => samples.iter().copied().sum::<f64>() / samples.len() as f64,
|
BatchMode::Average => samples.iter().copied().sum::<f64>() / samples.len() as f64,
|
||||||
|
/// Game uses a default of Positive INFINITY for Minimum
|
||||||
BatchMode::Minimum => *samples
|
BatchMode::Minimum => *samples
|
||||||
.iter()
|
.iter()
|
||||||
.min_by(|a, b| a.partial_cmp(b).unwrap())
|
.min_by(|a, b| a.partial_cmp(b).unwrap())
|
||||||
.unwrap_or(&0.0),
|
.unwrap_or(&f64::INFINITY),
|
||||||
|
/// Game uses default of NEG_INFINITY for Maximum
|
||||||
BatchMode::Maximum => *samples
|
BatchMode::Maximum => *samples
|
||||||
.iter()
|
.iter()
|
||||||
.max_by(|a, b| a.partial_cmp(b).unwrap())
|
.max_by(|a, b| a.partial_cmp(b).unwrap())
|
||||||
.unwrap_or(&0.0),
|
.unwrap_or(&f64::NEG_INFINITY),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user