New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MRG] fix logic checking extinput synweights zero #102
Conversation
@rythorpe do you want to review this PR since the commit that introduces the problem was yours? |
if self.p_ext[key][0] > 0.0: | ||
all_syn_weights_zero = False | ||
if all_syn_weights_zero: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit weird that this method even returns something because the return value is not used anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To address @jasmainak's point, this might be a good time to rethink the return values of the __create_
methods in the ExtFeed
class. It looks like the code is currently set up to return the number of inputs added to the feed (for troubleshooting purposes?), though this might be unnecessary if we implement good tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the error in #101 is caused by one of the synaptic weights from 'OnlyRhythmicDist.param' being zero
Correct, these are the only non-zero weights:
'input_dist_A_weight_L2Pyr_ampa': 5.4e-5,
'input_dist_A_weight_L5Pyr_ampa': 5.4e-5,
The method would return unless all weights were non-zero.
rethink the return values of the
__create_
methods in theExtFeed
class
+1 It doesn't seem that the return values are ever used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow the loop logic: it should only end the function if all inputs are zero. Before it would end if any input was <=0.
I’ll update the rst, but I think this was an unintentional mod (bug)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okayyyy, now I get it
so all you need to do for the unit test is to initialize an ExtFeed
object with the right parameters and then check if self.eventvec
exists (or is not None. I didn't check exactly whether this class initializes all attributes to None
or adds them as and when needed). No computation required at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll update the rst, but I think this was an unintentional mod (bug)
yep it should go to the bug section of whats_new.rst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuing off @jasmainak's suggestion, ideally we'd check the number and type of inputs in the p_ext
attribute of an ExtFeed
object so that we can be sure all (vs. any) expected inputs were added to the feed. I think this test could be added to the network test script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my latest push: it wasn't enough to check p_ext
, since these could be copied in fine, despite __create_extinput
not running through to create the eventvec
. I think we should test p_ext
in create_pext
?
Re: tests, I just did params_fname = op.join(hnn_core_root, 'param', 'default.json')
params = read_params(params_fname)
params.update({'input_dist_A_weight_L2Pyr_ampa': 5.4e-5,
'input_dist_A_weight_L5Pyr_ampa': 5.4e-5,
't0_input_dist': 50})
... which adds Still don't like the length of this test, though... Just for the heck of it, I tried params.update({"N_pyr_x": 2, "N_pyr_y": 2}) and re-run spiketype_counts
{'extinput': 34,
'evprox1': 11,
'L5_basket': 5,
'L2_pyramidal': 13,
'L2_basket': 6,
'L5_pyramidal': 31,
'evdist1': 9,
'evprox2': 11} Could this be a strategy? Shall we close this PR, then I try to create a fast test a la the above in a separate one? |
@cjayb I like the idea of having tests on a small network! However, I'm not sure if the signals you get out of the smaller network will be as meaningful to know if we broke something? Re the old tests of comparing to |
My thought was that all the simulations are deterministic, so even though they would be physiologically meaningless, they could serve as unit-like tests? Given that most of what we do involves nrn, we’re going to have to deal with the long compile/run times somehow... |
But that's not a very good unit test because if you fix a bug that changes the overall output, your test will fail. This is the case with the test where we compare with the old HNN output. The existing test is a bad unit test. It's just better than nothing. |
OK, got it. |
hnn_core/tests/test_network.py
Outdated
# Assert number of rhythmic inputs is 2 (distal & proximal) | ||
assert len(net.extinput_list) == 2 | ||
for ei in net.extinput_list: | ||
# naming could be better |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this should be called 'rhythmic'. We've discussed this with @rythorpe !
@cjayb I think your PR looks good to go for me. I played around with it a bit and removed some comments. I hope that's okay for you? I prefer to see clean code through good choice of variable names than explaining it through comments :) If you're fine, please set the PR title to [MRG] and I'll merge in the morning when I wake up. Thanks a lot for the PR. Looking forward to more contributions in the future! Maybe an easy one is to change the naming of 'extinput' -> 'rhythmic'? |
Nice touch with the context manager! I definitely don't mind the edits. Good way to work this: add copious comments while working on PR, remove most once test is written. Sure, I'll take a stab at the renaming next. Goal will be to create some test(s) while I'm at it. |
Perfect plan! Thanks a lot :-) |
This PR fixes the part of #98 (specifically 94fc21a in
feed.py
) that botches the alpha-example.No test written yet, input appreciated! There's a refactor brewing (see also discussion in #98), so perhaps tests should be deferred? To speed up tests, would it make sense to create a 'minimal network'? Not sure that makes sense, but almost 3 min spent on just the full alpha-example isn't sustainable.
Fixes #101