From ce352004534383c439d0fba9e574917fd200bbb8 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 16 Sep 2020 08:20:37 +0100 Subject: [PATCH] Rename variable to be clearer Better name than `population`, and `smartphone_ownership_for_area_by_age_range` matches with `SMARTPHONE_OWNERSHIP_BY_AGE_RANGE` --- app/broadcast_areas/create-broadcast-areas-db.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/broadcast_areas/create-broadcast-areas-db.py b/app/broadcast_areas/create-broadcast-areas-db.py index ed1ce2e96..78bfaf1fd 100755 --- a/app/broadcast_areas/create-broadcast-areas-db.py +++ b/app/broadcast_areas/create-broadcast-areas-db.py @@ -80,18 +80,18 @@ def estimate_number_of_smartphones_in_area(country_or_ward_code): raise ValueError(f'No population data for {country_or_ward_code}') population = area_to_population_mapping[country_or_ward_code] - population_by_range = {} + smartphone_ownership_for_area_by_age_range = {} for range, ownership in SMARTPHONE_OWNERSHIP_BY_AGE_RANGE.items(): min, max = range - population_by_range[range] = sum( + smartphone_ownership_for_area_by_age_range[range] = sum( people for age, people in population if min <= age <= max ) * ownership total_population = sum(dict(population).values()) - total_phones = sum(population_by_range.values()) + total_phones = sum(smartphone_ownership_for_area_by_age_range.values()) print( # noqa: T001 f' Population:{total_population: 11,.0f}'