Exemplo n.º 1
0
 def on_message(self, message):
     try:
         if self.sim_id != None:
             data = self.receive(message)
             if data['status'] == 'activate':
                 wrapper.activate(self.sim_obj)
                 self.send({
                     'status': 'active',
                     'message': f'activated simulation {self.sim_id}',
                 })
             else:
                 self.send({
                     'status':
                     'active',
                     'message':
                     'step',
                     'outputs':
                     wrapper.step(self.sim_obj, data['inputs']),
                 })
     except tornado.websocket.WebSocketClosedError:
         self.receive(
             json.dumps({
                 'status': 'backend',
                 'message': 'websocket closed by client',
             }))
     except Exception as e:
         self.receive({
             'status': 'error',
             'message': str(e),
         })
Exemplo n.º 2
0
    def test_mutual_should_construct_mutual_information(self):
        '''
        Tests the mutual program to make sure it is working.

        '''
        data = numpy.loadtxt('test.dat')
        (_, mutual) = wrapper.activate('mutual')
        muts = mutual(input=data)
        expected = numpy.array([
                            [ 0., 2.766932],
                            [ 1., 2.626527],
                            [ 2., 2.523629],
                            [ 3., 2.43525 ],
                            [ 4., 2.356612],
                            [ 5., 2.28539 ],
                            [ 6., 2.220294],
                            [ 7., 2.160475],
                            [ 8., 2.105323],
                            [ 9., 2.054395],
                            [10., 2.007321],
                            [11., 1.963788],
                            [12., 1.923651],
                            [13., 1.886742],
                            [14., 1.852874],
                            [15., 1.821637],
                            [16., 1.792148],
                            [17., 1.763563],
                            [18., 1.734117],
                            [19., 1.704597],
                            [20., 1.673778]
                        ], dtype=numpy.float64)
        self.assertEquals(muts.shape, expected.shape)
        for i in xrange(21):
            self.assertAlmostEqual(expected[i, 0], muts[i, 0])
            self.assertAlmostEqual(expected[i, 1], muts[i, 1])
Exemplo n.º 3
0
 def on_message(self, message):
     try:
         if self.sim_id != None:
             data = self.receive(message)
             if data['message'] == 'activate':
                 wrapper.activate(self.sim)
                 self.send({'message': 'active'})
             else:
                 self.send({
                     'message':
                     'active',
                     'outputs':
                     wrapper.step(self.sim, data['inputs']),
                 })
     except tornado.websocket.WebSocketClosedError:
         self.receive(
             json.dumps({
                 'message': 'backend',
                 'status': 'WebSocket closed by client.',
             }))
     except Exception as e:
         print(e)
Exemplo n.º 4
0
    'randomize_spike',
    'randomize_uneven',
    'rms',
    'spectrum',
    'spikeauto',
    'spikespec',
    'stp',
    'surrogates',
    'timerev',
    'upo',
    'upoembed',
    'wiener',
    'xc2',
    'xrecur'
]

FILE_OUTPUT_REQUIRED = [
    'boxcount',
    'lyap_k',
    'lyap_r',
    'polynom',
    'polypar',
]

selfmod = sys.modules[__name__]
selfmod.__dict__.update([wrapper.activate(program) for program in PROGRAMS])
selfmod.__dict__.update([
    wrapper.activate(program, output_to_file=True)
    for program in FILE_OUTPUT_REQUIRED
])
Exemplo n.º 5
0
    "pc",
    "predict",
    "project",
    "randomize",
    "randomize_auto",
    "randomize_cool",
    "randomize_cost",
    "randomize_extend",
    "randomize_perm",
    "randomize_spike",
    "randomize_uneven",
    "rms",
    "spectrum",
    "spikeauto",
    "spikespec",
    "stp",
    "surrogates",
    "timerev",
    "upo",
    "upoembed",
    "wiener",
    "xc2",
    "xrecur",
]

FILE_OUTPUT_REQUIRED = ["boxcount", "lyap_k", "lyap_r", "polynom", "polypar"]

selfmod = sys.modules[__name__]
selfmod.__dict__.update([wrapper.activate(program) for program in PROGRAMS])
selfmod.__dict__.update([wrapper.activate(program, output_to_file=True) for program in FILE_OUTPUT_REQUIRED])