Print Issue after using .connect()

When Python is the interpreter, what is a good
design for the interface to the basic NEURON

Moderator: hines

Post Reply
Posts: 4
Joined: Mon Dec 30, 2019 11:05 pm

Print Issue after using .connect()

Post by ssrihari »

Hi! I am new to the forum and also relatively new to computational neuroscience research. I am currently working on converting the McIntyre MRG axon model from Hoc to Python as part of my initial task as a researcher. However, I recently ran into an issue in which I am unable to print or display any output after instantiating an instance of my MRG axon class. I isolated the cause of the printing issue to a particular for loop I wrote in order to connect several parts of my axon model as was done in the original model:

Code: Select all

       for i in range(self.axonnodes - 1):
            self.MYSA[2 * i].connect(self.node[i])
            self.FLUT[2 * i].connect(self.MYSA[2 * i])
            self.STIN[6 * i].connect(self.FLUT[2 * i])
            self.STIN[6 * i + 1].connect(self.STIN[6 * i])
            self.STIN[6 * i + 2].connect(self.STIN[6 * i + 1])
            self.STIN[6 * i + 3].connect(self.STIN[6 * i + 2])
            self.STIN[6 * i + 4].connect(self.STIN[6 * i + 3])
            self.STIN[6 * i + 5].connect(self.STIN[6 * i + 4])
            self.FLUT[2 * i + 1].connect(self.STIN[6 * i + 5])
            self.MYSA[2 * i + 1].connect(self.FLUT[2 * i + 1])
            self.node[i + 1].connect(self.MYSA[2 * i + 1])
print "Output received" # This will print because it is before instance declaration
testMRG = MRG()
print "Output received" # Nothing beyond this line will print due to above for loop
print testMRG.fiberD
I was wondering if anyone has had a similar issue and/or whether there are any specific issues in my implementation that may be causing this?
Site Admin
Posts: 5819
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Print Issue after using .connect()

Post by ted »

For readers who wonder what came of this--

Diagnosis of this problem was complicated by two facts. First, the user isn't seeing error messages. On a different PC the code produced an error message to the effect that a connect statement failed because it would have connected a section to itself, resulting in a loop. Second, the error is a runtime error, and unlike a syntax error, a runtime error can make symptoms crop up at a point in a program that is far from the place at which the actual programming error is located.

The failure occurred at the very first connect statement, because the "lists" node, MYSA, FLUT, and STIN had all been created with this "one liner" statement
self.node = self.MYSA = self.FLUT = self.STIN = []
Consequently the names node, MYSA, FLUT, and STIN didn't signify separate lists. Instead, they actually referred to a single list that contained all of the model's sections. The very first connect statement failed because it tried to attach the first section in the list to itself.

The fix is to create each list separately, e.g.
self.node = []
self.MYSA = []

I imagine there's some elegant, highly Pythonic way to do this, and maybe it's even human readable. But quick and dirty works well enough.
Post Reply