8
8
__author__ = 'fccoelho'
9
9
10
10
import numpy as np
11
- from scipy .stats .distributions import poisson , nbinom
12
- from numpy import inf , nan , nan_to_num
13
- import sys
14
- import logging
11
+ # from scipy.stats.distributions import poisson, nbinom
12
+ # from numpy import inf, nan, nan_to_num
13
+ # import sys
14
+ # import logging
15
15
from collections import OrderedDict
16
- import cython
16
+ # import cython
17
+ from typing import Dict , List , Iterable , Any
18
+ # import numba
19
+ # from numba.experimental import jitclass
17
20
from epimodels import BaseModel
18
21
19
22
model_types = {
@@ -76,7 +79,6 @@ def run(self, *args):
76
79
raise NotImplementedError
77
80
78
81
def __call__ (self , * args , ** kwargs ):
79
- # args = self.get_args_from_redis()
80
82
res = self .run (* args )
81
83
self .traces .update (res )
82
84
# return res
@@ -511,7 +513,15 @@ def model(self, inits, trange, totpop, params):
511
513
512
514
return {'time' : tspan , 'S' : S , 'I' : I , 'E' : E , 'R' : R }
513
515
514
-
516
+ # from numba.types import unicode_type, pyobject
517
+ # spec = [
518
+ # ('model_type', unicode_type),
519
+ # ('state_variables', pyobject),
520
+ # ('parameters', pyobject),
521
+ # ('run', pyobject)
522
+ # ]
523
+ #
524
+ # @jitclass(spec)
515
525
class SIRS (DiscreteModel ):
516
526
def __init__ (self ):
517
527
super ().__init__ ()
@@ -520,11 +530,16 @@ def __init__(self):
520
530
self .parameters = {'beta' : r'$\beta$' , 'b' : 'b' , 'w' : 'w' }
521
531
self .run = self .model
522
532
523
- def model (self , inits , trange , totpop , params ):
533
+
534
+ # @numba.jit
535
+ def model (self , inits : List , trange : List , totpop : int , params : Dict ) -> Dict :
524
536
"""
525
537
calculates the model SIRS, and return its values (no demographics)
526
- - inits = (E,I,S)
527
- - theta = infectious individuals from neighbor sites
538
+ :param inits: (E,I,S)
539
+ :param trange:
540
+ :param totpop:
541
+ :param params:
542
+ :return:
528
543
"""
529
544
S : np .ndarray = np .zeros (trange [1 ] - trange [0 ])
530
545
I : np .ndarray = np .zeros (trange [1 ] - trange [0 ])
@@ -565,7 +580,7 @@ def __init__(self):
565
580
566
581
self .run = self .model
567
582
568
- def model (self , inits , trange , totpop , params ) -> list :
583
+ def model (self , inits , trange , totpop , params ) -> dict :
569
584
S : np .ndarray = np .zeros (trange [1 ] - trange [0 ])
570
585
E : np .ndarray = np .zeros (trange [1 ] - trange [0 ])
571
586
I : np .ndarray = np .zeros (trange [1 ] - trange [0 ])
0 commit comments