-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.py
59 lines (43 loc) · 1.34 KB
/
core.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
This module defines Tengolo's core classes for models, views, logs, and batches
"""
import time
import matplotlib.pyplot as pyl
class TengoloModel(object):
def set_param(self, param, value ):
self.__dict__[param] = value
def get_param(self, param ):
return self.__dict__[param]
class TengoloView(object):
def __init__(self, model):
self.controls = []
self.observers = []
self.model = model
self.ax_count = 0
def set_param(self, param, val):
self.model.set_param(param, val)
self.update()
def update(self):
self.model.update()
for (i, obj) in enumerate(self.observers):
obj['render_function'](obj["ax"], self.model, obj["args"])
pyl.draw()
def render(self):
self.update()
pyl.show()
def add_observer(self, render_function, location, args):
ax = pyl.axes(location)
self.observers.append({
"render_function": render_function,
"ax": ax,
"args": args,
})
self.ax_count += 1
def add_control(self, render_function, param, location, args ):
ax = pyl.axes(location)
self.controls.append( render_function(ax, self, param, args) )
self.ax_count += 1
class TengoloLog(object):
pass
class TengoloBatch(object):
pass