Skip to content

Commit 4734b2a

Browse files
authored
Merge pull request #71 from dilawar/pybind11
Fixes to examples script for new python bindings.
2 parents 31f898a + 89592ea commit 4734b2a

File tree

15 files changed

+337
-359
lines changed

15 files changed

+337
-359
lines changed

.ci/execute_travis_serial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def print_results():
7070
for k in result_:
7171
with open("%s.txt" % k, 'w') as f:
7272
for fl, r in result_[k]:
73-
f.write('- %s\n' % fl)
73+
f.write('- [ ] %s\n' % fl)
7474
f.write('```')
7575
try:
7676
r = r.decode('utf8')

neuroml2/run_hhcell.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@
4747
import numpy as np
4848
import matplotlib.pyplot as plt
4949

50-
51-
# NOTE: This script does not work with python3
52-
# See https://github.com/NeuroML/NeuroML2/issues/116 . If this bug is fixed then
53-
# remove this code block.
54-
import neuroml as nml
55-
a = nml.nml.nml.IonChannel()
56-
try:
57-
b = {a : 1 }
58-
except TypeError as e:
59-
print( 'Failed due to https://github.com/NeuroML/NeuroML2/issues/116' )
60-
quit( 0 )
61-
6250
def test_channel_gates():
6351
"""Creates prototype channels under `/library` and plots the time
6452
constants (tau) and activation (minf, hinf, ninf) parameters for the

snippets/funcInputToPools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def main():
100100
"""
101101

102102
makeModel()
103-
moose.seed()
103+
moose.seed(10)
104104

105105
moose.reinit()
106106
moose.start( 50.0 ) # Run the model for 100 seconds.

snippets/rxdReacDiffusion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def main():
1717
# define the geometry
1818
compt = moose.CylMesh( '/cylinder' )
1919
compt.r0 = compt.r1 = 1
20-
compt.x1 = 100
2120
compt.diffLength = 0.2
21+
compt.x1 = 100
2222
assert( compt.numDiffCompts == compt.x1/compt.diffLength )
2323

2424
#define the molecule. Its geometry is defined by its parent volume, cylinder

snippets/showmsg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def main():
1313
synapse = syn.synapse.vec
1414
mid = moose.connect(net, 'spikeOut', synapse, 'addSpike', 'Sparse') # This creates a `Sparse` message from `spikeOut` source of net to `addSpike` destination on synapse.
1515
msg = moose.element(mid)
16+
print(msg.setRandomConnectivity,'xx')
17+
msg.setRandomConnectivity(connectionProbability, 5)
18+
quit()
1619
msg.setRandomConnectivity(connectionProbability, 5)
1720
for n in net.vec:
1821
print(('Messages from %s.spikeOut' % (n.path)))

squid/electronics.py

Lines changed: 35 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
1-
# electronics.py ---
2-
#
1+
# electronics.py ---
2+
#
33
# Filename: electronics.py
4-
# Description:
4+
# Description:
55
# Author: Subhasis Ray
6-
# Maintainer:
7-
# Created: Wed Feb 22 00:53:38 2012 (+0530)
8-
# Version:
9-
# Last-Updated: Tue Jul 10 10:28:40 2012 (+0530)
10-
# By: subha
11-
# Update #: 221
12-
# URL:
13-
# Keywords:
14-
# Compatibility:
15-
#
16-
#
6+
# Maintainer: Dilawar Singh
177

18-
# Commentary:
19-
#
20-
#
21-
#
22-
#
23-
24-
# Change log:
25-
#
26-
# 2012-02-22 23:22:30 (+0530) Subha - the circuitry put in a class.
27-
#
28-
29-
# Code:
30-
31-
import numpy
8+
import numpy as np
329
import moose
3310

