本文整理汇总了Python中pyNN.parameters.ParameterSpace.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python ParameterSpace.evaluate方法的具体用法?Python ParameterSpace.evaluate怎么用?Python ParameterSpace.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyNN.parameters.ParameterSpace
的用法示例。
在下文中一共展示了ParameterSpace.evaluate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_evaluate_with_mask_2D
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_evaluate_with_mask_2D(self):
ps2d = ParameterSpace(
{"a": [[2, 3, 5, 8, 13], [21, 34, 55, 89, 144]], "b": 7, "c": lambda i, j: 3 * i - 2 * j}, shape=(2, 5)
)
ps2d.evaluate(mask=(slice(None), [1, 3, 4]))
assert_array_equal(ps2d["a"], np.array([[3, 8, 13], [34, 89, 144]]))
assert_array_equal(ps2d["c"], np.array([[-2, -6, -8], [1, -3, -5]]))
示例2: test_create_with_array_of_sequences
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_create_with_array_of_sequences(self):
schema = {"a": Sequence}
ps = ParameterSpace(
{"a": np.array([Sequence([1, 2, 3]), Sequence([4, 5, 6])], dtype=Sequence)}, schema, shape=(2,)
)
ps.evaluate()
assert_array_equal(ps["a"], np.array([Sequence([1, 2, 3]), Sequence([4, 5, 6])], dtype=Sequence))
示例3: test_iteration
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_iteration(self):
ps = ParameterSpace({'a': [2, 3, 5, 8, 13], 'b': 7, 'c': lambda i: 3*i+2}, shape=(5,))
ps.evaluate(mask=[1, 3, 4])
self.assertEqual(list(ps),
[{'a': 3, 'c': 5, 'b': 7},
{'a': 8, 'c': 11, 'b': 7},
{'a': 13, 'c': 14, 'b': 7}])
示例4: test_create_with_list_of_lists
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_create_with_list_of_lists(self):
schema = {'a': Sequence}
ps = ParameterSpace({'a': [[1, 2, 3], [4, 5, 6]]},
schema,
shape=(2,))
ps.evaluate()
assert_array_equal(ps['a'], np.array([Sequence([1, 2, 3]), Sequence([4, 5, 6])], dtype=Sequence))
示例5: test_create_with_tuple
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_create_with_tuple(self):
schema = {'a': Sequence}
ps = ParameterSpace({'a': (1, 2, 3)},
schema,
shape=(2,))
ps.evaluate()
assert_array_equal(ps['a'], np.array([Sequence([1, 2, 3]), Sequence([1, 2, 3])], dtype=Sequence))
示例6: test_iteration_items
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_iteration_items(self):
ps = ParameterSpace({'a': [2, 3, 5, 8, 13], 'b': 7, 'c': lambda i: 3*i+2}, shape=(5,))
ps.evaluate(mask=[1, 3, 4])
expected = {'a': np.array([3, 8, 13]),
'c': np.array([5, 11, 14]),
'b': np.array([7, 7, 7])}
for key, value in ps.items():
assert_array_equal(expected[key], value)
示例7: test_evaluate_with_mask
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_evaluate_with_mask(self):
ps = ParameterSpace({'a': [2, 3, 5, 8, 13], 'b': 7, 'c': lambda i: 3*i+2}, shape=(5,))
ps.evaluate(mask=[1, 3, 4])
expected = {'a': np.array([ 3, 8, 13]),
'c': np.array([ 5, 11, 14]),
'b': np.array([7, 7, 7])}
for key in expected:
assert_array_equal(expected[key], ps[key])
示例8: test_columnwise_iteration_single_column
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_columnwise_iteration_single_column(self):
ps2d = ParameterSpace(
{"a": [[2, 3, 5, 8, 13], [21, 34, 55, 89, 144]], "b": 7, "c": lambda i, j: 3 * i - 2 * j}, shape=(2, 5)
)
ps2d.evaluate(mask=(slice(None), 3))
expected = [{"a": np.array([8, 89]), "b": np.array([7, 7]), "c": np.array([-6, -3])}]
actual = list(ps2d.columns())
for x, y in zip(actual, expected):
for key in y:
assert_array_equal(x[key], y[key])
示例9: test_columnwise_iteration
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_columnwise_iteration(self):
ps2d = ParameterSpace({'a': [[2, 3, 5, 8, 13], [21, 34, 55, 89, 144]],
'b': 7,
'c': lambda i, j: 3*i-2*j}, shape=(2, 5))
ps2d.evaluate(mask=(slice(None), [1, 3, 4]))
expected = [{'a': np.array([3, 34]), 'b': np.array([7, 7]), 'c': np.array([-2, 1])},
{'a': np.array([8, 89]), 'b': np.array([7, 7]), 'c': np.array([-6, -3])},
{'a': np.array([13, 144]), 'b': np.array([7, 7]), 'c': np.array([-8, -5])}]
for x, y in zip(ps2d.columns(), expected):
for key in y:
assert_array_equal(x[key], y[key])
示例10: connect
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def connect(self, projection):
"""Connect-up a Projection."""
logger.debug("conn_list (original) = \n%s", self.conn_list)
if numpy.any(self.conn_list[:, 0] >= projection.pre.size):
raise errors.ConnectionError("source index out of range")
if (self.conn_list.shape[1] < 3 or self.conn_list.shape[1] > 4 or
(self.conn_list.shape[1] == 3 and projection.synapse_type.has_parameter('delay'))):
raise errors.ConnectionError("incompatible number of columns for connection list requires "
"4 (3 for synapse type without delay)")
# need to do some profiling, to figure out the best way to do this:
# - order of sorting/filtering by local
# - use numpy.unique, or just do in1d(self.conn_list)?
idx = numpy.argsort(self.conn_list[:, 1])
targets = numpy.unique(self.conn_list[:, 1]).astype(numpy.int)
local = numpy.in1d(targets,
numpy.arange(projection.post.size)[projection.post._mask_local],
assume_unique=True)
local_targets = targets[local]
self.conn_list = self.conn_list[idx]
left = numpy.searchsorted(self.conn_list[:, 1], local_targets, 'left')
right = numpy.searchsorted(self.conn_list[:, 1], local_targets, 'right')
logger.debug("idx = %s", idx)
logger.debug("targets = %s", targets)
logger.debug("local_targets = %s", local_targets)
logger.debug("conn_list (sorted by target) = \n%s", self.conn_list)
logger.debug("left = %s", left)
logger.debug("right = %s", right)
schema = projection.synapse_type.get_schema()
for tgt, l, r in zip(local_targets, left, right):
sources = self.conn_list[l:r, 0].astype(numpy.int)
param_dict = {'weight': self.conn_list[l:r, 2] }
if self.conn_list.shape[1] == 4:
param_dict['delay'] = self.conn_list[l:r, 3]
connection_parameters = ParameterSpace(param_dict,
schema=schema,
shape=(r-l,))
if isinstance(projection.synapse_type, StandardSynapseType):
connection_parameters = projection.synapse_type.translate(
connection_parameters)
connection_parameters.evaluate()
projection._convergent_connect(sources, tgt, **connection_parameters)
示例11: test_iteration
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_iteration(self):
ps = ParameterSpace({"a": [2, 3, 5, 8, 13], "b": 7, "c": lambda i: 3 * i + 2}, shape=(5,))
ps.evaluate(mask=[1, 3, 4])
self.assertEqual(list(ps), [{"a": 3, "c": 5, "b": 7}, {"a": 8, "c": 11, "b": 7}, {"a": 13, "c": 14, "b": 7}])
示例12: test_evaluate
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_evaluate(self):
ps = ParameterSpace({"a": [2, 3, 5, 8], "b": 7, "c": lambda i: 3 * i + 2}, shape=(4,))
self.assertIsInstance(ps["c"], LazyArray)
ps.evaluate()
assert_array_equal(ps["c"], np.array([2, 5, 8, 11]))
示例13: test_evaluate
# 需要导入模块: from pyNN.parameters import ParameterSpace [as 别名]
# 或者: from pyNN.parameters.ParameterSpace import evaluate [as 别名]
def test_evaluate(self):
ps = ParameterSpace({'a': [2, 3, 5, 8], 'b': 7, 'c': lambda i: 3*i+2}, shape=(4,))
self.assertIsInstance(ps['c'], LazyArray)
ps.evaluate()
assert_array_equal(ps['c'], np.array([ 2, 5, 8, 11]))