Skip to content

Fix run() with callbacks never ending on NEURON - #866

Merged
apdavison merged 1 commit into
NeuralEnsemble:masterfrom
apdavison:fix-run-until-callbacks
Nov 19, 2026
Merged

apdavison merged 1 commit into
NeuralEnsemble:masterfrom
apdavison:fix-run-until-callbacks

Conversation

@apdavison

Copy link
Copy Markdown
Member

With callbacks, run() and run_until() can loop forever on NEURON. NEURON stops at the last time step before an off-grid target time, so when the end time is not a multiple of the time step (e.g. run(10.07) with dt = 0.1), t never reaches it. A callback that asks to be called again less than one time step later stalls the loop in the same way (on NEST it raises an error instead).

Here, we make each step of the callback loop advance by at least one time step, and stop the loop if a step makes no progress. On-grid runs behave as before. A callback asking for less than one time step ahead is now called once per time step, which is mentioned in the documentation.

The new system tests cover callback intervals that are not a multiple of the time step, intervals shorter than the time step (all backends), and an off-grid end time (NEURON, Brian2 and Arbor, since NEST does not accept off-grid times).

This replaces #815, which reported the problem.

NEURON stops at the last time step before an off-grid target time, so when `time_point` is off the time grid, `t` cannot reach it and the loop does not end. A callback asking for less than one time step ahead also stalls the loop.

Reported in NeuralEnsemble#815.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 74.196% (+0.006%) from 74.19% — apdavison:fix-run-until-callbacks into NeuralEnsemble:master

@apdavison
apdavison merged commit 36b1c06 into NeuralEnsemble:master Nov 19, 2026
9 checks passed
@apdavison
apdavison deleted the fix-run-until-callbacks branch November 19, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants