Fix baseexport: serialize hetero delays, capture resolved integrator, handle NetworkOperation#76
Open
Sanchit2662 wants to merge 3 commits intobrian-team:masterfrom
Conversation
… handle NetworkOperation Signed-off-by: Sanchit2662 <sanchit2662@gmail.com>
Author
|
Hi @mstimberg , please review the changes. |
Member
|
Hi @Sanchit2662. These additions do sound useful, but did you actually try running your code? There is an incorrect import, and I don't think the {'index': 'True',
'source': 'synapses_pre',
'type': 'initializer',
'value': 'rand() * 5*ms',
'variable': 'delay'}inside the |
Signed-off-by: Sanchit2662 <sanchit2662@gmail.com>
Author
|
Hi @mstimberg , I have made the changes. |
Member
|
Hi @Sanchit2662. Could you please merge latest |
…lays-integrator-networkop
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.
Summary
I was going through the baseexport collector and found three issues that were silently breaking things.
The
firstone was in collect_Synapses. The delay was only being serialized when it was a scalar value (single delay for all synapses). If you had per-synapse delays like S.delay = 'rand() * 5*ms', that condition would be false and the entire delay array would just get dropped from the export with no warning. The fix is literally removing that condition. obj.delay[:] works fine for both scalar and array cases, so there was no reason to guard it in the first place.The
secondone was in collect_NeuronGroup and collect_SpatialNeuron. When a user doesn't specify a method explicitly, Brian2 still picks one at runtime (like exact or exponential_euler) but we were just storing None in the export. There was even a TODO comment there acknowledging it. I fixed it by looking at the StateUpdater object's method_choice during the contained objects loop, where the runtime-resolved method is actually available. It gets stored as resolved_method so an importer can explicitly set the same integrator rather than relying on Brian2's auto-selection which might differ across versions.The
thirdone was NetworkOperation. If you had a @network_operation in your network, the exporter would just crash with a NotImplementedError. I added NetworkOperation to supported_objs so it no longer blows up, wrote a collect_NetworkOperation function that captures the scheduling metadata (name, dt, when, eorder), and added a logger warning so the user knows the function body itself isn't captured. It's honest about what it can and can't do rather than just crashing.