ukhsa-collaboration / pygom

ODE modelling in Python
GNU General Public License v2.0
27 stars 20 forks source link

Use of derived_param argument option in intiating mode causes NameError when using R0 function. #64

Open m-d-grunnill opened 2 years ago

m-d-grunnill commented 2 years ago

If derived_param argument is used when intiating a model, the later use of the pygom.model.epi_analysis.R0 can cause a NameError. So for example if the term 'lambda__' was being used for transmission instead of the full force of infection equation the following error would be thrown when using pygom.model.epi_analysis.R0:

Traceback (most recent call last):
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\IPython\core\interactiveshell.py", line 3444, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-13-e9cf6dd5a5ac>", line 7, in <module>
    model_R0 = R0(mg_model,disease_states)
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\pygom-0.18-py3.9-win-amd64.egg\pygom\model\epi_analysis.py", line 75, in R0
    F, V = disease_progression_matrices(ode, disease_state)
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\pygom-0.18-py3.9-win-amd64.egg\pygom\model\epi_analysis.py", line 159, in disease_progression_matrices
    ode2 = SimulateOde(ode.state_list, ode.param_list, transition=FList)
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\pygom-0.18-py3.9-win-amd64.egg\pygom\model\simulate.py", line 79, in __init__
    super(SimulateOde, self).__init__(state,
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\pygom-0.18-py3.9-win-amd64.egg\pygom\model\deterministic.py", line 71, in __init__
    super(DeterministicOde, self).__init__(state,
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\pygom-0.18-py3.9-win-amd64.egg\pygom\model\base_ode_model.py", line 172, in __init__
    self._transitionVector = self._computeTransitionVector()
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\pygom-0.18-py3.9-win-amd64.egg\pygom\model\base_ode_model.py", line 964, in _computeTransitionVector
    _f, _t, eqn = self._unrollTransitionList(self._getAllTransition())
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\pygom-0.18-py3.9-win-amd64.egg\pygom\model\base_ode_model.py", line 1092, in _unrollTransitionList
    eqn_list = checkEquation(eqn_list, *self._getListOfVariablesDict())
  File "C:\Users\mdgru\anaconda3\envs\amr\lib\site-packages\pygom-0.18-py3.9-win-amd64.egg\pygom\model\_model_verification.py", line 101, in checkEquation
    _eqn = eval(_inputStr)
  File "<string>", line 1, in <module>
NameError: name 'lambda__' is not defined