[med-svn] [Git][med-team/python-epimodels][upstream] New upstream version 0.4.0

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



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


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


6 changed files:

- condarecipe/epimodels/meta.yaml
- + 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


=====================================
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/-/commit/3d75ef56a571a2a6c31def1ad3b794880f37cf43

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-epimodels/-/commit/3d75ef56a571a2a6c31def1ad3b794880f37cf43
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/b4f5f53c/attachment-0001.htm>


More information about the debian-med-commit mailing list