style(core): the test-only reference reduction maps rather than and_thens (improvise-qddo)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
Claude (dbsp-sources)
2026-10-10 17:58:17 -07:00
committed by Edward Langley
parent 5fdf502871
commit 7a3e0c5b55
+5 -5
View File
@@ -325,7 +325,7 @@ mod tests {
/// The reduction as it was before the source moved it, kept to compare against.
fn reference(values: &[&CellValue], func: &AggFunc) -> Option<CellValue> {
let numbers: Vec<f64> = values.iter().filter_map(|v| v.as_f64()).collect();
values.split_first().and_then(|(first, rest)| {
values.split_first().map(|(first, rest)| {
if numbers.len() == values.len() {
let mut sum = ExactSum::new();
numbers.iter().for_each(|v| sum.add(*v, 1));
@@ -333,17 +333,17 @@ mod tests {
let finite = numbers.iter().copied().filter(|v| !v.is_nan());
finite.min_by(order).unwrap_or(f64::NAN)
};
Some(CellValue::Number(match func {
CellValue::Number(match func {
AggFunc::Sum => sum.value(),
AggFunc::Avg => sum.mean(numbers.len() as u64),
AggFunc::Min => extreme(f64::total_cmp),
AggFunc::Max => extreme(|a, b| b.total_cmp(a)),
AggFunc::Count => numbers.len() as f64,
}))
})
} else if rest.iter().all(|v| v == first) {
Some((*first).clone())
(*first).clone()
} else {
Some(CellValue::Error("mixed".to_string()))
CellValue::Error("mixed".to_string())
}
})
}