def test(fname): # file as string without the ^D global b b = open(fname).read().replace("\x04\n", "") # zzz replaced by fname below a = ''' h('xopen("zzz")') h.xopen('zzz') h.execute('xopen("zzz")') h.execute1('xopen("zzz")') h.load_file('zzz') h(b) h.execute(b) h.execute1(b) ''' a = a.replace("zzz", fname) for line in a.splitlines(): print "TEST" if len(line): e('z = ' + line + '; print "result=",z')
from neuron import h import numpy from e import e e('h.abs(numpy.arange(10,11))') print(h.abs(float(numpy.arange(10, 11)))) e('h.abs(0j)') h('objref p') h.p = 10 + 2j print(h.p)
double d[2][2] d[0][0] = 100 d[1][1] = 101 func f() {return 0} begintemplate A public a, f, d double d[2][2] proc init() { a = 5 d[0] = 50 d[1] = 51} func f() { return 1 } endtemplate A objref b[3] b[0] = new A() ''') e('print (h.a)') e('print (h.b.a)') e('print (h.b[0].a)') e('print (h.b.f())') e('print (h.b[0].f())') e('print (h.b.b.b.b.a)') e('print (h.f.a)') e('print (h.b[0].f.a)') e('print (h.d.a)') e('print (h.d[0].a)') e('print (h.d[0][0].a)') e('print (h.b[0].d.a)') e('print (h.b[0].d[0].a)') e('h.b.__dict__') e('h.b.__doc__')
public soma, b, s, dend create soma, dend[2] strdef s objref b proc init() { insert extracellular a = 0 // not public b = new List() // b not subscriptable s = "hello" } endtemplate Foo ''') # NEURON: xg wrong number of array dimensions h('''proc p1() { $o1.soma.xg[0][0] }''') e('h.p1(h.Foo())') # NEURON: L section property can't have argument h('''proc p2() { $o1.soma.L(1) }''') e('h.p2(h.Foo())') # NEURON: xq suffix not a range variable or section property h('''proc p3() { $o1.soma.xq }''') e('h.p3(h.Foo())') # NEURON: [...](...) syntax only allowed for array range variables: x h('''proc p4() { $o1.x[0](.5) }''') e('h.p4(h.Vector())') class X():
# # from src/e.c # # long double ee(void) to e # from e import e r, n = e() print("{0:.14f}\n{1:.20f}\n{2} ({3})".format(r, r, r, n))
print(iname) exec('s2 = h.' + iname) print('s is s2', s is s2) print('s is h.cas()', s is h.cas()) print('s == h.cas()', s == h.cas()) h('create soma') s4 = h.soma print(s4.hoc_internal_name()) exec('s5 = h.' + s4.hoc_internal_name()) print('s5 is s4', s5 is s4) print('s5 == s4', s5 == s4) print(s5.name()) s6 = h.Section(name="s6") s6.name() h.topology() h('''__nrnsec_0x { print secname() }''') e('s7 = h.__nrnsec_0x') h('''__nrnsec_0xaaaa { print secname() }''') e('s7 = h.__nrnsec_0xaaaa') del(s) print(s2) print(s2.name()) sn = 'print (h.'+ s2.hoc_internal_name() + '.L)' e(sn) del(s2) e(sn)
from e import e from neuron import h h(''' begintemplate Foo public foo, _ref_foo proc init() { foo = 1 _ref_foo = 2 } endtemplate Foo ''') s = h.Section() f = h.Foo() e('h.setpointer(s(.5)._ref_v, "foo", f)') e('f._ref_foo = s(.5)._ref_v') e('f.foo = s(.5)._ref_v')
from neuron import h from e import e v1 = h.Vector(5).indgen() v2 = v1.c #left out () so v2 is a callable for the clone function of v1 v1.resize(10) print(v2) print((v2.hname())) e('print (v2.size())') # should give error instead of size of v1