SABS-R3-Epidemiology / branchpro

Using branching processes to estimate the time-dependent reproduction number of a disease with imported cases
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Issue 195 code optimization #196

Closed rccreswell closed 2 years ago

rccreswell commented 3 years ago

My current ideas for cutting cpu and memory usage, in the hope of getting it to run with 1000 serial interval samples on heroku.

closes #195

codecov[bot] commented 3 years ago

Codecov Report

Merging #196 (553ef23) into main (afba556) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #196   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          659       697   +38     
=========================================
+ Hits           659       697   +38     
Impacted Files Coverage Δ
branchpro/__init__.py 100.00% <100.00%> (ø)
branchpro/posterior.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update afba556...553ef23. Read the comment docs.

rccreswell commented 3 years ago

Looks good to me, thanks @rcw5890 ! My initial thought was that we potentially could have vectorised this using numpy to avoid the dependence on numexp, but I think this is all fine.

Thanks @DavAug . I had the same thought and did that first, but for arrays of our size numexpr manages to be about 4x faster than numpy. I don't think it's difficult to install and it can be made an optional dependency if anyone has trouble with it.

By the way, I just realized that my original gamma pdf fails in the special case of shape=1, x=0. I just added a potential fix.