Skip to content

Commit

Permalink
Bugs in installation + Bump to version 0.2.4 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
twallema authored Dec 4, 2023
1 parent 5653895 commit 4ca1eda
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 51 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.10'
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[develop]
pip install -e."[develop]"
- name: Build documentation
run: |
python setup.py build_sphinx
sphinx-build docs build/sphinx/
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/sphinx/html/
publish_dir: ./build/sphinx/
if: github.event_name == 'push'
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pip install pySODM

Documentation: https://twallema.github.io/pySODM

Manuscript: https://arxiv.org/abs/2301.10664
Manuscript: https://www.sciencedirect.com/science/article/pii/S1877750323002089

pyPI: https://pypi.org/project/pySODM/

Expand Down Expand Up @@ -61,6 +61,8 @@ The [enzyme kinetics](enzyme_kinetics.md) and [influenza 17-18](influenza_1718.m
> Published to pyPI.
- Version 0.2.3 (2023-05-04, PR #46)
> Fixed minor bugs encountered when using pySODM for a dynamic input-output model of the Belgian economy. Published to pyPI.
- Version 0.2.4 (2023-12-04, PR #62)
> Validated the use of Python 3.11. Efficiency gains in simulation of jump processes. Ommitted dependency on Numba. All changes related to publishing our software manuscript in Journal of Computational Science. Improved nomenclature in model defenition.
- Version 0.1 (2022-12-23, PR #14)
> Application pySODM to three use cases. Documentation website. Unit tests for ODE, JumpProcess and calibration.
- Version 0.1.1 (2023-01-09, PR #20)
Expand Down
33 changes: 17 additions & 16 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ pip install pySODM

### Install pySODM in a conda environment

When making your own modeling and simulation project, we recommend storing your dependencies in a conda environment. Using a conda environment allows others to more quickly replicate your code. Make sure you have Python (conda) and the required dependency packages installed. We recommend using `Anaconda` to manage your Python packages. See the [conda installation instructions](https://docs.anaconda.com/anaconda/install/) and make sure you have conda up and running. Next:
When making your own modeling and simulation project, we recommend storing your dependencies in a conda environment. Using a conda environment allows others to more quickly replicate your code. Make sure you have Python (conda) and the required dependency packages installed. We recommend using `Anaconda` to manage your Python packages. See the [conda installation instructions](https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html) and make sure you have conda up and running. Next:

- Update conda after the installation to make sure your version is up-to-date,
```
conda update conda
```
- Make an environment file `environment.yml` with the dependencies of your own project. pySODM was validated on Python versions 3.9, 3.10 and 3.11.
- Make an environment file `environment.yml` with the dependencies of your own project. pySODM is currently validated on Python 3.11.
```
name: MY_ENVIRONMENT
Expand All @@ -25,7 +25,6 @@ When making your own modeling and simulation project, we recommend storing your
dependencies:
- python=3.11
- ...
- ...
```
- Setup/update the `environment`: Dependencies are collected in the conda `environment.yml` file (inside the root folder), so anybody can recreate the required environment using,
Expand All @@ -49,32 +48,34 @@ When making your own modeling and simulation project, we recommend storing your
pip install pySODM
```
__Note:__ This step needs to be done in a terminal or command prompt. Use your favorite terminal or use the [Anaconda Prompt](https://docs.anaconda.com/anaconda/user-guide/getting-started/#open-anaconda-prompt). Navigate with the `cd` command to the directory where you copied the `pySODM` repository.
__Note:__ The above step should be executed in a Linux terminal or command prompt. Use your favorite terminal or use the [Anaconda Prompt](https://docs.anaconda.com/anaconda/user-guide/getting-started/#open-anaconda-prompt).
### Want to try out the tutorials?
Installing pySODM from pyPI does not give you acces to the tutorials and case studies as these are on Github. To try them out,
- Download the source code from GitHub. When all went fine, you should have the code on your computer in a directory called `pySODM`.
Installing pySODM from pyPI does not give you acces to the tutorials and case studies as these are located in the source on Github. To try them out,
- All we need to do is setup the PYSODM environment inside `environment.yml` and install pySODM from source inside this environment,
- Download the [source code](https://github.com/twallema/pySODM) from GitHub. When all went fine, you should have the code on your computer in a directory called `pySODM`.
- An environment with the dependencies for the tutorials is available inside the `~/environment.yml` file (environment name: PYSODM). Open a terminal in the root folder and create the PYSODM environment:
```
conda env create -f environment.yml
```
- Activate the environment and install pySODM from source in it:
```
conda activate PYSODM
pip install -e
pip install -e.
```
### Want to work on pySODM?
- Create a [`github`](https://github.com/) account if you do not have one already.
- Create a [GitHub](https://github.com/) account if you do not have one already.
- On the [pySODM Github repository page](https://github.com/twallema/pySODM) click the `Fork` button.
- From your own repository page (your account) of `pySODM`, use [`git`](https://git-scm.com/) to download the code to your own computer. See the [Github documentation](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) on how to clone/download a repository.
When all went fine, you should have the code on your computer in a directory called `pySODM`. This folder contains an `environment.yml` file containing all the dependencies necessary to recreate the tutorials and case studies. Install pySODM in this environment with the development requirements (necessary to work on the documentation),
```
conda env create -f environment.yml
conda activate PYSODM
pip install -e ".[develop]"
```
```
conda env create -f environment.yml
conda activate PYSODM
pip install -e ".[develop]"
```
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pip install pySODM

Documentation: https://twallema.github.io/pySODM

Manuscript: https://arxiv.org/abs/2301.10664
Manuscript: https://www.sciencedirect.com/science/article/pii/S1877750323002089

pyPI: https://pypi.org/project/pySODM/

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name='pySODM',
packages=find_packages("src", exclude=["*.tests"]),
package_dir={'': 'src'},
version='0.2.3',
version='0.2.4',
description='Simulating and Optimising Dynamical Models',
author='Tijs Alleman, KERMIT, Ghent University',
author_email='[email protected]',
Expand Down
11 changes: 4 additions & 7 deletions tutorials/SIR/workflow_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
"""

__author__ = "Tijs Alleman & Wolf Demunyck"
__copyright__ = "Copyright (c) 2023 by T.W. Alleman, BIOSPACE, Ghent University. All Rights Reserved."
__copyright__ = "Copyright (c) 2024 by T.W. Alleman, BIOSPACE, Ghent University. All Rights Reserved."


############################
## Load required packages ##
############################

from pyexpat import model
import sys,os
import emcee
import datetime
# General purpose packages
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -215,10 +212,10 @@ def draw_fcn(param_dict, samples_dict):
return param_dict

# Attach its arguments to the parameter dictionary
params.update({'start_measures': end_date})
model.parameters.update({'start_measures': end_date})

# Initialize the model with the time dependent parameter funtion
model_with = ODE_SIR(states=init_states, parameters=params, time_dependent_parameters={'beta': lower_infectivity})
model_with = ODE_SIR(states=model.initial_states, parameters=model.parameters, time_dependent_parameters={'beta': lower_infectivity})

# Simulate the model
out_with = model_with.sim([start_date, end_date+pd.Timedelta(days=2*28)], N=100, samples=samples_dict, draw_function=draw_fcn, processes=processes)
Expand Down
5 changes: 2 additions & 3 deletions tutorials/SIR_SI/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
## Load required packages ##
############################

import sys,os
# General purpose packages
import corner
import pandas as pd
import numpy as np
Expand Down Expand Up @@ -85,7 +85,6 @@
objective_function = log_posterior_probability(model, pars, bounds, data, states, log_likelihood_fnc, log_likelihood_fnc_args, labels=labels)
# Initial guess --> pso
theta = pso.optimize(objective_function, swarmsize=3*18, max_iter=30, processes=18, debug=True)[0]
#theta = [7, 0.05, 0.1, 0.2, 0.15]
# Run Nelder-Mead optimisation
theta = nelder_mead.optimize(objective_function, theta, 0.10*np.ones(len(theta)), processes=18, max_iter=30)[0]
# Simulate the model
Expand Down Expand Up @@ -115,7 +114,7 @@
###########################

# Variables
n_mcmc = 1000
n_mcmc = 100
multiplier_mcmc = 9
processes = 9
print_n = 50
Expand Down
31 changes: 16 additions & 15 deletions tutorials/influenza_1718/calibration.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""
This script contains a calibration of an influenza model to 2017-2018 data.
This script contains the calibration of an influenza model to the 2017-2018 surveillance data
"""

__author__ = "Tijs Alleman & Wolf Demunyck"
__copyright__ = "Copyright (c) 2023 by T.W. Alleman, BIOSPACE, Ghent University. All Rights Reserved."
__copyright__ = "Copyright (c) 2024 by T.W. Alleman, BIOSPACE, Ghent University. All Rights Reserved."

############################
## Load required packages ##
############################

# General purpose packages
import os
import emcee
import random
Expand All @@ -32,19 +33,19 @@
## Settings ##
##############

tau = 0.50 # Timestep of Tau-Leaping algorithm
alpha = 0.03 # Overdispersion factor (based on COVID-19)
end_calibration = pd.Timestamp('2018-03-01')
identifier = 'twallema_2018-03-01'
n_pso = 3 # Number of PSO iterations
multiplier_pso = 36 # PSO swarm size
n_mcmc = 200 # Number of MCMC iterations
multiplier_mcmc = 36 # Total number of Markov chains = number of parameters * multiplier_mcmc
print_n = 100 # Print diagnostics every print_n iterations
discard = 1000 # Discard first `discard` iterations as burn-in
thin = 10 # Thinning factor emcee chains
n = 100 # Repeated simulations used in visualisations
processes = int(os.getenv('SLURM_CPUS_ON_NODE', mp.cpu_count()/2))
tau = 0.50 # Timestep of Tau-Leaping algorithm
alpha = 0.03 # Overdispersion factor (based on COVID-19)
end_calibration = pd.Timestamp('2018-03-01') # Enddate of calibration
identifier = 'twallema_2018-03-01' # Give any output of this script an ID
n_pso = 3 # Number of PSO iterations
multiplier_pso = 36 # PSO swarm size
n_mcmc = 50 # Number of MCMC iterations
multiplier_mcmc = 36 # Total number of Markov chains = number of parameters * multiplier_mcmc
print_n = 100 # Print diagnostics every print_n iterations
discard = 1000 # Discard first `discard` iterations as burn-in
thin = 10 # Thinning factor emcee chains
n = 100 # Repeated simulations used in visualisations
processes = int(os.getenv('SLURM_CPUS_ON_NODE', mp.cpu_count()/2)) # Automatically use half the number of available threads (typically corresponds to number of physical CPU cores)

###############
## Load data ##
Expand Down
2 changes: 0 additions & 2 deletions tutorials/influenza_1718/data_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

import os
import datetime
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

###############
## Load data ##
Expand Down

0 comments on commit 4ca1eda

Please sign in to comment.