-
Notifications
You must be signed in to change notification settings - Fork 5
Allow for deletion of neurons and synapses semi-sanely #27
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements deletion functionality for neurons and synapses in the neuromorphic model, providing four new methods to safely remove components while managing index reordering.
Key changes:
- Adds
delete_neuron(),delete_neurons(),delete_synapse(), anddelete_synapses()methods - Implements automatic index remapping to maintain consistency after deletions
- Handles cascading synapse deletions when neurons are removed
- Updates cached objects (neurons, synapses, and list views) with new indices
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/test_deletion.py | New test file covering basic deletion functionality scenarios |
| src/superneuromat/neuromorphicmodel.py | Core deletion methods implementation with index management |
| pyproject.toml | Adds deletion test to test suite configuration |
| docs/source/api/SNN.rst | Documents the new deletion methods in API reference |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| indices = set(nlist.indices) | ||
| overlap = indices & mapping.keys() | ||
| if overlap: | ||
| nlist.indices = [mapping[i] for i in nlist.indices if i != neuron_id and i in mapping] |
Copilot
AI
Sep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable neuron_id is used here but it's not defined in this scope. This appears to be a copy-paste error from the single neuron deletion method. This should likely reference the current neuron being processed from the indices list.
| nlist.indices = [mapping[i] for i in nlist.indices if i != neuron_id and i in mapping] | |
| nlist.indices = [mapping[i] for i in nlist.indices if i in mapping] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a bug? I've fixed this and added a test for multi-neuron deletion just in case.
Implements four functions, which allow you to delete Neuron(s) or Synapse(s) from the model, and help you deal
with the fallout of the huge changes in model index.
This makes use of the Neuron, Synapse, and associated *ListView caching on the model, so that the model knows to update those accessors with the new indices.
Includes basic tests for this, but the functionality is complicated, so more comprehensive tests may be needed in the future.
Includes super-basic docstrings, but this needs to be more well explained in a separate guide for sure. Users may not understand what's going on under the hood or how silly what I've done here is, so maybe a guide to the way SNM stores neuron/synapse parameters is in order.