ZeroDivisionError: float division

Hi @nvar . That’s a thorough report – you certainly “did your homework” :clap:. I don’t have time to run things myself right now, but here are a few techniques that can be really helpful to debug this kind of problem (and apologies that this is not really documented anywhere, I really want to enable this all automatically with some kind of debug mode in the future):

  • Use Python code generation instead of Cython: prefs.codegen.target = 'numpy'
  • Switch off some optimization that makes the link between code and equations less obvious: prefs.codegen.loop_invariant_optimisations = False
  • Make numpy raise errors for all kind of floating point problems, including division by 0: np.seterr(all='raise')

If you then run your simulation, you should get an error pointing to the line where the problem occurs. If you run this in an interactive console (or a jupyter notebook etc.), you can then verify the values of all variables used in the equation and should be able to see where exactly the division by zero occurs.

Hope that helps, best
Marcel

1 Like