Skip to content

Commit

Permalink
fix: Fixed issue where read-in of hierarchical json with read_drives=…
Browse files Browse the repository at this point in the history
… False, did not clear drive connectivity.
  • Loading branch information
gtdang committed Jul 5, 2024
1 parent 4b7fdd7 commit 1acda1e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hnn_core/hnn_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,8 @@ def _set_from_cell_specific(drive_data):
return drive_data['n_drive_cells']


def _read_external_drive(net, drive_data, read_drives, read_output):
def _read_external_drive(net, drive_data, read_output):
"""Adds drives encoded in json data to a Network"""
if not read_drives:
return None

if (drive_data['type'] == 'evoked') or (drive_data['type'] == 'gaussian'):
# Skipped n_drive_cells here
Expand Down Expand Up @@ -439,7 +437,7 @@ def read_network_configuration(fname, read_drives=True):
net_data['external_drives'])
for key in external_drive_data.keys():
_read_external_drive(net, external_drive_data[key],
read_output=False, read_drives=read_drives)
read_output=False)
# Set external biases
net.external_biases = net_data['external_biases']
# Set connectivity
Expand All @@ -451,4 +449,7 @@ def read_network_configuration(fname, read_drives=True):
# Set delay
net.delay = net_data['delay']

if not read_drives:
net.clear_drives()

return net
13 changes: 13 additions & 0 deletions hnn_core/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,19 @@ def test_read_configuration_json(jones_2009_network):
)
assert net == jones_2009_network

# Read without drives
net_no_drives = read_network_configuration(
Path(assets_path, 'jones2009_3x3_drives.json'),
read_drives=False
)
# Check there are no external drives
assert len(net_no_drives.external_drives) == 0
# Check there are no external drive connections
connection_src_types = [connection['src_type']
for connection in net_no_drives.connectivity]
assert not any([src_type in net.external_drives.keys()
for src_type in connection_src_types])


def test_read_incorrect_format(tmp_path):
"""Test that error raise when the json do not have a Network label."""
Expand Down

0 comments on commit 1acda1e

Please sign in to comment.