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

Use rounding for treatments #225

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Use rounding for treatments #225

wants to merge 10 commits into from

Conversation

wenzeslaus
Copy link
Member

@wenzeslaus wenzeslaus commented Oct 24, 2024

Replaced flooring by rounding in all treatments.

Instead of floor or ceil, always round to the nearest integer value as soon as the floating point calculation is finished.

This changes results in r.pops.spread and presumably in rpops, too.
…use treatment of infected is based on mortality groups
@wenzeslaus wenzeslaus changed the title round treatments Round treatments Oct 24, 2024
@wenzeslaus
Copy link
Member Author

This causes some, but not much changes in r.pops.spread test results:

======================================================================
FAIL: test_outputs_mortality_pesticide_treatment (__main__.TestSpread.test_outputs_mortality_pesticide_treatment)
Check mortality together with pesticide treatment (all_infected_in_cell)
----------------------------------------------------------------------
...
AssertionError: r.univar map=average percentile=90.0 nprocs=1 separator== format=plain -g difference:
mismatch values (key, reference, actual): [('max', 5.6, 5.8), ('mean', 0.526, 0.552422813036034)]
command: r.univar map=average percentile=90.0 nprocs=1 separator== format=plain -g {'map': 'average', 'separator': '=', 'flags': 'g'}

======================================================================
FAIL: test_outputs_mortality_treatment (__main__.TestSpread.test_outputs_mortality_treatment)
Check mortality together with treatment
----------------------------------------------------------------------
...
AssertionError: r.univar map=dead_2020_12_31 percentile=90.0 nprocs=1 separator== format=plain -g difference:
mismatch values (key, reference, actual): [('sum', 2483, 2505)]
command: r.univar map=dead_2020_12_31 percentile=90.0 nprocs=1 separator== format=plain -g {'map': 'dead_2020_12_31', 'separator': '=', 'flags': 'g'}

----------------------------------------------------------------------

@wenzeslaus wenzeslaus added the changes results Results will be different label Oct 24, 2024
@wenzeslaus wenzeslaus changed the title Round treatments Use rounding for treatments Nov 5, 2024
@wenzeslaus
Copy link
Member Author

Two tests with mortality in r.pops.spread fail:

def test_outputs_mortality_treatment(self):
    """Check mortality together with treatment"""
# ...
def test_outputs_mortality_pesticide_treatment(self):
    """Check mortality together with pesticide treatment (all_infected_in_cell)"""
# ...

The other two treatment tests without mortality pass even with this change:

def test_sei_treatments_removal_ratio_to_all(self):
    """Check outputs with SEI and treatment_length == 0"""
# ...
def test_sei_treatments_pesticide_ratio_to_all(self):
    """Check outputs with SEI and treatment_length != 0 (pesticide)"""
# ...

…quires using mortality groups in calculations. Specifically, treatments use mortality groups directly to consistently apply the treatment function. When mortality is not active, we still need to behave the same, so we now consider all infected to be a part of one mortality group when asked for it. This allows treatments to use mortality groups to get infected even when mortality is disabled. The functions in host pool which accept mortality groups for a cell as an input are now ignoring mortality groups when mortality is not active (before they were relying on input mortality vector being empty). Alternative implementation, or just possible improvement in addtion to this new API, would be to allow treatments to pass a function to reduce the different values, but treatments uses different functions for different pools, so that would require at least two functions passed which is possible, but may be hard to read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes results Results will be different
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant