ukhsa-collaboration / pygom

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

Occaisonal "TypeError: argument of type ‘bool’ is not iterable" at function tauLeap (line 552) of module pygom.stochastic_simulation. #62

Closed m-d-grunnill closed 3 months ago

m-d-grunnill commented 2 years ago

When running certain stochastic simulation through SimulateOde.simulate_jump methods the error "TypeError: argument of type ‘bool’ is not iterable" occasionally occurs. This happens in line 552 in function tauLeap of module pygom.model.stochastic_simulation. The error is caused by function _cy_test_tau_leap_safety (file pygom/model/_tau_leap.pyx). When failing to find a low enough tau/jump step _cy_test_tau_leap_safety returns the bool False. However, line 552 in the function tauLeap is expecting a numeric followed by a bool.

Changing _cy_test_tau_leap_safety return if fail from (lines 56-57 of file pygom/model/_tau_leap.pyx):

        if tau_scale*total_rate <= 1.0 or count > 256:
            return False

to:

        if tau_scale*total_rate <= 1.0 or count > 256:
            return tau_scale, False

Solves this issue.

twomagpi commented 3 months ago

Yes, good catch. This has been updated for #114