Skip to content

Commit c36fe00

Browse files
authored
maint: read in pos_dict and cell_types (#1195)
This is related to #1168, and is required in order for @katduecker's new model to be successfully read in from Network JSON files. This makes a very tiny change in `hnn_io::dict_to_network`, affecting `hnn_io::read_network_configuration` among others. When a dictionary of `Network` parameters is being read in (such as from file), the `Network.pos_dict` and `Network.cell_types` data is passed from the originating dictionary to the `Network` initializer, instead of being added to the `Network` object after creation. This takes advantage of Chetan's updates to `Network` that can use these new arguments. This allows Network JSON files with custom `cell_types` and/or `pos_dict` to have that information read in, instead of having it overwritten with the defaults, which is what is done currently.
1 parent d97e77e commit c36fe00

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

hnn_core/hnn_io.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,20 +528,22 @@ def dict_to_network(net_data, read_drives=True, read_external_biases=True):
528528
mesh_shape = (net_data["N_pyr_x"], net_data["N_pyr_y"])
529529

530530
# Instantiating network
531-
net = Network(params, mesh_shape=mesh_shape, legacy_mode=net_data["legacy_mode"])
531+
net = Network(
532+
params,
533+
mesh_shape=mesh_shape,
534+
legacy_mode=net_data["legacy_mode"],
535+
pos_dict=_read_pos_dict(net_data["pos_dict"]),
536+
cell_types=_read_cell_types(net_data["cell_types"]),
537+
)
532538

533539
# Setting attributes
534-
# Set cell types
535-
net.cell_types = _read_cell_types(net_data["cell_types"])
536540
# Set gid ranges
537541
gid_ranges_data = dict()
538542
for key in net_data["gid_ranges"]:
539543
start = net_data["gid_ranges"][key]["start"]
540544
stop = net_data["gid_ranges"][key]["stop"]
541545
gid_ranges_data[key] = range(start, stop)
542546
net.gid_ranges = OrderedDict(gid_ranges_data)
543-
# Set pos_dict
544-
net.pos_dict = _read_pos_dict(net_data["pos_dict"])
545547
# Set cell_response
546548
net.cell_response = _read_cell_response(
547549
net_data["cell_response"], read_output=False

0 commit comments

Comments
 (0)