Skip to content

Commit

Permalink
address code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ntolley committed Jul 10, 2024
1 parent c21c332 commit c9c7c23
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
10 changes: 5 additions & 5 deletions hnn_core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,11 +1378,11 @@ def clear_drives(self):
conn['src_type'] not
in self.external_drives.keys()]

for cell_type in list(self.gid_ranges.keys()):
if cell_type in self.external_drives:
self._n_gids -= len(self.gid_ranges[cell_type])
del self.gid_ranges[cell_type]
del self.pos_dict[cell_type]
for cell_name in list(self.gid_ranges.keys()):
if cell_name in self.external_drives:
self._n_gids -= len(self.gid_ranges[cell_name])
del self.gid_ranges[cell_name]
del self.pos_dict[cell_name]

self.external_drives = dict()

Expand Down
34 changes: 26 additions & 8 deletions hnn_core/tests/test_drives.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,37 @@ def test_clear_drives(setup_net):
weights_ampa=weights_ampa, location='proximal',
synaptic_delays=synaptic_delays, cell_specific=True)

assert len(net.external_drives) > 0
net.add_evoked_drive(
'dist', mu=40, sigma=8.33, numspikes=1,
weights_ampa=weights_ampa, location='distal',
synaptic_delays=synaptic_delays, cell_specific=True)

for drive_name in ['prox', 'dist']:
assert len(net.external_drives) == 2
assert drive_name in net.external_drives
assert drive_name in net.gid_ranges
assert drive_name in net.pos_dict
assert net._n_gids == n_gids + len(net.gid_ranges['L5_pyramidal']) * 2

net.clear_drives()
for drive_name in ['prox', 'dist']:
assert len(net.external_drives) == 0
assert drive_name not in net.external_drives
assert drive_name not in net.gid_ranges
assert drive_name not in net.pos_dict
assert net._n_gids == n_gids

net.add_evoked_drive(
'prox', mu=40, sigma=8.33, numspikes=1,
weights_ampa=weights_ampa, location='proximal',
synaptic_delays=synaptic_delays, cell_specific=True)

assert len(net.external_drives) == 1
assert 'prox' in net.external_drives
assert 'prox' in net.gid_ranges
assert 'prox' in net.pos_dict
assert net._n_gids == n_gids + len(net.gid_ranges['L5_pyramidal'])

net.clear_drives()
assert len(net.external_drives) == 0
assert 'prox' not in net.external_drives
assert 'prox' not in net.gid_ranges
assert 'prox' not in net.pos_dict
assert net._n_gids == n_gids


def test_add_drives():
"""Test methods for adding drives to a Network."""
Expand Down

0 comments on commit c9c7c23

Please sign in to comment.