New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1-timestep difference when running certain simulations in standalone mode #695

mstimberg opened this Issue May 10, 2016 · 0 comments


None yet
1 participant

mstimberg commented May 10, 2016

The following code will run for 250 time steps in runtime mode but for 251 steps in standalone:

from brian2 import *
defaultclock.dt = 20.000000000020002*us
G = NeuronGroup(1, 'v:1')
mon = StateMonitor(G, 'v', record=True)
print len(mon.t)

The example may look contrived, but @romainbrette stumbled across this in a real use case, the weird dt value was of course not specified manually but taken from the difference between two time stamps in a file.

The reason for this issue is actually quite simple: we insert the desired runtime as a string into the standalone code, using default string formatting which does not preserve the full precision. We should instead force the use of the repr representation:

dt_float = float(20.000000000020002*us)

I had a quick check and it seems for other constants we are already using the conversion via repr, so they should be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment