Bug in netrxd.py

28 views
Skip to first unread message

Adam Mergenthal

unread,
Feb 3, 2021, 6:59:01 PM2/3/21
to NetPyNE Q&A forum

Hi,

So I've been experimenting with using inspyred to optimize a model based on the example code on the website. On the first iteration the simulation runs without a problem and prints out the calculated fitness value. On the second iteration, I get the error

UnboundLocalError: local variable 'nrnRegions' referenced before assignment

What I've figure out is that in netrxd.py under _addReactions() in the block of code between lines 355 and 363, if param['regions'] is a list, then there is no way for the variable nrnRegions to be assigned. What was happening was that my param['regions'] variables were strings on the first iteration, but then got converted into lists so that on the second pass nrnRegions never got assigned.

A quick fix would be to put "if param['regions']:" on the line before the try statement. By that point param['regions'] should either be None or a list and should be fine.

Joe Graham

unread,
Feb 14, 2021, 8:16:11 PM2/14/21
to NetPyNE Q&A forum
Hello,

Thank you for pointing out this bug (and even more thanks for suggesting a solution).  I believe we have solved this issue with the following Pull Request: https://github.com/Neurosim-lab/netpyne/pull/554

This fix is already available in the development branch of NetPyNE, and will be included in the next stable release.

Best wishes,
Joe

Adam Mergenthal

unread,
Feb 16, 2021, 4:25:29 PM2/16/21
to NetPyNE Q&A forum
I pulled the development branch code, and I noticed the changes in netrxd.py. However, it looks like that change should also be made to the _addRates function as the same problem will come up.

Joe Graham

unread,
Feb 19, 2021, 1:35:07 PM2/19/21
to NetPyNE Q&A forum
Thanks for pointing that out!

We have fixed _addRates now in the development branch.  Adam (who did the fix) said: "I noticed when testing it as addRxD returns all the rxd stuff, if I just call it directly my interactive terminal keeps a copy of the rxd objects alive, which causes problems with repeated simulations. Instead if I do sim.net.rxd = sim.net.addRxD() , I have no problems. It might just be a problem with my python install."

Please let us know if you have any more problems.

Cheers,
Joe
Reply all
Reply to author
Forward
0 new messages