Page 1 of 1

a caveat

Posted: Sat Sep 15, 2007 9:59 pm
by eacheon
From a python shell, if I do

Code: Select all

>> import neuron
>> h = neuron.HocObject()
>> h("a = 10")
>> h("print a")
10

>> h.quit()  # this quits the python shell.
While I would rather destroy h instead of quit my python shell. Is it possible at all?

I was actually trying to clear everything I did with this session and would like to start a new simulation, however, it seems hard to manage without restarting a python shell:

Code: Select all

...
>> print h.a
10
>> "Let's try to clean up things"
>> del h
>> from sys import modules
>> del neuron
>> del modules['neuron.hoc']
>> del modules['neuron']

>> "try it again, will there be a fresh session?"
>> import neuron
>> h = neuron.HocObject()
>> print h.a
10
>> "nothing got cleaned. :("
So the h still points to the same HocObject that has everything I've done which has not been cleaned.

Posted: Mon Sep 17, 2007 7:06 am
by hines
Restarting the hoc interpreter in a pristine
state is not supported. See
https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=1029
However, since I don't know anything about ipython, I can assume you can easily unexport neuron and start over that
way.

Posted: Mon Sep 17, 2007 11:26 am
by eacheon
hines wrote:Restarting the hoc interpreter in a pristine
state is not supported. See
https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=1029
However, since I don't know anything about ipython, I can assume you can easily unexport neuron and start over that
way.
That doesn't seem to be the case: it is pretty hard for python to do it:

http://groups.google.com/group/comp.lan ... d671363234

Posted: Mon Jan 28, 2008 3:09 am
by henriklinden
Hi,

I have the same problem as above. I have so far not found a way to successfully unimport NEURON from python in a way that a get a "fresh" NEURON process when I restart it.

Therefore, is there any other command besides quit() that would shut down the NEURON process?

Alternatively, is there a simple way to delete all variables and object within NEURON?