Skip to content

Commit

Permalink
STY: cosmetic improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmainak committed May 28, 2020
1 parent 81d824f commit 917aff4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion hnn_core/feed.py
Expand Up @@ -180,7 +180,7 @@ def __create_extinput(self):
"""Creates the ongoing external inputs (rhythmic)."""
# print("__create_extinput")
# Return if all synaptic weights are 0
all_syn_weights_zero = True # fixes #101
all_syn_weights_zero = True
for key in self.p_ext.keys():
if key.startswith('L2Pyr') or \
key.startswith('L5Pyr') or \
Expand Down
43 changes: 17 additions & 26 deletions hnn_core/tests/test_feed.py
Expand Up @@ -21,29 +21,20 @@ def test_external_rhythmic_feeds():
'input_prox_A_weight_L2Pyr_ampa': 5.4e-5,
'input_prox_A_weight_L5Pyr_ampa': 5.4e-5,
't0_input_prox': 50})
net = Network(deepcopy(params))

# from Network.build: creates ExtFeeds in < 1 sec
net._create_all_src()
# needed to close the ParallelContext, else next pc will segfault
from hnn_core.parallel import pc
pc.gid_clear()

# annoyingly, net.extinput_list is always 2, whether populated
# or not, so the first few assertions have no effect
# the eventvec needs to be > 0, though (catches #101, tests #102)
assert len(net.extinput_list) == 2 # (distal & proximal)
for ei in net.extinput_list:
# naming could be better
assert ei.ty == 'extinput'
# eventvec is of type h.Vector
assert ei.eventvec.hname().startswith('Vector')
# not sure why this is 40 for both, just test > 0
assert len(ei.eventvec.as_numpy()) > 0
# move this to new test of create_pext in params?
# tests that cryptically named input parameters indeed
# copied into p_ext
loc = ei.p_ext['loc'][:4]
for lay in ['L2', 'L5']:
pname = 'input_' + loc + '_A_weight_' + lay + 'Pyr_ampa'
assert ei.p_ext[lay + 'Pyr_ampa'][0] == params[pname]

with Network(deepcopy(params)) as net:
net._create_all_src()

assert len(net.extinput_list) == 2 # (distal & proximal)
for ei in net.extinput_list:
# XXX: need to rename ei.ty to 'rhythmic'
assert ei.ty == 'extinput'
assert ei.eventvec.hname().startswith('Vector')
# not sure why this is 40 for both, just test > 0
assert len(ei.eventvec.as_numpy()) > 0

# check that ei.p_ext matches params
loc = ei.p_ext['loc'][:4] # loc=prox or dist
for layer in ['L2', 'L5']:
key = 'input_{}_A_weight_{}Pyr_ampa'.format(loc, layer)
assert ei.p_ext[layer + 'Pyr_ampa'][0] == params[key]

0 comments on commit 917aff4

Please sign in to comment.