[med-svn] [Git][med-team/python-epimodels][master] 3 commits: Upstream has tagged release
Andreas Tille
gitlab at salsa.debian.org
Mon Feb 22 15:35:06 GMT 2021
Andreas Tille pushed to branch master at Debian Med / python-epimodels
Commits:
86e060f7 by Andreas Tille at 2021-02-22T16:28:35+01:00
Upstream has tagged release
- - - - -
5c49f65d by Andreas Tille at 2021-02-22T16:29:01+01:00
New upstream version 0.3.18
- - - - -
c6159d65 by Andreas Tille at 2021-02-22T16:29:02+01:00
Update upstream source from tag 'upstream/0.3.18'
Update to upstream version '0.3.18'
with Debian dir 7b867a0718e1d0a659d427b4b00f2c792de0d709
- - - - -
7 changed files:
- − .github/workflows/python-package.yml
- Pipfile
- debian/changelog
- debian/watch
- src/epimodels/continuous/models.py
- src/epimodels/discrete/models.py
- tests/test_continuous_models.py
Changes:
=====================================
.github/workflows/python-package.yml deleted
=====================================
@@ -1,39 +0,0 @@
-# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
-# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
-
-name: Python package
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
- strategy:
- matrix:
- python-version: [3.5, 3.6, 3.7, 3.8]
-
- steps:
- - uses: actions/checkout at v2
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python at v2
- with:
- python-version: ${{ matrix.python-version }}
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install flake8 pytest
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- - name: Lint with flake8
- run: |
- # stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- - name: Test with pytest
- run: |
- pytest
=====================================
Pipfile
=====================================
@@ -14,6 +14,7 @@ matplotlib = "*"
mypy = "*"
sphinx = "*"
pyitlib = "*"
+numba = "*"
[dev-packages]
=====================================
debian/changelog
=====================================
@@ -1,4 +1,4 @@
-python-epimodels (0.0+git20201022.2c49b90-1) UNRELEASED; urgency=medium
+python-epimodels (0.3.18-1) UNRELEASED; urgency=medium
* Initial release (Closes: #<bug>)
=====================================
debian/watch
=====================================
@@ -1,10 +1,4 @@
version=4
-opts="mode=git,pretty=0.0+git%cd.%h" \
- https://github.com/fccoelho/epimodels.git HEAD
-
-# Issue asking for release tags:
-# https://github.com/fccoelho/epimodels/issues/3
-
-#opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%@PACKAGE at -$1.tar.gz%" \
-#https://github.com/fccoelho/epimodels/releases .*/archive/v?@ANY_VERSION@\.tar\.gz
+opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%@PACKAGE at -$1.tar.gz%" \
+ https://github.com/fccoelho/epimodels/releases .*/archive/v?@ANY_VERSION@\.tar\.gz
=====================================
src/epimodels/continuous/models.py
=====================================
@@ -9,6 +9,7 @@ from epimodels import BaseModel
import logging
from collections import OrderedDict
from functools import lru_cache
+import numba
logging.basicConfig(filename='epimodels.log', filemode='w', level=logging.DEBUG)
@@ -59,13 +60,13 @@ class SIR(ContinuousModel):
self.state_variables = OrderedDict({'S': 'Susceptible', 'I': 'Infectious', 'R': 'Removed'})
self.parameters = OrderedDict({'beta': r'$\beta$', 'gamma': r'$\gamma$'})
self.model_type = 'SIR'
-
+ @numba.jit
def _model(self, t: float, y: list, params: dict) -> list:
"""
SIR Model.
- :param t:
- :param y:
- :param params:
+ :param t: time step
+ :param y: state of the model at time t
+ :param params: parameter dictionary
:return:
"""
S, I, R = y
@@ -85,6 +86,7 @@ class SIS(ContinuousModel):
self.model_type = 'SIS'
# @lru_cache(1000)
+ @numba.jit
def _model(self, t: float, y: list, params: dict) -> list:
"""
SIS Model.
@@ -108,6 +110,7 @@ class SIRS(ContinuousModel):
self.parameters = OrderedDict({'beta': r'$\beta$', 'gamma': r'$\gamma$', 'xi': r'$\xi$'})
self.model_type = 'SIRS'
+ @numba.jit
def _model(self, t: float, y: list, params: dict) -> list:
"""
SIR Model.
@@ -132,6 +135,7 @@ class SEIR(ContinuousModel):
self.parameters = OrderedDict({'beta': r'$\beta$', 'gamma': r'$\gamma$', 'epsilon': r'$\epsilon$'})
self.model_type = 'SEIR'
+ @numba.jit
def _model(self, t: float, y: list, params: dict) -> list:
S, E, I, R = y
beta, gamma, epsilon, N = params['beta'], params['gamma'], params['epsilon'], params['N']
@@ -156,6 +160,7 @@ class SEQIAHR(ContinuousModel):
})
self.model_type = 'SEQIAHR'
+ @numba.jit
def _model(self, t: float, y: list, params: dict) -> list:
S, E, I, A, H, R, C, D = y
chi, phi, beta, rho, delta, gamma, alpha, mu, p, q, r, N = params.values()
=====================================
src/epimodels/discrete/models.py
=====================================
@@ -8,12 +8,15 @@ License: GPL-v3
__author__ = 'fccoelho'
import numpy as np
-from scipy.stats.distributions import poisson, nbinom
-from numpy import inf, nan, nan_to_num
-import sys
-import logging
+# from scipy.stats.distributions import poisson, nbinom
+# from numpy import inf, nan, nan_to_num
+# import sys
+# import logging
from collections import OrderedDict
-import cython
+# import cython
+from typing import Dict, List, Iterable, Any
+# import numba
+# from numba.experimental import jitclass
from epimodels import BaseModel
model_types = {
@@ -76,7 +79,6 @@ class DiscreteModel(BaseModel):
raise NotImplementedError
def __call__(self, *args, **kwargs):
- # args = self.get_args_from_redis()
res = self.run(*args)
self.traces.update(res)
# return res
@@ -511,7 +513,15 @@ class SEIpR(DiscreteModel):
return {'time': tspan, 'S': S, 'I': I, 'E': E, 'R': R}
-
+# from numba.types import unicode_type, pyobject
+# spec = [
+# ('model_type', unicode_type),
+# ('state_variables', pyobject),
+# ('parameters', pyobject),
+# ('run', pyobject)
+# ]
+#
+# @jitclass(spec)
class SIRS(DiscreteModel):
def __init__(self):
super().__init__()
@@ -520,11 +530,16 @@ class SIRS(DiscreteModel):
self.parameters = {'beta': r'$\beta$', 'b': 'b', 'w': 'w'}
self.run = self.model
- def model(self, inits, trange, totpop, params):
+
+ # @numba.jit
+ def model(self, inits: List, trange: List, totpop: int, params: Dict) -> Dict:
"""
calculates the model SIRS, and return its values (no demographics)
- - inits = (E,I,S)
- - theta = infectious individuals from neighbor sites
+ :param inits: (E,I,S)
+ :param trange:
+ :param totpop:
+ :param params:
+ :return:
"""
S: np.ndarray = np.zeros(trange[1] - trange[0])
I: np.ndarray = np.zeros(trange[1] - trange[0])
@@ -565,7 +580,7 @@ class SEQIAHR(DiscreteModel):
self.run = self.model
- def model(self, inits, trange, totpop, params) -> list:
+ def model(self, inits, trange, totpop, params) -> dict:
S: np.ndarray = np.zeros(trange[1] - trange[0])
E: np.ndarray = np.zeros(trange[1] - trange[0])
I: np.ndarray = np.zeros(trange[1] - trange[0])
=====================================
tests/test_continuous_models.py
=====================================
@@ -22,8 +22,6 @@ def test_SIR_with_t_eval():
assert len(model.traces['S']) == 500
# assert len(model.traces['time']) == 50
-
-
def test_SIS():
model = SIS()
model([1000, 1], [0, 50], 1001, {'beta': 2, 'gamma': .1})
View it on GitLab: https://salsa.debian.org/med-team/python-epimodels/-/compare/a8b54ee7b8268f0c3564989393d52b55e378ae71...c6159d65cf646a29e23b79f17dfb3734d5db6b5c
--
View it on GitLab: https://salsa.debian.org/med-team/python-epimodels/-/compare/a8b54ee7b8268f0c3564989393d52b55e378ae71...c6159d65cf646a29e23b79f17dfb3734d5db6b5c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20210222/31a2e2ad/attachment-0001.htm>
More information about the debian-med-commit
mailing list