Skip to content

Commit 98ee42f

Browse files
authored
Merge pull request #100 from OpenSourceBrain/test_pynn0101
Uses PyNN v0.10.1, nrn v8.1, nest v3.3
2 parents e47401e + 2009a13 commit 98ee42f

File tree

12 files changed

+91
-8
lines changed

12 files changed

+91
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- "NEURON:7.8.2"
2828
- "PyNEURON:8.0.2"
2929
- PyNN
30+
- PyNN_Brian2
3031
- PyNN_NEURON
3132
- PyNN_Nest
3233
- PyNN_NeuroML

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,4 @@ report*.txt
121121
*_moose.py
122122
/utilities/tests/*.gen.c
123123
/utilities/tests/*_eden.py
124+
arm64

omv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.2'
1+
__version__ = '0.2.4'

omv/analyzers/utils/timeseries.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ def load_data_file(fname, columns=(0, 1), header_lines=0, scaling=1):
2727

2828
def load_spike_file(fname, format='ID_TIME', ids=0, scaling=1.0):
2929
from numpy import loadtxt
30-
ts = loadtxt(fname)
30+
ts = loadtxt(fname, skiprows=3) if format=='ID_TIME_NEST_DAT' else loadtxt(fname)
3131
spike_map = {}
3232
for l in ts:
33-
if format=='ID_TIME':
33+
#print('Interpreting: %s'%l)
34+
if format=='ID_TIME' or format=='ID_TIME_NEST_DAT':
3435
t = l[1]*scaling
3536
id = l[0]
3637
elif format=='TIME_ID':

omv/engines/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from omv.engines.pynnneuron import PyNNNRNEngine
3030
from omv.engines.pyneuron import PyNRNEngine
3131
#from omv.engines.pynnbrian1 import PyNNBrian1Engine
32+
from omv.engines.pynnbrian2 import PyNNBrian2Engine
3233
from omv.engines.pynnnest import PyNNNestEngine
3334
from omv.engines.pynnneuroml import PyNNNeuroMLEngine
3435
from omv.engines.octave import OctaveEngine

omv/engines/getnest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def install_nest(version):
99

1010
if not version:
11-
version='2.20.0'
11+
version='3.3'
1212

1313
inform('Installing NEST', indent=2, verbosity=1)
1414
nestpath = os.path.join(os.environ['HOME'],'nest')

omv/engines/getnrn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def install_neuron(version):
1212
if not version:
1313
if sys.version_info.major == 3:
14-
version='7.8.2'
14+
version='8.1' # 8.1 works with pynn 0.10.1
1515
else:
1616
version='7.6'
1717

omv/engines/getpynn.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
from omv.engines.utils.wdir import working_dir
66

77
def install_pynn(version=None):
8+
9+
if not version:
10+
version='0.10.1'
11+
812
try:
913

1014
#pip_install('lazyarray') # This should ideally be automatically installed with PyNN...
11-
pip_install('neo==0.9.0') # This should ideally be automatically installed with PyNN, some issues with 0.10.0...
15+
#pip_install('neo>=0.11.0') # This should ideally be automatically installed with PyNN...
1216

1317
install_root = os.environ['HOME']
1418

@@ -19,7 +23,6 @@ def install_pynn(version=None):
1923
path = os.path.join(install_root, pyNN_src)
2024

2125
with working_dir(path):
22-
if version==None: version = '0.9.6'
2326
print(check_output(['git','checkout',version])) # neuroml branch has the latest NML2 import/export code!
2427
#check_output(['git','checkout','master'])
2528
#print(check_output(['python', 'setup.py', 'install']))

omv/engines/nestsli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def get_nest_environment():
1818
nestpath = os.path.join(os.environ['HOME'],'nest/nest/')
1919
if 'NEST_INSTALL_DIR' in os.environ:
2020
nestpath = os.environ['NEST_INSTALL_DIR']+'/'
21+
elif 'NEST_HOME' in os.environ:
22+
nestpath = os.environ['NEST_HOME']+'/'
2123

2224
environment_vars = {'NEST_HOME': nestpath,
2325
'PYTHONPATH': nestpath+'/lib/python%s.%s/site-packages/'%(sys.version_info.major, sys.version_info.minor)}
@@ -28,7 +30,6 @@ def get_nest_environment():
2830
@staticmethod
2931
def is_installed():
3032
ret = True
31-
3233
environment_vars = NestEngine.get_nest_environment()
3334
try:
3435
FNULL = open(os.devnull, 'w')
@@ -39,6 +40,8 @@ def is_installed():
3940
if '-' in ret:
4041
ret = 'v%s'%ret.split('-')[-1]
4142

43+
if not 'v' in ret: ret='v%s'%ret
44+
4245
inform("NEST %s is correctly installed..." % ret, indent=2, verbosity=1)
4346

4447
except OSError as err:

omv/engines/pynnbrian2.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import os
2+
import subprocess as sp
3+
4+
from omv.engines.brian2_ import Brian2Engine
5+
from omv.engines.pynn import PyNNEngine
6+
7+
from omv.common.inout import inform, trim_path, check_output, is_verbose
8+
from omv.engines.engine import EngineExecutionError
9+
10+
11+
class PyNNBrian2Engine(PyNNEngine):
12+
13+
name = "PyNN_Brian2"
14+
python3_compatible = Brian2Engine.python3_compatible
15+
16+
@staticmethod
17+
def is_installed():
18+
if is_verbose():
19+
inform("Checking whether %s is installed..." %
20+
PyNNBrian2Engine.name, indent=1)
21+
return PyNNEngine.is_installed() and Brian2Engine.is_installed()
22+
23+
@staticmethod
24+
def install(version):
25+
if not Brian2Engine.is_installed():
26+
Brian2Engine.install(version) # interpret version as version of Brian!
27+
inform("%s installed Brian..." % PyNNBrian2Engine.name, indent=2, verbosity =1)
28+
if not PyNNEngine.is_installed():
29+
PyNNEngine.install(None)
30+
inform("%s installed PyNN..." % PyNNBrian2Engine.name, indent=2, verbosity =1)
31+
32+
PyNNBrian2Engine.path = PyNNEngine.path + \
33+
":" + Brian2Engine.path
34+
PyNNBrian2Engine.environment_vars = {}
35+
PyNNBrian2Engine.environment_vars.update(
36+
PyNNEngine.environment_vars)
37+
PyNNBrian2Engine.environment_vars.update(
38+
Brian2Engine.environment_vars)
39+
inform("PATH: " + PyNNBrian2Engine.path)
40+
41+
42+
def run(self):
43+
try:
44+
inform("Running file %s with %s" % (trim_path(self.modelpath), self.name), indent=1)
45+
self.stdout = check_output(['python', self.modelpath, 'brian2'],
46+
cwd=os.path.dirname(self.modelpath))
47+
self.returncode = 0
48+
except sp.CalledProcessError as err:
49+
self.returncode = err.returncode
50+
self.stdout = err.output
51+
raise EngineExecutionError
52+
except Exception as err:
53+
inform("Another error with running %s: "%self.name, err, indent=1)
54+
self.returncode = -1
55+
self.stdout = "???"
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+

0 commit comments

Comments
 (0)