本文整理汇总了Python中nest.sli_run函数的典型用法代码示例。如果您正苦于以下问题:Python sli_run函数的具体用法?Python sli_run怎么用?Python sli_run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sli_run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_music
def _setup_music(self):
"""
Setup music connection.
"""
_nest.sli_run('statusdict/have_music ::')
if not _nest.spp():
print('NEST was not compiled with support for MUSIC, not running.')
_sys.exit()
# Setup music spike output.
self._music_spike_output = _nest.Create('music_event_out_proxy', 1)
_nest.SetStatus(self._music_spike_output,
{'port_name': self._spike_port_name})
# Connecting neurons to music event channels. In case of the BBP
# circuit, each channel corresponds to a gid.
for gid, neuron in self._gid_to_neuron_map.items():
_nest.Connect([neuron], self._music_spike_output, 'one_to_one',
{'music_channel': gid})
# Connecting the last music channel (value specified in the
# configuration file) to a dummy neuron
dummy = _nest.Create('iaf_neuron', 1)
_nest.Connect(dummy, self._music_spike_output, 'one_to_one',
{'music_channel': 10000000})
# Setup music steering input.
self._music_steering_input = _nest.Create('music_message_in_proxy', 1)
_nest.SetStatus(self._music_steering_input,
{'port_name': self._steering_port_name,
'acceptable_latency': 40.0})
示例2: sli_run
def sli_run(parameters=object(),
fname='microcircuit.sli',
verbosity='M_ERROR'):
'''
Takes parameter-class and name of main sli-script as input, initiating the
simulation.
Parameters
----------
parameters : object
parameter class instance
fname : str
path to sli codes to be executed
verbosity : str,
nest verbosity flag
Returns
-------
None
'''
# Load parameters from params file, and pass them to nest
# Python -> SLI
send_nest_params_to_sli(vars(parameters))
#set SLI verbosity
nest.sli_run("%s setverbosity" % verbosity)
# Run NEST/SLI simulation
nest.sli_run('(%s) run' % fname)
示例3: load_libraries
def load_libraries(self, name, url, **kwargs): # @UnusedVariable
install_dir = self.get_install_dir(name, url)
lib_dir = os.path.join(install_dir, 'lib')
add_lib_path(lib_dir)
# Add module install directory to NEST path
nest.sli_run(
'({}) addpath'.format(os.path.join(install_dir, 'share', 'sli')))
# Install nest module
nest.Install(name + 'Module')
示例4: get_help_text
def get_help_text(self, name):
nest.sli_run("statusdict /prgdocdir get")
docdir = nest.sli_pop()
helptext = "No documentation available"
for subdir in ["cc", "sli"]:
filename = os.path.join(docdir, "help", subdir, name + ".hlp")
if os.path.isfile(filename):
helptext = open(filename, 'r').read()
return helptext
示例5: prepare_simulation
def prepare_simulation(master_seed, n_populations):
"""Prepare random generators with master seed."""
nest.ResetKernel()
# set global kernel parameters
nest.SetKernelStatus(
{"communicate_allgather": sim.allgather,
"print_time": True,
"overwrite_files": False,
"resolution": sim.dt,
"total_num_virtual_procs": sim.n_vp})
# Set random seeds
nest.sli_run('0 << /rngs [%i %i] Range { rngdict/gsl_mt19937 :: exch CreateRNG } Map >> SetStatus'%(
master_seed, master_seed + sim.n_vp - 1))
#nest.SetKernelStatus({"rng_seeds" : range(master_seed, master_seed + sim.n_vp)})
nest.sli_run('0 << /grng rngdict/gsl_mt19937 :: %i CreateRNG >> SetStatus'%(master_seed + sim.n_vp))
#nest.SetKernelStatus({"grng_seed" : master_seed + sim.n_vp})
pyrngs = [np.random.RandomState(s) for s in
range(master_seed + sim.n_vp + 1, master_seed + 2 * sim.n_vp + 1)]
return pyrngs
示例6: load_libraries
def load_libraries(cls, name, install_dir):
lib_dir = os.path.join(install_dir, 'lib', 'nest')
if (sys.platform.startswith('linux') or
sys.platform in ['os2', 'os2emx', 'cygwin', 'atheos',
'ricos']):
lib_path_key = 'LD_LIBRARY_PATH'
elif sys.platform == 'darwin':
lib_path_key = 'DYLD_LIBRARY_PATH'
elif sys.platform == 'win32':
lib_path_key = 'PATH'
if lib_path_key in os.environ:
os.environ[lib_path_key] += os.pathsep + lib_dir
else:
os.environ[lib_path_key] = lib_dir
# Add module install directory to NEST path
nest.sli_run(
'({}) addpath'.format(os.path.join(install_dir, 'share', 'nest',
'sli')))
# Install nest module
nest.Install(name + 'Module')
示例7: send_nest_params_to_sli
def send_nest_params_to_sli(p):
'''
Read parameters and send them to SLI
Parameters
----------
p : dict
sli parameter name and value as dictionary key and value pairs
Returns
-------
None
'''
for name in p.keys():
value = p[name]
if type(value) == np.ndarray:
value = value.tolist()
if type(value) == dict:
value = dict_of_numpyarray_to_dict_of_list(value)
if name == 'neuron_model': # special case as neuron_model is a
# NEST model and not a string
try:
nest.sli_run('/'+name)
nest.sli_push(value)
nest.sli_run('eval')
nest.sli_run('def')
except:
print 'Could not put variable %s on SLI stack' % (name)
print type(value)
else:
try:
nest.sli_run('/'+name)
nest.sli_push(value)
nest.sli_run('def')
except:
print 'Could not put variable %s on SLI stack' % (name)
print type(value)
return
示例8: prepare_simulation
def prepare_simulation(master_seed, n_populations):
"""Prepare random generators with master seed."""
nest.ResetKernel()
# set global kernel parameters
nest.SetKernelStatus(
{"communicate_allgather": sim.allgather,
"overwrite_files": sim.overwrite_existing_files,
"resolution": sim.dt,
"total_num_virtual_procs": sim.n_vp})
if sim.to_text_file:
nest.SetKernelStatus({"data_path": data_path_test})
# Set random seeds
# PYNEST
#nest.sli_run('0 << /rngs [%i %i] Range { rngdict/gsl_mt19937 :: exch CreateRNG } Map >> SetStatus'%(
# master_seed, master_seed + sim.n_vp - 1))
#nest.SetKernelStatus({"rng_seeds" : range(master_seed, master_seed + sim.n_vp)})
#nest.sli_run('0 << /grng rngdict/gsl_mt19937 :: %i CreateRNG >> SetStatus'%(master_seed + sim.n_vp))
#nest.SetKernelStatus({"grng_seed" : master_seed + sim.n_vp})
#pyrngs = [np.random.RandomState(s) for s in
# range(master_seed + sim.n_vp + 1, master_seed + 2 * sim.n_vp + 1)]
# SLI VERSION
sli_str = "0 << \n"
#sli_str += "/rngs %i [0 %i 1 sub] add Range { rngdict/gsl_mt19937 :: exch CreateRNG } Map\n"%(master_seed, sim.n_vp) # local RNG, seeded
#sli_str += "/grng rngdict/gsl_mt19937 :: %i %i add CreateRNG\n"%(master_seed, sim.n_vp) # global RNG
sli_str += "/rng_seeds %i [0 %i 1 sub] add Range\n"%(master_seed, sim.n_vp) # local RNG seeds
sli_str += "/grng_seed %i %i add\n"%(master_seed, sim.n_vp) # global RNG seed
sli_str += ">> SetStatus"
nest.sli_run(sli_str)
sli_str2 = "/script_rngs [%i]\n"%sim.n_vp
sli_str2 += "{%i add rngdict /gsl_mt19937 get exch CreateRNG } Table def\n"%(master_seed + sim.n_vp)
sli_str2 += "/normal_rdvs script_rngs { rdevdict /normal get CreateRDV } Map def"
nest.sli_run(sli_str2)
pyrngs = None
return pyrngs
示例9: _set_verbosity
def _set_verbosity(self, verbosity):
nest.sli_run("M_%s setverbosity" % verbosity.upper())
示例10: LambertWm1
def LambertWm1(x):
nest.sli_push(x)
nest.sli_run('LambertWm1')
y = nest.sli_pop()
return y
示例11: test_libcsa_cgnext
def test_libcsa_cgnext(self):
"""cgnext"""
nest.ResetKernel()
w = 10000.0
d = 1.0
cs = libcsa.cset(libcsa.oneToOne, w, d)
nest.sli_push(cs)
nest.sli_run('dup')
nest.sli_push(numpy.array([0, 1, 2, 3]))
nest.sli_push(numpy.array([0, 1, 2, 3]))
nest.sli_run('cgsetmask')
nest.sli_run('dup')
nest.sli_run('cgstart')
for i in range(4):
nest.sli_run('dup')
nest.sli_run('cgnext')
self.assertEqual(nest.sli_pop(), True)
self.assertEqual(nest.sli_pop(), d)
self.assertEqual(nest.sli_pop(), w)
self.assertEqual(nest.sli_pop(), i)
self.assertEqual(nest.sli_pop(), i)
nest.sli_run('cgnext')
self.assertEqual(nest.sli_pop(), False)
示例12: libcsaTestCase
from . import compatibility
try:
import libcsa
HAVE_LIBCSA = True
except ImportError:
HAVE_LIBCSA = False
try:
import numpy
HAVE_NUMPY = True
except ImportError:
HAVE_NUMPY = False
nest.sli_run("statusdict/have_libneurosim ::")
HAVE_LIBNEUROSIM = nest.sli_pop()
@nest.check_stack
@unittest.skipIf(not HAVE_LIBCSA, 'Python libcsa package is not available')
@unittest.skipIf(
not HAVE_LIBNEUROSIM,
'PyNEST was built without the libneurosim library'
)
class libcsaTestCase(unittest.TestCase):
"""libcsa tests"""
def test_libcsa_OneToOne_subnet_1d(self):
"""One-to-one connectivity with 1-dim subnets"""
示例13: len
Create one subdir per number of MPI processes, then move into each subdir, run there.
Afterwards, diff subdirs. Diff should output nothing.
Hans Ekkehard Plesser, 2010-11-03, 2012-11-23
"""
import nest
import nest.topology as topo
import os
import sys
assert len(sys.argv) == 2, "Usage: topo_mpi_test.py convergent|divergent"
direction = sys.argv[1]
nest.sli_run('M_ERROR setverbosity')
nest.SetKernelStatus({'total_num_virtual_procs': 4})
l1 = topo.CreateLayer({'rows': 10,
'columns': 20,
'elements': ['iaf_neuron', 2],
'edge_wrap': True})
l2 = topo.CreateLayer({'rows': 10,
'columns': 20,
'elements': ['iaf_neuron', 2],
'edge_wrap': True})
topo.ConnectLayers(l1, l2, {'connection_type': direction,
'mask': {'circular': {'radius': 0.4}},
'weights': {'linear': {'c': 1., 'a': -5.}}})
示例14: print
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
import nest
nest.sli_run("statusdict/have_music ::")
if not nest.spp():
import sys
print("NEST was not compiled with support for MUSIC, not running.")
sys.exit()
mmip = nest.Create('music_message_in_proxy')
nest.SetStatus(mmip, {'port_name': 'msgdata'})
# Simulate and get message data with a granularity of 10 ms:
time = 0
while time < 1000:
nest.Simulate(10)
data = nest.GetStatus(mmip, 'data')
print(data)
示例15: empty_stack
def empty_stack():
nest.sli_run('clear')