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

Expose the run_multiple Functionality #26

Closed
wants to merge 7 commits into from

Conversation

IsaccBarker
Copy link
Collaborator

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.

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.
@IsaccBarker IsaccBarker requested a review from gvegayon June 28, 2024 10:00
@IsaccBarker IsaccBarker self-assigned this Jun 28, 2024
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)
Copy link
Collaborator Author

@IsaccBarker IsaccBarker left a 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.
Copy link
Collaborator Author

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.

Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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?

@IsaccBarker
Copy link
Collaborator Author

Blocked by #33.

@gvegayon
Copy link
Member

gvegayon commented Aug 5, 2024

Hey @IsaccBarker, how is progress in here?

@IsaccBarker
Copy link
Collaborator Author

Solved by #38.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose the run_multiple functionality
2 participants