fix(dyn/neurons): CondNeuGroup synaptic-current scaling (1000x attenuation)#842
Merged
Merged
Conversation
… by 1e-3/A CondNeuGroup scaled incoming synaptic current by the membrane-area factor 1e-3/A (a 1000x attenuation whenever A != 1e-3); synaptic input is already a current density and must be injected unscaled via the derivative, matching CondNeuGroupLTC. (High) Findings recorded in docs/issues-found-20260619-dyn-neurons.md
Reviewer's GuideFixes a 1000x attenuation bug in CondNeuGroup synaptic current handling by treating synaptic inputs as current densities in the derivative (consistent with CondNeuGroupLTC), adds regression tests to lock in the behavior and ensure external injected currents remain correctly scaled, and documents audit findings for neuron/channel/ion modules, including one high-priority bug fix and several low-priority style/documentation issues. Sequence diagram for CondNeuGroup synaptic-current scaling fixsequenceDiagram
actor Sim
participant CondNeuGroup
participant CondNeuGroupLTC
participant SynInputs
participant Channels
Sim->>CondNeuGroup: update(x_external)
CondNeuGroup->>SynInputs: sum_current_inputs(V, init=0.)
SynInputs-->>CondNeuGroup: syn_density
CondNeuGroup->>CondNeuGroup: _syn_current = syn_density
CondNeuGroup->>CondNeuGroupLTC: update(x_external)
CondNeuGroupLTC->>CondNeuGroupLTC: x = x * (1e-3 / A)
CondNeuGroupLTC->>CondNeuGroup: derivative(V, t, x)
CondNeuGroup->>CondNeuGroup: I = x + _syn_current
CondNeuGroup->>Channels: current(V)
Channels-->>CondNeuGroup: channel_density
CondNeuGroup->>CondNeuGroup: I = I + channel_density
CondNeuGroup-->>CondNeuGroupLTC: I / C
CondNeuGroupLTC-->>Sim: updated state
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
CondNeuGroup,_syn_currentis defined as a class-level attribute and then mutated per instance; consider initializing it in__init__(or another instance-level setup) to avoid accidental cross-instance sharing or confusion for static analyzers. - The new
CondNeuGroup.update/derivativecoupling relies onupdatebeing called beforederivativeso_syn_currentis set; ifderivativecan be used independently (e.g., by analysis tools), consider guarding against stale_syn_currentor computing synaptic density lazily insidederivativewhen needed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `CondNeuGroup`, `_syn_current` is defined as a class-level attribute and then mutated per instance; consider initializing it in `__init__` (or another instance-level setup) to avoid accidental cross-instance sharing or confusion for static analyzers.
- The new `CondNeuGroup.update`/`derivative` coupling relies on `update` being called before `derivative` so `_syn_current` is set; if `derivative` can be used independently (e.g., by analysis tools), consider guarding against stale `_syn_current` or computing synaptic density lazily inside `derivative` when needed.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fresh review of
brainpy/dyn/{neurons,channels,ions}.High —
CondNeuGroupscaled incoming synaptic current by the membrane-area factor1e-3/A, a silent 1000x attenuation of synaptic drive wheneverA != 1e-3. Synaptic input is already a current density and is now injected unscaled via the derivative (matchingCondNeuGroupLTC); external injected current stays correctly density-converted.Prior-audit channel/neuron findings (HH/Markov NaN at voltage singularity, etc.) were verified already-fixed. Regression tests added (263 passed in-scope). Findings:
docs/issues-found-20260619-dyn-neurons.md.Summary by Sourcery
Fix synaptic current density scaling in CondNeuGroup and document neuron/channel audit findings.
Bug Fixes:
Enhancements:
Documentation:
Tests: