[med-svn] [Git][med-team/python-epimodels][master] 5 commits: New upstream version 0.4.0

Andreas Tille (@tille) gitlab at salsa.debian.org
Fri Nov 25 07:35:29 GMT 2022



Andreas Tille pushed to branch master at Debian Med / python-epimodels


Commits:
3d75ef56 by Andreas Tille at 2022-11-25T08:08:27+01:00
New upstream version 0.4.0
- - - - -
8a2ee81a by Andreas Tille at 2022-11-25T08:08:27+01:00
routine-update: New upstream version

- - - - -
41d0b627 by Andreas Tille at 2022-11-25T08:08:27+01:00
Update upstream source from tag 'upstream/0.4.0'

Update to upstream version '0.4.0'
with Debian dir 4b6891d267ae7d932a76d685982d8737154c0c88
- - - - -
dfe42c35 by Andreas Tille at 2022-11-25T08:08:28+01:00
routine-update: Standards-Version: 4.6.1

- - - - -
b000a762 by Andreas Tille at 2022-11-25T08:35:07+01:00
TODO: Wait until python3-llvmlite (precondition for python3-numba) is installable again

- - - - -


8 changed files:

- condarecipe/epimodels/meta.yaml
- debian/changelog
- debian/control
- + pyproject.toml
- requirements.txt
- src/epimodels/continuous/models.py
- src/epimodels/discrete/models.py
- tests/test_continuous_models.py


Changes:

=====================================
condarecipe/epimodels/meta.yaml
=====================================
@@ -1,5 +1,5 @@
 {% set name = "epimodels" %}
-{% set version = "0.3.19" %}
+{% set version = "0.3.20" %}
 
 package:
   name: "{{ name|lower }}"
@@ -7,7 +7,7 @@ package:
 
 source:
   url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz"
-  sha256: 8dec0de96e6ec506e3c61b7af6d687791c6db0eb5f74a90538f2844505db60e8
+  sha256: 8424e5487136dadfae92eb620a75a7cb174325c72be941a280900fc365e61ada
 
 build:
   number: 0


=====================================
debian/changelog
=====================================
@@ -1,8 +1,11 @@
-python-epimodels (0.3.20-2) UNRELEASED; urgency=medium
+python-epimodels (0.4.0-1) UNRELEASED; urgency=medium
 
   * Use tags in d/watch
+  * New upstream version
+  * Standards-Version: 4.6.1 (routine-update)
+  TODO: Wait until python3-llvmlite (precondition for python3-numba) is installable again
 
- -- Andreas Tille <tille at debian.org>  Wed, 22 Dec 2021 16:00:10 +0100
+ -- Andreas Tille <tille at debian.org>  Fri, 25 Nov 2022 08:08:27 +0100
 
 python-epimodels (0.3.20-1) unstable; urgency=medium
 


=====================================
debian/control
=====================================
@@ -14,7 +14,7 @@ Build-Depends: debhelper-compat (= 13),
                python3-scipy <!nocheck>,
                python3-pytest <!nocheck>,
                python3-pytest-cov <!nocheck>
-Standards-Version: 4.6.0
+Standards-Version: 4.6.1
 Vcs-Browser: https://salsa.debian.org/med-team/python-epimodels
 Vcs-Git: https://salsa.debian.org/med-team/python-epimodels.git
 Homepage: https://github.com/fccoelho/epimodels


=====================================
pyproject.toml
=====================================
@@ -0,0 +1,23 @@
+[tool.poetry]
+name = "epimodels"
+description= "Library of mathematical epidemic models for use in simulation studies and inference"
+authors= ["Flávio Codeço Coelho"]
+version = "0.3.21"
+homepage = "https://github.com/fccoelho/epimodels"
+
+[tool.poetry.dependencies]
+python = "^3.9"
+cython = "0.29.32"
+numpy = "^1.23.3"
+scipy = "^1.9.2"
+matplotlib = "^3.6.1"
+mypy = "==0.982"
+pyitlib = "*"
+sphinx = "*"
+sympy = "^1.11.1"
+
+[tool.poetry.dev-dependencies]
+pytest = {optional = true, version = "*"}
+pytest-cov = {optional = true, version = "*"}
+nox-poetry = "^1.0.1"
+autoflake8 = "^0.4.0"


=====================================
requirements.txt
=====================================
@@ -14,4 +14,3 @@ matplotlib
 mypy
 sphinx
 pyitlib
-numba


=====================================
src/epimodels/continuous/models.py
=====================================
@@ -9,7 +9,6 @@ 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)
 
@@ -33,6 +32,15 @@ class ContinuousModel(BaseModel):
         #     logging.Error('Invalid model type: {}'.format(model_type))
 
     def __call__(self, inits: list, trange: list, totpop: float, params: dict, method: str = 'RK45', **kwargs):
+        """
+        Run the model
+        :param inits: initial contitions
+        :param trange: time range: [t0, tf]
+        :param totpop: total population size
+        :param params: dictionary of parameters
+        :param method: integration method. default is 'RK45'
+        :param kwargs: Additional parameters passed on to solve_ivp
+        """
         self.method = method
         self.kwargs = kwargs
         sol = self.run(inits, trange, totpop, params, **kwargs)
@@ -60,7 +68,7 @@ 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.
@@ -78,6 +86,28 @@ class SIR(ContinuousModel):
         ]
 
 
+class SIR1D(ContinuousModel):
+    def __init__(self):
+        super().__init__()
+        self.state_variables = OrderedDict({'R': 'Recovered'})
+        self.parameters = {'R0': r'{\cal R}_0', 'gamma': r'\gamma', 'S0': r'S_0'}
+        self.model_type = 'SIR1D'
+
+    def _model(self, t: float, y: list, params: dict) -> list:
+        """
+        One dimensional SIR model
+        :param t:
+        :param y:
+        :param params:
+        """
+        N = params['N']
+        R = y
+        R0, gamma, S0 = params['R0'], params['gamma'], params['S0']
+        return [
+            gamma * (N - R - (S0 * np.exp(-R0 * R)))
+        ]
+
+
 class SIS(ContinuousModel):
     def __init__(self):
         super().__init__()
@@ -86,7 +116,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.
@@ -110,7 +140,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.
@@ -135,7 +165,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']
@@ -160,7 +190,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
=====================================
@@ -15,8 +15,6 @@ import numpy as np
 from collections import OrderedDict
 # import cython
 from typing import Dict, List, Iterable, Any
-# import numba
-# from numba.experimental import jitclass
 from epimodels import BaseModel
 
 model_types = {


=====================================
tests/test_continuous_models.py
=====================================
@@ -22,6 +22,14 @@ def test_SIR_with_t_eval():
     assert len(model.traces['S']) == 500
     # assert len(model.traces['time']) == 50
 
+def test_SIR1D():
+    model = SIR1D()
+    model([0], [0, 500], 100, {'R0': 1.5, 'gamma': .1, 'S0': 98})
+    # assert len(model.traces['R']) == 500
+    assert len(model.traces) == 2
+    model.plot_traces()
+    P.show()
+
 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/d85b8d346f1aa556da1ae3a2fe8050c8e992da45...b000a7622a8f14eb42dbb1900dd2b737ea9f279e

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-epimodels/-/compare/d85b8d346f1aa556da1ae3a2fe8050c8e992da45...b000a7622a8f14eb42dbb1900dd2b737ea9f279e
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/20221125/3d81ca81/attachment-0001.htm>


More information about the debian-med-commit mailing list