-
Notifications
You must be signed in to change notification settings - Fork 1
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
Expose the run_multiple
Functionality
#26
Conversation
See UofUEpiBio#23. There's a bunch of filesystem stuff here, since we're on C++11 and don't have access to the C++17 filesytem APIs. The only thing we should have to worry about here is that the implementation of the Saver constructor matches the Saver constructor (or equivilant) in EpiworldR: https://github.com/UofUEpiBio/epiworldR/blob/main/R/make_saver.R The thing that most needs to be watched out for is what happens if you supply `fn` a file versus a directory; I've done some testing and it appears to be working fine, but there might be some edge cases I didn't test. I would write a unit test to check, but I'm not entirely sure about the intended behaviour of the original R code.
Summary (fixed): src/epiworld-common.hpp: Consecutive return, break, continue, goto or throw statements are unnecessary. src/epiworld-common.hpp: Variable 'fun' is assigned in constructor body. src/epiworld-common.hpp: Function parameter '_default' should be passed by const reference. src/epiworldpy/__init__.py: '._core.Saver' imported but unused (F401)
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.
I would select the request changes option here, but it won't let me!
|
||
saver.run_multiple(covid19, 100, 4, nthreads=1) | ||
|
||
# TODO: Verify things worked correctly, as is the point of tesing. |
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.
TODO: Verify things worked correctly, as is the point of testing.
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.
Is the functionality to load the results available? If so, can you add or point me to an example using it?
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.
Yeah, getting the results is available (see get_generation_time
, get_reproductive_number
, and so on) when iterating over the viruses returned by Epiworld. I've gone ahead and merged the commits with those functions into this PR, but when using them in a run-multiple context, they only ever seem to report one virus. For example, the below prints 1 (when we're running doing five runs):
import epiworldpy as epiworld
covid19 = epiworld.ModelSEIR(
name = 'covid-19',
n = 10000,
prevalence = .01,
contact_rate = 2.0,
transmission_rate = .1,
incubation_days = 7.0,
recovery_rate = 0.14
)
saver = epiworld.Saver("total_hist", "virus_hist")
saver.run_multiple(covid19, 100, 5, nthreads=1)
generation_time = covid19.get_db().get_generation_time()
viruses = generation_time['viruses']
print(len(np.unique(viruses)))
Am I getting the data wrong? I know it can't be a problem with the C++ interface because it's just a direct wrapping of the C++ arrays within Python capsules/arrays.
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.
Can you put the output here?
Blocked by #33. |
Hey @IsaccBarker, how is progress in here? |
Solved by #38. |
Fixes #23. There's a bunch of filesystem stuff here, since we're on C++11 and don't have access to the C++17 filesytem APIs. The only thing we should have to worry about here is that the implementation of the Saver constructor matches the Saver constructor (or equivalent) in EpiworldR.
The thing that most needs to be watched out for is what happens if you supply
fn
a file versus a directory; I've done some testing and it appears to be working fine, but there might be some edge cases I didn't test. I would write a unit test to check, but I'm not entirely sure about the intended behaviour of the original R code.This code will be cleaned up by #24.