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

Rework Initial Infections and Support Exponential Growth Initializations #124

Merged
merged 117 commits into from
Jun 7, 2024

Conversation

damonbayer
Copy link
Collaborator

@damonbayer damonbayer commented May 19, 2024

Closes #116.

Requesting early feedback on my very WIP changes, since this is my first contribution, and I'm pretty inexperienced at Python, object-oriented programming, and Numpyro/JAX.

Eventually, this PR will achieve several objectives:

  1. Implementation of InfectionSeedMethod of which the current only behavior (padding with 0's) will be one method, and an exponential grown initialization will be another. Must meet all specifications documented in Exponential growth model for initial infections #116.
  2. Rewrite of the Infections0 class to correspond to all of the "seed" infections, rather than just the initial infections (see here). This work is currently being done in model/src/pyrenew/latent/infection_seeding_method.py.
  3. Update all existing tutorials to work with the new methods.
  4. Maybe: write a new tutorial relating to the seeding methods.

Much of the current PR was implemented by pattern matching existing classes and not fully understanding what I was doing. I have littered the code with questions throughout and will self-review to ask more questions.

@damonbayer damonbayer linked an issue May 19, 2024 that may be closed by this pull request
4 tasks
Copy link

codecov bot commented May 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.81%. Comparing base (f28ad47) to head (0854aee).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
+ Coverage   94.29%   94.81%   +0.51%     
==========================================
  Files          37       39       +2     
  Lines         771      848      +77     
==========================================
+ Hits          727      804      +77     
  Misses         44       44              
Flag Coverage Δ
unittests 94.81% <100.00%> (+0.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator Author

@damonbayer damonbayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-reviewing to ask questions for other reviewers (or future me) to answer.

model/src/pyrenew/latent/infection_seeding_method.py Outdated Show resolved Hide resolved
model/src/pyrenew/latent/infection_seeding_method.py Outdated Show resolved Hide resolved
model/src/pyrenew/latent/infection_seeding_process.py Outdated Show resolved Hide resolved
scratch/InfectionSeedingProcess_demo.py Outdated Show resolved Hide resolved
scratch/InfectionSeedingProcess_demo.py Outdated Show resolved Hide resolved
@damonbayer
Copy link
Collaborator Author

@gvegayon and I discussed all my questions over Teams. No need review the current state.

damonbayer and others added 3 commits June 7, 2024 09:03
Co-authored-by: Dylan H. Morris <dylanhmorris@users.noreply.github.com>
@gvegayon
Copy link
Member

gvegayon commented Jun 7, 2024

To regenerate the image, I did the following:

cd model
poetry shell
make test_images

Which runs:

poetry run pytest --mpl-generate-path=src/test/baseline

This is the "session info"

>>> import sys
>>> import platform
on version")
print(sys.version)
print("Version info.")
print(sys.version_info)

print("\nOperating s>>> import pip
ystem")
print(platform.system(), platform.release())

print("\nInstalled packages")
pip.main(['list'])>>> 
>>> print("Python version")
Python version
>>> print(sys.version)
3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
>>> print("Version info.")
Version info.
>>> print(sys.version_info)
sys.version_info(major=3, minor=10, micro=12, releaselevel='final', serial=0)
>>> 
>>> print("\nOperating system")

Operating system
>>> print(platform.system(), platform.release())
Linux 6.5.0-35-generic
>>> 
>>> print("\nInstalled packages")

Installed packages
>>> pip.main(['list'])
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Package                       Version     Editable project location
----------------------------- ----------- --------------------------------------------
alabaster                     0.7.16
asttokens                     2.4.1
attrs                         23.2.0
Babel                         2.15.0
certifi                       2024.2.2
charset-normalizer            3.3.2
comm                          0.2.2
contourpy                     1.2.1
coverage                      7.5.1
cycler                        0.12.1
debugpy                       1.8.1
decorator                     5.1.1
docutils                      0.21.2
exceptiongroup                1.2.1
executing                     2.0.1
fastjsonschema                2.19.1
fonttools                     4.51.0
idna                          3.7
imagesize                     1.4.1
iniconfig                     2.0.0
ipykernel                     6.29.4
ipython                       8.24.0
jax                           0.4.27
jaxlib                        0.4.27
jedi                          0.19.1
Jinja2                        3.1.4
jsonschema                    4.22.0
jsonschema-specifications     2023.12.1
jupyter_client                8.6.1
jupyter_core                  5.7.2
kiwisolver                    1.4.5
MarkupSafe                    2.1.5
matplotlib                    3.8.4
matplotlib-inline             0.1.7
ml-dtypes                     0.4.0
multipledispatch              1.0.0
nbclient                      0.10.0
nbformat                      5.10.4
nest-asyncio                  1.6.0
numpy                         1.26.4
numpydoc                      1.7.0
numpyro                       0.13.2
opt-einsum                    3.3.0
packaging                     24.0
parso                         0.8.4
pexpect                       4.9.0
pillow                        10.3.0
pip                           24.0
platformdirs                  4.2.1
pluggy                        1.5.0
polars                        0.20.25
prompt-toolkit                3.0.43
psutil                        5.9.8
ptyprocess                    0.7.0
pure-eval                     0.2.2
Pygments                      2.18.0
pyparsing                     3.1.2
pyrenew                       0.1.0       /home/george/Documents/development/msr/model
pytest                        8.2.0
pytest-cov                    5.0.0
pytest-mpl                    0.17.0
python-dateutil               2.9.0.post0
PyYAML                        6.0.1
pyzmq                         26.0.3
referencing                   0.35.1
requests                      2.32.2
rpds-py                       0.18.1
scipy                         1.13.0
setuptools                    69.1.0
six                           1.16.0
snowballstemmer               2.2.0
Sphinx                        7.3.7
sphinxcontrib-applehelp       1.0.8
sphinxcontrib-devhelp         1.0.6
sphinxcontrib-htmlhelp        2.0.5
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.7
sphinxcontrib-serializinghtml 1.1.10
stack-data                    0.6.3
tabulate                      0.9.0
tomli                         2.0.1
tornado                       6.4
tqdm                          4.66.4
traitlets                     5.14.3
typing_extensions             4.11.0
urllib3                       2.2.1
wcwidth                       0.2.13
0
>>> 

Here is the clean code:

import sys
import platform
import pip

print("Python version")
print(sys.version)
print("Version info.")
print(sys.version_info)

print("\nOperating system")
print(platform.system(), platform.release())

print("\nInstalled packages")
pip.main(['list'])

@damonbayer damonbayer dismissed dylanhmorris’s stale review June 7, 2024 20:11

resolved all comments

@damonbayer damonbayer requested a review from AFg6K7h4fhy2 June 7, 2024 20:12
@damonbayer damonbayer merged commit 4eda387 into main Jun 7, 2024
8 checks passed
@damonbayer damonbayer deleted the 116-exponential-growth-model-for-initial-infections branch June 7, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exponential growth model for initial infections
4 participants