• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utility.assert_arrays_equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyNN.utility.assert_arrays_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_arrays_equal函数的具体用法?Python assert_arrays_equal怎么用?Python assert_arrays_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_arrays_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test__make_compatible_v

def test__make_compatible_v():
    r = recording.Recorder('v')
    input_data = numpy.array([[0, 0.0, -65.0], [3, 0.0, -65.0],
                              [0, 0.1, -64.3], [3, 0.1, -65.1],
                              [0, 0.2, -63.7], [3, 0.2, -65.5]])
    output_data = r._make_compatible(input_data) # voltage id
    assert_arrays_equal(input_data[:,(2,0)], output_data) 
开发者ID:agravier,项目名称:pynn,代码行数:7,代码来源:test_recording.py


示例2: test_infinite_space_with_3D_distances

 def test_infinite_space_with_3D_distances(self):
     s = space.Space()
     self.assertEqual(s.distances(self.A, self.B), sqrt(3))
     self.assertEqual(s.distances(self.C, self.B), sqrt(12))
     self.assertArraysEqual(s.distances(self.A, self.ABCD), numpy.array([0.0, sqrt(3), sqrt(3), sqrt(29)]))
     self.assertArraysEqual(s.distances(self.A, self.ABCD), s.distances(self.ABCD, self.A).T)
     assert_arrays_equal(
         s.distances(self.ABCD, self.ABCD),
         numpy.array(
             [
                 0.0,
                 sqrt(3),
                 sqrt(3),
                 sqrt(29),
                 sqrt(3),
                 0.0,
                 sqrt(12),
                 sqrt(14),
                 sqrt(3),
                 sqrt(12),
                 0.0,
                 sqrt(50.0),
                 sqrt(29),
                 sqrt(14),
                 sqrt(50.0),
                 0.0,
             ]
         ),
     )
     self.assertArraysEqual(s.distances(self.ABCD, self.A), numpy.array([0.0, sqrt(3), sqrt(3), sqrt(29)]))
开发者ID:costypetrisor,项目名称:PyNN,代码行数:30,代码来源:test_space.py


示例3: test_get_positions

def test_get_positions():
    p = MockPopulation(11, MockStandardCell)
    ppos = numpy.random.uniform(size=(3,11))
    p._positions = ppos
    pv = common.PopulationView(parent=p,
                               selector=slice(3,9,2))
    assert_arrays_equal(pv.positions, numpy.array([ppos[:,3], ppos[:,5], ppos[:,7]]).T)
开发者ID:agravier,项目名称:pynn,代码行数:7,代码来源:test_populationview.py


示例4: test_really_simple1

 def test_really_simple1(self):
     A = numpy.ones((3,))
     B = numpy.zeros((3,5))
     D = connectors.DistanceMatrix(B, space.Space())
     D.set_source(A)
     assert_arrays_equal(D.as_array(),
                         numpy.sqrt(3*numpy.ones((5,), float)))
开发者ID:agravier,项目名称:pynn,代码行数:7,代码来源:test_connectors.py


示例5: test_reset_recording

def test_reset_recording(sim):
    """
    Check that record(None) resets the list of things to record.

    This test injects different levels of current into two neurons. In the
    first run, we record one of the neurons, in the second we record the other.
    The main point is to check that the first neuron is not recorded in the
    second run.
    """
    sim.setup()
    p = sim.Population(7, sim.IF_cond_exp())
    p[3].i_offset = 0.1
    p[4].i_offset = 0.2
    p[3:4].record('v')
    sim.run(10.0)
    sim.reset()
    p.record(None)
    p[4:5].record('v')
    sim.run(10.0)
    data = p.get_data()
    sim.end()
    ti = lambda i: data.segments[i].analogsignalarrays[0].times
    assert_arrays_equal(ti(0), ti(1))
    idx = lambda i: data.segments[i].analogsignalarrays[0].channel_index
    assert idx(0) == [3]
    assert idx(1) == [4]
    vi = lambda i: data.segments[i].analogsignalarrays[0]
    assert vi(0).shape == vi(1).shape == (101, 1)
    assert vi(0)[0, 0] == vi(1)[0, 0] == p.initial_values['v'].evaluate(simplify=True)*pq.mV # the first value should be the same
    assert not (vi(0)[1:, 0] == vi(1)[1:, 0]).any()            # none of the others should be, because of different i_offset
