Prefix local variables in the Cython `synapses.pyx` template with underscores (fixes #1906) #1908
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 284 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.338
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1908"
general
weight: 0.35
mstimberg
Fixes #1906.
The Cython template for synaptic propagation used
ias its loop counter, which clashed with the presynaptic indexiinon_pre/on_postcode. As discussed in the issue, this renames all local variables ofsynapses.pyxwith a leading underscore, so they can't clash with user-defined names:| Before | After |
|---|---|
|
i|_spike_idx||
num_spikes|_num_spikes||
synapse_id|_synapse_id||
spike_data|_spike_data||
spike_vector|_spike_vector||
cpp_queue|_cpp_queue||
capsule|_capsule|The new names don't appear anywhere else in the Cython runtime or templates, apart from
_num_spikesinratemonitor.pyx, which is compiled as a separate module.Test
New
test_transmission_names_of_template_variablesintest_synapses.py(standalone compatible):on_pre="v_post += i"on_post="u_pre += i", with presynaptic indices 5 to 9 only. A clash with the loop counter then makes the loop stop early, so a regression shows up as a test failure instead of a hang. The hang can't be interrupted by pytest-timeout, because the loop is compiled code.num_spikes,synapse_id,spike_data,spike_vector,cpp_queueandcapsule, used inon_preOn macOS (arm64, Apple clang 21.0.0, Python 3.13.15, Cython 3.3.0, numpy 2.5.4):
cython(vis[0, 0, 0]instead of[0, 1, 2];uis[0, 0, 0, 0, 0, 5, 0, 0, 0, 0]instead of[0, 0, 0, 0, 0, 5, 6, 7, 8, 9]; Cython reports'num_spikes' redeclaredetc.).numpy,cythonandcpp_standalone.cythontest suite, including long and codegen-independent tests: 56 doctests and 455 codegen-independent tests passed; 316 Cython tests passed, 10 skipped. The only failure wastest_spikegenerator_rounding_longhitting the 1 h pytest timeout while running in parallel with the other workers. Run on its own, it passes and takes the same time with and without this change (37:27 vs. 37:20 onmaster).ruff format --check(v0.14.2) reports no changes.The examples from the issue now give the same results as
numpywithcython([0. 1. 2.]and[2. 4. 6.], the latter finishing in a few seconds).