Skip to main content

Summer is a compartmental disease modelling framework, written in Python. It provides a high-level API to build and run models.

Project description

Summer: compartmental disease modelling in Python

Automated Tests

Summer is a Python-based framework for the creation and execution of compartmental (or "state-based") epidemiological models of infectious disease transmission.

It provides a range of structures for easily implementing compartmental models, including structure for some of the most common features added to basic compartmental frameworks, including:

  • A variety of inter-compartmental flows (infections, transitions, births, deaths, imports)
  • Force of infection multipliers (frequency, density)
  • Post-processing of compartment sizes into derived outputs
  • Stratification of compartments, including:
    • Adjustments to flow rates based on strata
    • Adjustments to infectiousness based on strata
    • Heterogeneous mixing between strata
    • Multiple disease strains

Some helpful links to learn more:

Installation and Quickstart

This project requires at least Python 3.7

Set up and activate an appropriate virtual environment, then install the summerepi2 package from PyPI

pip install summerepi2

Important note for Windows users: summerepi2 relies on the Jax framework for fast retargetable computing. This is automatically installed under Linux, OSX, and WSL environments. If you are using Windows, you can either install via WSL, or run the following command after installing

pip install jax[cpu]==0.3.14 -f https://whls.blob.core.windows.net/unstable/index.html

Then you can now use the library to build and run models. See here for some code examples.

Optional (recommended) extras

Summer has advanced interactive plotting tools built in - but they are greatly improved with the addition of the pygraphviz library.

If you are using conda, the simplest method of installation is as follows:

conda install --channel conda-forge pygraphviz

For other install methods, see https://pygraphviz.github.io/documentation/stable/install.html

Development

Poetry is used for packaging and dependency management.

Initial project setup is documented here and should work for Windows or Ubuntu, maybe for MacOS.

Some common things to do as a developer working on this codebase:

# Activate summer conda environment prior to doing other stuff (see setup docs)
conda activate summer

# Install latest requirements
poetry install

# Publish to PyPI - use your PyPI credentials
poetry publish --build

# Add a new package
poetry add

# Run tests
pytest -vv

# Format Python code
black .
isort . --profile black

Releases

Releases are numbered using Semantic Versioning

  • 1.0.0/1:
    • Initial release
  • 1.1.0:
    • Add stochastic integrator
  • 2.0.2:
    • Rename fractional flow to transition flow
    • Remove sojourn flow
    • Add vectorized backend and other performance improvements
  • 2.0.3:
    • Set default IVP solver to use a maximum step size of 1 timestep
  • 2.0.4:
    • Add runtime derived values
  • 2.0.5:
    • Remove legacy Summer implementation
  • 2.1.0:
    • Add AdjustmentSystems
    • Improve vectorization of flows
    • Add computed_values inputs to flow and adjustment parameters
  • 2.1.1:
    • Fix for invalid/unused package imports (cachetools)
  • 2.2.0
    • Add validation and compartment caching optimizations
  • 2.2.1
    • Derived output index caching
    • Optimized fast-tracks for infectious multipliers
  • 2.2.2
    • JIT infectiousness calculations
    • Various micro-optimizations
  • 2.2.3
    • Bugfix release (clamp outputs to 0.0)
  • 2.2.4
    • Datetime awareness, DataFrame outputs
  • 2.2.5
    • Performance improvements (frozenset), no API changes
  • 2.2.6
    • Verify strata in flow adjustments (prevent unexpected behaviour)
  • 2.2.7
    • Rename add_flow_adjustments -> set_flow_adjustments
  • 2.2.8
    • Split imports functionality (add_importation_flow now requires split_imports arg)
  • 2.2.9
    • Post-stratification population restribution
  • 2.3.0
    • First official version to support only Python 3.7
  • 2.5.0
    • Support Python 3.9
  • 2.6.0
    • Merge 3.9/master branches
  • 2.7.0
    • Include Python 3.10 support and update requirements
  • 2.7.1
    • Bugfix (source flows not counted correctly in _add_transition_flow)
  • 3.1.0
    • Parameter aware summer using computegraph
  • 3.1.1
    • Update computegraph and add additional param awareness
  • 3.1.2
    • Initial population/stratification now param aware
  • 3.1.3
    • More jax implementation (strain stratification)
  • 3.1.4
    • Bugfix release (jax imported even though optional)
  • 3.1.5
    • Bugfix and minor improvements search for parameters
  • 3.1.6
    • Support lists of adjustments and flow params
  • 4.0.0a
    • Full jax support with ModelBuilder wrapper
  • 4.1.0a
    • Abstract and lazy parameters
  • 4.2.0a
    • Refactor parameters, combine runners

Release process

To do a release:

  • Commit any code changes and push them to GitHub
  • Choose a new release number accoridng to Semantic Versioning
  • Add a release note above
  • Edit the version key in pyproject.toml to reflect the release number
  • Publish the package to PyPI using Poetry, you will need a PyPI login and access to the project
  • Commit the release changes and push them to GitHub (Use a commit message like "Release 1.1.0")
  • Update requirements.txt in Autumn to use the new version of Summer
poetry build
poetry publish

Documentation

Sphinx is used to automatically build reference documentation for this library. The documentation is automatically built and deployed to summerepi.com whenever code is pushed to master.

To run or edit the code examples in the documentation, start a jupyter notebook server as follows:

jupyter notebook --config docs/jupyter_notebook_config.py
# Go to http://localhost:8888/tree/docs/examples in your web browser.

You can clean outputs from all the example notbooks with

./docs/scripts/clean.sh

To build and deploy

./docs/scripts/build.sh
./docs/scripts/deploy.sh

To work on docs locally

./docs/scripts/watch.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

summerepi2-1.0.1b2.tar.gz (61.2 kB view details)

Uploaded Source

Built Distribution

summerepi2-1.0.1b2-py3-none-any.whl (66.5 kB view details)

Uploaded Python 3

File details

Details for the file summerepi2-1.0.1b2.tar.gz.

File metadata

  • Download URL: summerepi2-1.0.1b2.tar.gz
  • Upload date:
  • Size: 61.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.9.13 Windows/10

File hashes

Hashes for summerepi2-1.0.1b2.tar.gz
Algorithm Hash digest
SHA256 67f2bd47fe648db274552ee3ad71cc4270d0463bcb836928c4256bc29a919c59
MD5 73058b210b9671d198c4dc6cc2fdc752
BLAKE2b-256 4e6c4e947179e95498d3f55f1e5c0aa36b7b8267ef3a874d409130932b08482c

See more details on using hashes here.

File details

Details for the file summerepi2-1.0.1b2-py3-none-any.whl.

File metadata

  • Download URL: summerepi2-1.0.1b2-py3-none-any.whl
  • Upload date:
  • Size: 66.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.9.13 Windows/10

File hashes

Hashes for summerepi2-1.0.1b2-py3-none-any.whl
Algorithm Hash digest
SHA256 b66c5b66f48f621ab8c6ad60ecf271cb6cb50141ce67297d30f5502f8c8ac323
MD5 0a5b1c9487dbc62924089bfba4d8e709
BLAKE2b-256 279af18b8f7a29f6378358eebfddb21800deb75864db6ce5b08ad33ac632334f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page