34-
class ClampCircuit(moose.Neutral):
11+
class ClampCircuit(object):
3512
"""Container for a Voltage-Clamp/Current clamp circuit."""
13+
3614
defaults = {
3715
'level1': 25.0,
3816
'width1': 50.0,
@@ -41,48 +19,59 @@ class ClampCircuit(moose.Neutral):
4119
'trigMode': 0,
4220
'delay3': 1e9
4321
}
44-
def __init__(self, path, compartment):
45-
moose.Neutral.__init__(self, path)
22+
def __init__(self, path, squid):
23+
self.path = path
24+
moose.Neutral(path)
4625
self.pulsegen = moose.PulseGen(path+"/pulse") # holding voltage/current generator
4726
self.pulsegen.count = 2
4827
self.pulsegen.firstLevel = 25.0
4928
self.pulsegen.firstWidth = 50.0
5029
self.pulsegen.firstDelay = 2.0
5130
self.pulsegen.secondDelay = 0.0
5231
self.pulsegen.trigMode = 2
53-
self.gate = moose.PulseGen(path+"/gate") # holding voltage/current generator
32+
self.gate = moose.PulseGen(path + "/gate") # holding voltage/current generator
5433
self.gate.level[0] = 1.0
5534
self.gate.delay[0] = 0.0
5635
self.gate.width[0] = 1e9
57-
moose.connect(self.gate, 'output', self.pulsegen, 'input')
58-
self.lowpass = moose.RC(path+"/lowpass") # lowpass filter
36+
moose.connect(self.gate, "output", self.pulsegen, "input")
37+
self.lowpass = moose.RC(path + "/lowpass") # lowpass filter
5938
self.lowpass.R = 1.0
6039
self.lowpass.C = 0.03
61-
self.vclamp = moose.DiffAmp(path+"/vclamp")
40+
self.vclamp = moose.DiffAmp(path + "/vclamp")
6241
self.vclamp.gain = 0.0
6342
self.vclamp.saturation = 1e10
64-
self.iclamp = moose.DiffAmp(path+"/iclamp")
43+
self.iclamp = moose.DiffAmp(path + "/iclamp")
6544
self.iclamp.gain = 0.0
6645
self.iclamp.saturation = 1e10
67-
self.pid = moose.PIDController(path+"/pid")
46+
self.pid = moose.PIDController(path + "/pid")
6847
self.pid.gain = 0.5
6948
self.pid.tauI = 0.02
7049
self.pid.tauD = 0.005
7150
self.pid.saturation = 1e10
7251
# Connect current clamp circuitry
7352
moose.connect(self.pulsegen, "output", self.iclamp, "plusIn")
74-
moose.connect(self.iclamp, "output", compartment, "injectMsg")
53+
moose.connect(self.iclamp, "output", squid.C, "injectMsg")
7554
# Connect voltage clamp circuitry
7655
moose.connect(self.pulsegen, "output", self.lowpass, "injectIn")
7756
moose.connect(self.lowpass, "output", self.vclamp, "plusIn")
7857
moose.connect(self.vclamp, "output", self.pid, "commandIn")
79-
moose.connect(compartment, "VmOut", self.pid, "sensedIn")
80-
moose.connect(self.pid, "output", compartment, "injectMsg")
58+
moose.connect(squid.C, "VmOut", self.pid, "sensedIn")
59+
moose.connect(self.pid, "output", squid.C, "injectMsg")
8160
current_table = moose.Table("/data/Im")
82-
moose.connect(current_table, "requestOut", compartment, "getIm")
61+
moose.connect(current_table, "requestOut", squid.C, "getIm")
8362

84-
def configure_pulses(self, baseLevel=0.0, firstLevel=0.1, firstDelay=5.0, firstWidth=40.0, secondLevel=0.0, secondDelay=1e6, secondWidth=0.0, singlePulse=True):
85-
"""Set up the pulse generator."""
63+
def configure_pulses(
64+
self,
65+
baseLevel=0.0,
66+
firstLevel=0.1,
67+
firstDelay=5.0,
68+
firstWidth=40.0,
69+
secondLevel=0.0,
70+
secondDelay=1e6,
71+
secondWidth=0.0,
72+
singlePulse=True,
73+
):
74+
"""Set up the pulse generator."""
8675
self.pulsegen.baseLevel = baseLevel
8776
self.pulsegen.firstLevel = firstLevel
8877
self.pulsegen.firstWidth = firstWidth
@@ -91,10 +80,10 @@ def configure_pulses(self, baseLevel=0.0, firstLevel=0.1, firstDelay=5.0, firstW
9180
self.pulsegen.secondDelay = secondDelay
9281
self.pulsegen.secondWidth = secondWidth
9382
if singlePulse:
94-
self.pulsegen.trigMode = 1
83+
self.pulsegen.trigMode = 1
9584
else:
9685
self.pulsegen.trigMode = 0
97-
86+
9887
def do_voltage_clamp(self):
9988
"""Switch to voltage clamp circuitry. After this the simdt may
10089
need to be changed for correct performance."""
@@ -103,14 +92,10 @@ def do_voltage_clamp(self):
10392
self.pid.gain = 0.5
10493
self.pid.tauD = 0.005
10594
self.pid.tauI = 0.02
106-
95+
10796
def do_current_clamp(self):
10897
"""Switch to current clamp circuitry. After this the simdt may
10998
need to be changed for correct performance."""
11099
self.iclamp.gain = 1.0
111100
self.vclamp.gain = 0.0
112101
self.pid.gain = 0.0
113-
114-
115-
#
116-
# electronics.py ends here

0 commit comments

Comments
 (0)