server
Some checks failed
Build and publish Docker image / build-and-push (push) Failing after 6m7s
CI / Check (push) Failing after 7m21s

This commit is contained in:
Andras Schmelczer 2026-05-31 13:19:26 +01:00
parent 8dc939d761
commit d98819b569
12 changed files with 157 additions and 161 deletions

View file

@ -257,10 +257,11 @@ pub fn compute_feature_stats(
/// Compute property-weighted per-year crime means across the selection.
///
/// Each matching property contributes its LSOA's per-year counts; this is the
/// same property-weighted-LSOA-average shape used elsewhere in the right pane.
/// LSOAs with no series for a given crime type contribute 0 for that type
/// (matching how the existing `(avg/yr)` columns treat missing crime types).
/// Each matching property contributes its postcode's per-year counts (incidents
/// within 50m of that postcode); this is the same property-weighted-average
/// shape used elsewhere in the right pane. Postcodes with no series for a given
/// crime type contribute 0 for that type (matching how the `(avg/yr)` columns
/// treat missing crime types).
pub fn compute_crime_by_year(
matching_rows: &[usize],
data: &PropertyData,
@ -273,19 +274,19 @@ pub fn compute_crime_by_year(
}
// For each crime type, accumulate per-year sums and the count of rows whose
// LSOA exists in the crime side table.
// postcode exists in the crime side table.
let num_types = crime_by_year.crime_types.len();
let mut per_type_year_sums: Vec<FxHashMap<i32, f64>> =
(0..num_types).map(|_| FxHashMap::default()).collect();
let mut per_type_row_counts: Vec<u32> = vec![0; num_types];
for &row in matching_rows {
let lsoa = data.lsoa(row);
let Some(series_list) = crime_by_year.series_by_lsoa.get(lsoa) else {
let postcode = data.postcode(row);
let Some(series_list) = crime_by_year.series_by_postcode.get(postcode) else {
continue;
};
// For every type the LSOA reports, add its per-year counts.
// For every type the postcode reports, add its per-year counts.
// For types it doesn't report, treat the row as contributing 0 — so we
// bump the row count for *every* known type below.
for series in series_list {