UofUEpiBio / epiworldpy

https://uofuepibio.github.io/epiworldpy/
Other
1 stars 1 forks source link

Expose More Functions/Models #25

Closed IsaccBarker closed 3 months ago

IsaccBarker commented 4 months ago

Fixes #20. Here, we expose the functions mentioned in issue https://github.com/UofUEpiBio/epiworldpy/issues/20. We also do some optimization; namely, before, lots of data was being copied over to Python. Now, we bind the data to a Python capsule and then convert that over to an array. The underlying C++ vector will only be destroyed when the Python object sharing the data goes out of scope. This doesn't seem to be documented within PyBind, but from my own testing it appears to work just fine.

It's worth noting that I couldn't find a way to do this while maintaining some semblance of API similarity with the function get_reproductive_number, due to the fact that the values it returns are not "rectangular" and thus cannot be represented by Python arrays without having to insert some filler values. It would be possible to do a zero-copy version of this function if we were willing to stray from strict API alignment.

This code will be cleaned up by #24.

gvegayon commented 4 months ago

The figures are looking awesome! I'll take a detail view later in the morning. Thanks, @IsaccBarker!!!

IsaccBarker commented 4 months ago