Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Demography.AGE_RANGE_LOOKUP to read-only mapping #947

Merged
merged 3 commits into from
Apr 20, 2023

Conversation

matt-graham
Copy link
Collaborator

Fixes issue described in #763 (comment) which was causing intermittent failure of tests/test_demography.py::test_py_calc test under Pandas v2.0.0.

Wraps the class attribute AGE_RANGE_LOOKUP of the Demography module, previously set to a defaultdict returned by the create_age_range_lookup function in src/tlo/util.py, in a read-only MappingProxyType. The defaultdict is first converted to a dict as otherwise the MappingProxyType will still use the underlying defaultdict for item access, which means the problem of accessing keys which are not present in the defaultdict adding new entries would remain.

@matt-graham matt-graham requested a review from tamuri April 20, 2023 10:15
@tamuri tamuri merged commit 4c2dcda into master Apr 20, 2023
@tamuri tamuri deleted the mmg/read-only-age-range-lookup branch April 20, 2023 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants