Beispiel #1
0
    def test_direct_mode_simple(self):
        """
        """
        net = Network('Runtime Test', dt=0.001, seed=123,
                     Simulator=self.Simulator)
        net.make_input('in', value=np.sin)
        p = net.make_probe('in', dt_sample=0.001, pstc=0.0)
        rawp = net._raw_probe(net.inputs['in'], dt_sample=.001)
        st_probe = net._raw_probe(net.simtime, dt_sample=.001)
        net.run(0.01)

        data = p.get_data()
        raw_data = rawp.get_data()
        st_data = st_probe.get_data()
        print data.dtype
        print st_data
        print raw_data
        assert np.allclose(st_data.ravel(),
                           np.arange(0.001, 0.0105, .001))
        assert np.allclose(raw_data.ravel(),
                           np.sin(np.arange(0, 0.0095, .001)))
        # -- the make_probe call induces a one-step delay
        #    on readout even when the pstc is really small.
        assert np.allclose(data.ravel()[1:],
                           np.sin(np.arange(0, 0.0085, .001)))
Beispiel #2
0
    def test_counters(self):
        net = Network('foo', dt=0.001, seed=123,
                     Simulator=self.Simulator)

        simtime_probe = net._raw_probe(net.simtime, dt_sample=.001)
        steps_probe = net._raw_probe(net.steps, dt_sample=.001)
        net.run(0.003)
        simtime_data = simtime_probe.get_data()
        steps_data = steps_probe.get_data()
        assert np.allclose(simtime_data.flatten(), [.001, .002, .003])
        assert np.allclose(steps_data.flatten(), [1, 2, 3])