This commit is contained in:
Andras Schmelczer 2026-06-28 11:59:44 +01:00
parent f1601257c7
commit c2070693fb
68 changed files with 2305 additions and 212 deletions

View file

@ -142,7 +142,7 @@ pub fn compute_feature_stats(
if value.is_finite() {
// Reject negatives, NaN-via-large-cast, and any out-of-range
// index. A schema/data mismatch is a critical data-integrity
// bug skip the row, count it, and surface as error so
// bug: skip the row, count it, and surface as error so
// monitoring catches it.
let len = value_counts.len();
let idx_ok = value >= 0.0 && (value as usize) < len;
@ -154,7 +154,7 @@ pub fn compute_feature_stats(
feature = feature_names[fi].as_str(),
value,
max = len,
"Enum index out of bounds data/schema mismatch"
"Enum index out of bounds: data/schema mismatch"
);
}
}
@ -296,7 +296,7 @@ pub fn compute_enum_feature_counts(
/// Denominators are COVERAGE-AWARE: police.uk has multi-year publication gaps
/// for whole forces (e.g. Greater Manchester from 2019-07), and the pipeline
/// emits a `covered_years` calendar per postcode. A postcode only counts toward
/// a year's denominator if its force published that year and only then does
/// a year's denominator if its force published that year, and only then does
/// its missing bar mean a genuine zero. Years no selected postcode covers are
/// omitted entirely (charted as gaps, not zeros). Postcodes without coverage
/// info (legacy parquet without the column) count toward every year, restoring
@ -337,7 +337,7 @@ pub fn compute_crime_by_year(
// A postcode with a row but no series for a given type had no recorded
// incidents of that type: it contributes 0 to the sums, and its covered
// years still count in the denominator a genuine zero. Uncovered
// years still count in the denominator: a genuine zero. Uncovered
// years are excluded via the denominators instead.
if let Some(series_list) = crime_by_year.series_by_postcode.get(postcode) {
for series in series_list {
@ -575,7 +575,7 @@ mod tests {
assert_eq!(all.get("Yes"), Some(&2));
assert_eq!(all.get("No"), Some(&1));
// A filter-matching subset would yield a different tally confirming
// A filter-matching subset would yield a different tally, confirming
// the count is driven purely by the rows passed in (so callers can pass
// the full area to make it filter-independent).
let subset = compute_enum_feature_counts(&[0, 3], &data, 0).unwrap();
@ -621,7 +621,7 @@ mod tests {
let robbery = out.iter().find(|c| c.name == "Robbery (/yr, 7y)").unwrap();
assert_eq!(robbery.national, Some(6.0));
// The outcode value was NaN dropped to None; the sector value is finite.
// The outcode value was NaN, dropped to None; the sector value is finite.
assert_eq!(robbery.outcode, None);
assert_eq!(robbery.sector, Some(7.0));
}