Skip to content

Commit 0d45671

Browse files
committed
Simplify load_mechanisms() to use neuron.load_mechanisms()
NEURON's own load_mechanisms() handles platform detection (including .dylib on macOS) via mechanism_suffix, making the hand-rolled arch/ extension loop redundant. Remaining change from NeuralEnsemble#822; mod file changes were already applied in 8699516.
1 parent 7f43d9b commit 0d45671

1 file changed

Lines changed: 6 additions & 26 deletions

File tree

pyNN/neuron/simulator.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from operator import itemgetter
2626
import warnings
2727

28+
import neuron
2829
import numpy as np
2930
from neuron import h, nrn_dll_loaded
3031

@@ -76,32 +77,11 @@ def load_mechanisms(path):
7677
which the directory 'i686' (or 'x86_64' or 'powerpc' depending on your
7778
platform) was created.
7879
"""
79-
import platform
80-
81-
if path in nrn_dll_loaded:
82-
logger.warning("Mechanisms already loaded from path: %s" % path)
83-
return
84-
# in case NEURON is assuming a different architecture to Python,
85-
# we try multiple possibilities
86-
if platform.system() == 'Windows':
87-
lib_path = os.path.join(path, 'nrnmech.dll')
88-
if os.path.exists(lib_path):
89-
h.nrn_load_dll(lib_path)
90-
nrn_dll_loaded.append(path)
91-
return
92-
else:
93-
arch_list = [platform.machine(), 'i686', 'x86_64', 'powerpc', 'umac']
94-
for arch in arch_list:
95-
path_list = ['.so', '.dylib']
96-
for p in path_list:
97-
lib_path = os.path.join(path, arch, f'libnrnmech{p}')
98-
if os.path.exists(lib_path):
99-
h.nrn_load_dll(lib_path)
100-
nrn_dll_loaded.append(path)
101-
return
102-
raise IOError(
103-
f"NEURON mechanisms not found in {path}. "
104-
"You may need to run 'nrnivmodl' in this directory.")
80+
result = neuron.load_mechanisms(path)
81+
if not result:
82+
raise IOError(
83+
f"NEURON mechanisms not found in {path}. "
84+
"You may need to run 'nrnivmodl' in this directory.")
10585

10686

10787
def is_point_process(obj):

0 commit comments

Comments
 (0)