开发者ID:costypetrisor,项目名称:PyNN,代码行数:30,代码来源:test_recording.py


示例6: test_columnwise_iteration_with_structured_array_and_mask

def test_columnwise_iteration_with_structured_array_and_mask():
    input = numpy.arange(12).reshape((4,3))
    m = LazyArray(input, shape=(4,3)) # 4 rows, 3 columns
    mask = numpy.array([False, True, True])
    cols = [col for col in m.by_column(mask=mask)]    
    assert_arrays_equal(cols[0], input[:,1])
    assert_arrays_equal(cols[1], input[:,2])
开发者ID:agravier,项目名称:pynn,代码行数:7,代码来源:test_core.py


示例7: test_apply_function_to_structured_array

def test_apply_function_to_structured_array():
    f = lambda m: 2*m + 3
    input = numpy.arange(12).reshape((4,3))
    m0 = LazyArray(input, shape=(4,3))
    m1 = f(m0)
    assert isinstance(m1, larray)
    assert_arrays_equal(m1.evaluate(simplify=True), input*2 + 3)
开发者ID:agravier,项目名称:pynn,代码行数:7,代码来源:test_core.py


示例8: test_set_synaptic_parameters

def test_set_synaptic_parameters(sim):
    sim.setup()
    mpi_rank = sim.rank()
    p1 = sim.Population(4, sim.IF_cond_exp())
    p2 = sim.Population(2, sim.IF_cond_exp())
    syn = sim.TsodyksMarkramSynapse(U=0.5, weight=0.123, delay=0.1)
    prj = sim.Projection(p1, p2, sim.AllToAllConnector(), syn)

    expected = numpy.array([
        (0.0, 0.0, 0.123, 0.1, 0.5),
        (0.0, 1.0, 0.123, 0.1, 0.5),
        (1.0, 0.0, 0.123, 0.1, 0.5),
        (1.0, 1.0, 0.123, 0.1, 0.5),
        (2.0, 0.0, 0.123, 0.1, 0.5),
        (2.0, 1.0, 0.123, 0.1, 0.5),
        (3.0, 0.0, 0.123, 0.1, 0.5),
        (3.0, 1.0, 0.123, 0.1, 0.5),
    ])
    actual = numpy.array(prj.get(['weight', 'delay', 'U'], format='list'))
    if mpi_rank == 0:
        ind = numpy.lexsort((actual[:, 1], actual[:, 0]))
        assert_arrays_equal(actual[ind], expected)

    positional_weights = numpy.array([[0, 1], [2, 3], [4, 5], [6, 7]], dtype=float)
    prj.set(weight=positional_weights)
    expected = positional_weights
    actual = prj.get('weight', format='array')
    if mpi_rank == 0:
        assert_arrays_equal(actual, expected)

    u_list = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]
    prj.set(U=u_list)
    expected = numpy.array([[0.9, 0.8], [0.7, 0.6], [0.5, 0.4], [0.3, 0.2]])
    actual = prj.get('U', format='array')
    if mpi_rank == 0:
        assert_arrays_equal(actual, expected)

    f_delay = lambda d: 0.5+d
    prj.set(delay=f_delay)
    expected = numpy.array([[0.5, 1.5], [1.5, 0.5], [2.5, 1.5], [3.5, 2.5]])
    actual = prj.get('delay', format='array')
    if mpi_rank == 0:
        assert_arrays_equal(actual, expected)

    # final sanity check
    expected = numpy.array([
        (0.0, 0.0, 0.0, 0.5, 0.9),
        (0.0, 1.0, 1.0, 1.5, 0.8),
        (1.0, 0.0, 2.0, 1.5, 0.7),
        (1.0, 1.0, 3.0, 0.5, 0.6),
        (2.0, 0.0, 4.0, 2.5, 0.5),
        (2.0, 1.0, 5.0, 1.5, 0.4),
        (3.0, 0.0, 6.0, 3.5, 0.3),
        (3.0, 1.0, 7.0, 2.5, 0.2),
    ])
    actual = numpy.array(prj.get(['weight', 'delay', 'U'], format='list'))
    if mpi_rank == 0:
        ind = numpy.lexsort((actual[:, 1], actual[:, 0]))
        assert_arrays_equal(actual[ind], expected)
