当前位置: 首页>>代码示例>>Python>>正文


Python utility.assert_arrays_equal函数代码示例

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


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


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