本文整理汇总了Python中pyNN.parameters.ParameterSpace.update方法的典型用法代码示例。如果您正苦于以下问题:Python ParameterSpace.update方法的具体用法?Python ParameterSpace.update怎么用?Python ParameterSpace.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyNN.parameters.ParameterSpace
的用法示例。
在下文中一共展示了ParameterSpace.update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import update [as 别名]
def __init__(self, **parameters):
self._device = nest.Create(self.nest_name)
self.cell_list = []
parameter_space = ParameterSpace(self.default_parameters,
self.get_schema(),
shape=(1,))
parameter_space.update(**parameters)
parameter_space = self.translate(parameter_space)
self.set_native_parameters(parameter_space)
示例2: __init__
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import update [as 别名]
def __init__(self, **parameters):
super(StandardCurrentSource, self).__init__(**parameters)
self.cell_list = []
self.indices = []
simulator.state.current_sources.append(self)
parameter_space = ParameterSpace(self.default_parameters,
self.get_schema(),
shape=(1,))
parameter_space.update(**parameters)
parameter_space = self.translate(parameter_space)
self.set_native_parameters(parameter_space)
示例3: BaseModelType
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import update [as 别名]
class BaseModelType(object):
"""Base class for standard and native cell and synapse model classes."""
default_parameters = {}
default_initial_values = {}
parameter_checks = {}
def __init__(self, **parameters):
"""
`parameters` should be a mapping object, e.g. a dict
"""
self.parameter_space = ParameterSpace(self.default_parameters,
self.get_schema(),
shape=None)
if parameters:
self.parameter_space.update(**parameters)
def __repr__(self):
return "%s(<parameters>)" % self.__class__.__name__ # should really include the parameters explicitly, to be unambiguous
@classmethod
def has_parameter(cls, name):
"""Does this model have a parameter with the given name?"""
return name in cls.default_parameters
@classmethod
def get_parameter_names(cls):
"""Return the names of the parameters of this model."""
return list(cls.default_parameters.keys())
def get_schema(self):
"""
Returns the model schema: i.e. a mapping of parameter names to allowed
parameter types.
"""
return dict((name, type(value))
for name, value in self.default_parameters.items())
def describe(self, template='modeltype_default.txt', engine='default'):
"""
Returns a human-readable description of the cell or synapse type.
The output may be customized by specifying a different template
togther with an associated template engine (see ``pyNN.descriptions``).
If template is None, then a dictionary containing the template context
will be returned.
"""
context = {
"name": self.__class__.__name__,
"default_parameters": self.default_parameters,
"default_initial_values": self.default_initial_values,
"parameters": self.parameter_space._parameters, # should add a describe() method to ParameterSpace
}
return descriptions.render(engine, template, context)
示例4: NestCurrentSource
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import update [as 别名]
class NestCurrentSource(BaseCurrentSource):
"""Base class for a nest source of current to be injected into a neuron."""
def __init__(self, **parameters):
self._device = nest.Create(self.nest_name)
self.cell_list = []
self.parameter_space = ParameterSpace(self.default_parameters,
self.get_schema(),
shape=(1,))
if parameters:
self.parameter_space.update(**parameters)
self.min_delay = state.min_delay
self.dt = state.dt
def inject_into(self, cells):
for id in cells:
if id.local and not id.celltype.injectable:
raise TypeError("Can't inject current into a spike source.")
if isinstance(cells, (Population, PopulationView, Assembly)):
self.cell_list = [cell for cell in cells]
else:
self.cell_list = cells
nest.Connect(self._device, self.cell_list, syn_spec={"delay": state.min_delay})
def _delay_correction(self, value):
"""
A change in a device requires a min_delay to take effect at the target
"""
corrected = value - self.min_delay
# set negative times to zero
if isinstance(value, numpy.ndarray):
corrected = numpy.where(corrected > 0, corrected, 0.0)
else:
corrected = max(corrected, 0.0)
return corrected
def record(self):
self.i_multimeter = nest.Create('multimeter', params={'record_from': ['I'], 'interval': state.dt})
nest.Connect(self.i_multimeter, self._device)
def _get_data(self):
events = nest.GetStatus(self.i_multimeter)[0]['events']
# Similar to recording.py: NEST does not record values at
# the zeroth time step, so we add them here.
t_arr = numpy.insert(numpy.array(events['times']), 0, 0.0)
i_arr = numpy.insert(numpy.array(events['I']/1000.0), 0, 0.0)
# NEST and pyNN have different concepts of current initiation times
# To keep this consistent across simulators, we will have current
# initiating at the electrode at t_start and effect on cell at next dt
# This requires padding min_delay equivalent period with 0's
pad_length = int(self.min_delay/self.dt)
i_arr = numpy.insert(i_arr[:-pad_length], 0, [0]*pad_length)
return t_arr, i_arr
示例5: __init__
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import update [as 别名]
def __init__(self, **parameters):
self._devices = []
self.cell_list = []
self._amplitudes = None
self._times = None
self._h_iclamps = {}
parameter_space = ParameterSpace(self.default_parameters,
self.get_schema(),
shape=(1,))
parameter_space.update(**parameters)
parameter_space = self.translate(parameter_space)
self.set_native_parameters(parameter_space)
示例6: __init__
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import update [as 别名]
def __init__(self, **parameters):
super(StandardCurrentSource, self).__init__(**parameters)
global current_sources
self.cell_list = []
self.indices = []
self.ind = len(current_sources) # Todo use self.indices instead...
current_sources.append(self)
parameter_space = ParameterSpace(self.default_parameters,
self.get_schema(),
shape=(1,))
parameter_space.update(**parameters)
parameter_space = self.translate(parameter_space)
self.set_native_parameters(parameter_space)