开发者ID:jougs,项目名称:PyNN,代码行数:59,代码来源:test_parameter_handling.py


示例9: test__record

def test__record():
    p = MockPopulation()
    p.recorders = {'v': Mock()}
    p._record('v')
    meth, args, kwargs = p.recorders['v'].method_calls[0]
    id_arr, = args
    assert_equal(meth, 'record')
    assert_arrays_equal(id_arr, p.all_cells)
开发者ID:agravier,项目名称:pynn,代码行数:8,代码来源:test_basepopulation.py


示例10: test_evaluate_with_functional_array

def test_evaluate_with_functional_array():
    input = lambda i,j: 2*i + j
    m = LazyArray(input, shape=(4,3))
    assert_arrays_equal(m.evaluate(),
                        numpy.array([[0, 1, 2],
                                     [2, 3, 4],
                                     [4, 5, 6],
                                     [6, 7, 8]]))
开发者ID:agravier,项目名称:pynn,代码行数:8,代码来源:test_core.py


示例11: issue241

def issue241(sim):
    spike_train1 = sim.Population(1, sim.SpikeSourcePoisson, {'rate' : [5], 'start' : [1000], 'duration': [1234]})
    spike_train2 = sim.Population(2, sim.SpikeSourcePoisson, {'rate' : [5, 6], 'start' : [1000, 1001], 'duration': [1234, 2345]})
    spike_train3 = sim.Population(1, sim.SpikeSourcePoisson, {'rate' : [5], 'start' : [1000], 'duration': 1234})
    spike_train4 = sim.Population(1, sim.SpikeSourcePoisson, {'rate' : [5], 'start' : [1000]})
    spike_train5 = sim.Population(2, sim.SpikeSourcePoisson, {'rate' : [5, 6], 'start' : [1000, 1001]})
    assert_arrays_equal(spike_train2.get('duration'), numpy.array([1234, 2345]))
    assert_equal(spike_train3.get(['rate', 'start', 'duration']), [5, 1000, 1234])
开发者ID:mfraezz,项目名称:PyNN,代码行数:8,代码来源:test_parameter_handling.py


示例12: test_tset_with_array_values

def test_tset_with_array_values():
    p = MockPopulation()
    p._set_array = Mock()
    spike_times = numpy.linspace(0.0, 1000.0, num=10*p.size).reshape((p.size,10))
    p.tset("spike_times", spike_times)
    call_args = p._set_array.call_args[1]['spike_times']
    assert_equal(call_args.shape, spike_times[p._mask_local].shape)
    assert_arrays_equal(call_args.flatten(),
                        spike_times[p._mask_local].flatten())
开发者ID:agravier,项目名称:pynn,代码行数:9,代码来源:test_basepopulation.py


示例13: test_get__zero_offset

def test_get__zero_offset():
    r = recording.Recorder('spikes')
    fake_data = numpy.array([
                    (3, 12.3),
                    (4, 14.5),
                    (7, 19.8)
                ])
    r._get = Mock(return_value=fake_data)
    assert_arrays_equal(r.get(), fake_data)
开发者ID:agravier,项目名称:pynn,代码行数:9,代码来源:test_recording.py


示例14: test_sample

def test_sample():
    orig_pv = populations.PopulationView
    populations.PopulationView = Mock()
    p = MockPopulation()
    rng = Mock()
    rng.permutation = Mock(return_value=numpy.array([7,4,8,12,0,3,9,1,2,11,5,10,6]))
    pv = p.sample(5, rng=rng)
    assert_arrays_equal(populations.PopulationView.call_args[0][1], numpy.array([7,4,8,12,0]))
    populations.PopulationView = orig_pv
