本文整理汇总了Python中brian2.groups.group.CodeRunner.before_run方法的典型用法代码示例。如果您正苦于以下问题:Python CodeRunner.before_run方法的具体用法?Python CodeRunner.before_run怎么用?Python CodeRunner.before_run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brian2.groups.group.CodeRunner
的用法示例。
在下文中一共展示了CodeRunner.before_run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: before_run
# 需要导入模块: from brian2.groups.group import CodeRunner [as 别名]
# 或者: from brian2.groups.group.CodeRunner import before_run [as 别名]
def before_run(self, run_namespace=None, level=0):
# execute code to initalize the spike queue
if self._initialise_queue_codeobj is None:
self._initialise_queue_codeobj = create_runner_codeobj(self,
'', # no code,
'synapses_initialise_queue',
name=self.name+'_initialise_queue',
check_units=False,
additional_variables=self.variables,
run_namespace=run_namespace,
level=level+1)
self._initialise_queue_codeobj()
CodeRunner.before_run(self, run_namespace, level=level+1)
# we insert rather than replace because CodeRunner puts a CodeObject in updaters already
if self._pushspikes_codeobj is None:
self._pushspikes_codeobj = create_runner_codeobj(self,
'', # no code
'synapses_push_spikes',
name=self.name+'_push_spikes',
check_units=False,
additional_variables=self.variables,
run_namespace=run_namespace,
level=level+1)
self._code_objects.insert(0, weakref.proxy(self._pushspikes_codeobj))
示例2: before_run
# 需要导入模块: from brian2.groups.group import CodeRunner [as 别名]
# 或者: from brian2.groups.group.CodeRunner import before_run [as 别名]
def before_run(self, run_namespace):
# execute code to initalize the data structures
if self._prepare_codeobj is None:
self._prepare_codeobj = create_runner_codeobj(self.group,
'', # no code,
'spatialneuron_prepare',
name=self.name+'_spatialneuron_prepare',
check_units=False,
additional_variables=self.variables,
run_namespace=run_namespace)
self._prepare_codeobj()
# Raise a warning if the slow pure numpy version is used
# For simplicity, we check which CodeObject class the _prepare_codeobj
# is using, this will be the same as the main state updater
from brian2.codegen.runtime.numpy_rt.numpy_rt import NumpyCodeObject
if isinstance(self._prepare_codeobj, NumpyCodeObject):
# If numpy is used, raise a warning if scipy is not present
try:
import scipy
except ImportError:
logger.info(('SpatialNeuron will use numpy to do the numerical '
'integration -- this will be very slow. Either '
'switch to a different code generation target '
'(e.g. weave or cython) or install scipy.'),
once=True)
CodeRunner.before_run(self, run_namespace)
示例3: before_run
# 需要导入模块: from brian2.groups.group import CodeRunner [as 别名]
# 或者: from brian2.groups.group.CodeRunner import before_run [as 别名]
def before_run(self, run_namespace=None, level=0):
if self._group.dt != self._stored_dt:
raise NotImplementedError('The dt used for simulating %s changed '
'after the PoissonInput source was '
'created.' % self.group.name)
CodeRunner.before_run(self, run_namespace=run_namespace,
level=level+1)
示例4: before_run
# 需要导入模块: from brian2.groups.group import CodeRunner [as 别名]
# 或者: from brian2.groups.group.CodeRunner import before_run [as 别名]
def before_run(self, run_namespace=None, level=0):
# execute code to initalize the data structures
if self._prepare_codeobj is None:
self._prepare_codeobj = create_runner_codeobj(self.group,
'', # no code,
'spatialneuron_prepare',
name=self.name+'_spatialneuron_prepare',
check_units=False,
additional_variables=self.variables,
run_namespace=run_namespace,
level=level+1)
self._prepare_codeobj()
CodeRunner.before_run(self, run_namespace, level=level + 1)
示例5: before_run
# 需要导入模块: from brian2.groups.group import CodeRunner [as 别名]
# 或者: from brian2.groups.group.CodeRunner import before_run [as 别名]
def before_run(self, run_namespace=None, level=0):
if not self._isprepared: # this is done only once even if there are multiple runs
self.prepare()
self._isprepared = True
CodeRunner.before_run(self, run_namespace, level=level + 1)