-
Notifications
You must be signed in to change notification settings - Fork 2
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
Correcting minor bug in dist functions and adding optional overwrite to read and add params #54
base: master
Are you sure you want to change the base?
Conversation
…to read and add params
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #54 +/- ##
==========================================
- Coverage 84.12% 84.03% -0.09%
==========================================
Files 42 42
Lines 2822 2825 +3
==========================================
Hits 2374 2374
- Misses 448 451 +3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few things to address before merging this, but mostly looking good!
if (n_to_sample > static_cast<int>(n)) | ||
|
||
// Correcting for possible overflow | ||
if (n_to_sample == (static_cast<int>(n) + 1)) | ||
--n_to_sample; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions here:
- Why not set
n_to_sample = static_cast<int>(n);
instead of--n_to_sample
? - Is it impossible for
n_to_sample
to be greater than(static_cast<int>(n) + 1))
? Or does it just not need to be corrected if so?
n_to_distribute--; | ||
// Correcting for possible rounding errors | ||
if (n_to_distribute == (n + 1)) | ||
--n_to_distribute; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same questions as above: why not set = n
? and can n_to_distribute
exceed (n+1)
?
n_to_sample--; | ||
// Correcting for possible overflow | ||
if (n_to_sample == (n + 1)) | ||
--n_to_sample; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same questions as above
) { | ||
|
||
if (parameters.find(pname) == parameters.end()) | ||
parameters[pname] = initial_value; | ||
else if (!overwrite) | ||
throw std::logic_error("The parameter " + pname + " already exists."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests to cover this case and specific error message
This pull request includes several changes to the
epiworld
library, focusing on version updates, parameter handling, and correcting potential overflow and rounding errors in distribution functions. The most important changes are summarized below:Version Update:
epiworld.hpp
andinclude/epiworld/epiworld.hpp
. [1] [2]Parameter Handling:
add_param
andread_params
methods inclass Model
to include anoverwrite
flag, allowing parameters to be overwritten if they already exist. [1] [2]add_param
andread_params
methods to handle theoverwrite
flag correctly inepiworld.hpp
andinclude/epiworld/model-meat.hpp
. [1] [2] [3] [4]Overflow and Rounding Corrections:
distribute_virus_randomly
,distribute_tool_randomly
, anddistribute_entity_randomly
functions by adjusting the conditions under which the number of items to distribute is decremented. [1] [2] [3] [4] [5]