开发者ID:agravier,项目名称:pynn,代码行数:9,代码来源:test_basepopulation.py


示例15: test_initialize_random_distribution

def test_initialize_random_distribution():
    p = MockPopulation()
    p.initial_values = {}
    p._set_initial_value_array = Mock()
    class MockRandomDistribution(random.RandomDistribution):
        def next(self, n, mask_local):
            return 42*numpy.ones(n)[mask_local]
    p.initialize('v', MockRandomDistribution())
    assert_arrays_equal(p.initial_values['v'].evaluate(simplify=True), 42*numpy.ones(p.local_size))
开发者ID:agravier,项目名称:pynn,代码行数:9,代码来源:test_basepopulation.py


示例16: test_set_positions

def test_set_positions():
    p = MockPopulation(11, MockStandardCell)
    assert p._structure != None
    new_positions = numpy.random.uniform(size=(3,11))
    p.positions = new_positions
    assert_equal(p.structure, None)
    assert_arrays_equal(p.positions, new_positions)
    new_positions[0,0] = 99.9
    assert p.positions[0,0] != 99.9
开发者ID:agravier,项目名称:pynn,代码行数:9,代码来源:test_population.py


示例17: test_apply_function_to_functional_array

def test_apply_function_to_functional_array():
    input = lambda i,j: 2*i + j
    m0 = LazyArray(input, shape=(4,3))
    f = lambda m: 2*m + 3
    m1 = f(m0)
    assert_arrays_equal(m1.evaluate(),
                        numpy.array([[3, 5, 7],
                                     [7, 9, 11],
                                     [11, 13, 15],
                                     [15, 17, 19]]))
开发者ID:agravier,项目名称:pynn,代码行数:10,代码来源:test_core.py


示例18: test_local_cells

def test_local_cells():
    p1 = MockPopulation()
    p2 = MockPopulation()
    p3 = MockPopulation()
    a = Assembly(p1, p2, p3)
    assert_equal(a.local_cells.size,
                 p1.local_cells.size + p2.local_cells.size + p3.local_cells.size)
    assert_equal(a.local_cells[0], p1.local_cells[0])
    assert_equal(a.local_cells[-1], p3.local_cells[-1])
    assert_arrays_equal(a.local_cells, numpy.append(p1.local_cells, (p2.local_cells, p3.local_cells)))
开发者ID:agravier,项目名称:pynn,代码行数:10,代码来源:test_assembly.py


示例19: test_weight_histogram_no_args

def test_weight_histogram_no_args():
    p1 = MockPopulation()
    p2 = MockPopulation()
    prj = common.Projection(p1, p2, method=Mock())
    prj.getWeights = Mock(return_value=numpy.array(range(10)*42))
    n, bins = prj.weightHistogram(nbins=10)
    assert_equal(n.size, 10)
    assert_equal(bins.size, n.size+1)
    assert_arrays_equal(n, 42*numpy.ones(10))
    assert_equal(n.sum(), 420)
    assert_arrays_equal(bins, numpy.arange(0.0, 9.1, 0.9))
开发者ID:agravier,项目名称:pynn,代码行数:11,代码来源:test_projection.py


示例20: test_mask_local

def test_mask_local():
    p1 = MockPopulation()
    p2 = MockPopulation()
    p3 = MockPopulation()
    a = Assembly(p1, p2, p3)
    assert_equal(a._mask_local.size,
                 p1._mask_local.size + p2._mask_local.size + p3._mask_local.size)
    assert_equal(a._mask_local[0], p1._mask_local[0])
    assert_equal(a._mask_local[-1], p3._mask_local[-1])
    assert_arrays_equal(a._mask_local, numpy.append(p1._mask_local, (p2._mask_local, p3._mask_local)))
    assert_arrays_equal(a.local_cells, a.all_cells[a._mask_local])
开发者ID:agravier,项目名称:pynn,代码行数:11,代码来源:test_assembly.py



注:本文中的pyNN.utility.assert_arrays_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utility.get_script_args函数代码示例发布时间:2022-05-25
下一篇:
Python spiNNaker.setup函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap