Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kenblu24
Copy link
Collaborator

@kenblu24 kenblu24 commented Sep 5, 2025

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.

@kenblu24 kenblu24 requested a review from Copilot September 5, 2025 08:50
Copy link
Contributor

Copilot AI left a 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(), and delete_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]
Copy link

Copilot AI Sep 5, 2025

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.

Suggested change
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]

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

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.

@kenblu24 kenblu24 merged commit efc2498 into ORNL:main Sep 5, 2025
8 checks passed
@kenblu24 kenblu24 linked an issue Sep 26, 2025 that may be closed by this pull request
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.

<Suggestion> Ability to delete Neurons and Synapses

1 participant