Skip to content

Use per-capita contacts in contact_basis - #283

Open
RasmusSkytte wants to merge 6 commits into
mainfrom
feature/DiseasyActivity-store-per-capita-contacts
Open

Use per-capita contacts in contact_basis#283
RasmusSkytte wants to merge 6 commits into
mainfrom
feature/DiseasyActivity-store-per-capita-contacts

Conversation

@RasmusSkytte

@RasmusSkytte RasmusSkytte commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Intent

Currently we perform the age group remapping from the contact matrix age groups to the model age groups in DiseasyActivity.

However, since the population is now primarily being handled in DiseasyPopulation which has access to both the model demography and model age groups, this is a more fitting place for this age handling to occur.

To migrate the age handling from DiseasyActivity to DiseasyPopulation, the first step is to make the contact matrices in DiseasyActivity agnostic to the original demography used to compute the matrices.

Approach

Contact matrices now saved as the per-capita contact rates ("C" domain) instead of the current mean contact rate ("M" domain).

This removes the need to store the original demography used to compute the contact matrices.

This data is still kept, but it paves the way to fully remove this demography when we migrate age handling to DiseasyPopulation.

Contacts returned from DiseasyActivity$get_scenario_contacts() are now also per-capita, and DiseasyActivity$rescale_rates_to_counts() is modified so the output is still C*N.

Known issues

N/A

Checklist

  • The PR passes all local unit tests
  • I have documented any new features introduced
  • If the PR adds a new feature, please add an entry in NEWS.md
  • A reviewer is assigned to this PR

@RasmusSkytte RasmusSkytte self-assigned this Aug 12, 2026
@RasmusSkytte RasmusSkytte added the enhancement New feature or request label Aug 12, 2026
@RasmusSkytte
RasmusSkytte force-pushed the feature/DiseasyActivity-store-per-capita-contacts branch 4 times, most recently from 4ab41d6 to a6c99bf Compare August 12, 2026 11:51
@RasmusSkytte RasmusSkytte added this to the DiseasyRegions milestone Aug 12, 2026
@RasmusSkytte
RasmusSkytte force-pushed the feature/DiseasyActivity-store-per-capita-contacts branch from 0ebc528 to 9c74f45 Compare August 13, 2026 09:03
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.56322% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.22%. Comparing base (50d7d25) to head (aef4e1d).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
R/DiseasyActivity.R 76.11% 16 Missing ⚠️
R/generate_contact_basis.R 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #283      +/-   ##
==========================================
- Coverage   66.09%   64.22%   -1.88%     
==========================================
  Files          28       28              
  Lines        4643     9586    +4943     
==========================================
+ Hits         3069     6157    +3088     
- Misses       1574     3429    +1855     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RasmusSkytte
RasmusSkytte marked this pull request as ready for review August 13, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant