-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester_classes.py
56 lines (51 loc) · 1.43 KB
/
tester_classes.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
from vec import Vec
from mat import Mat
class DummyItem(object):
def __init__(self):
self.multiplications = []
def __getattr__(self, _): return self
def __getitem__(self, _): return self
def __mul__(self, v):
self.multiplications.append(v)
return v
def __rmul__(self, v):
self.multiplications.append(v)
return v
dummy = DummyItem()
class Tester(object):
def __init__(self, labels):
self.D = labels
self.right = []
self.left = []
def __getitem__(self, k): return 0
def __setitem__(self, k, v): pass
class VecTester(Tester):
def __mul__(self, v):
self.right.append(v)
vn = type(v).__name__
if vn == 'Vec':
return 0
if vn == 'Mat':
return Vec(v.D[1], {})
def __rmul__(self, v):
self.left.append(v)
vn = type(v).__name__
if vn == 'Vec':
return 0
if vn == 'Mat':
return Vec(v.D[0], {})
class MatTester(Tester):
def __mul__(self, v):
self.right.append(v)
vn = type(v).__name__
if vn == 'Vec':
return Vec(self.D[0], {})
if vn == 'Mat':
return Vec(self.D[1], {})
def __rmul__(self, v):
self.left.append(v)
vn = type(v).__name__
if vn == 'Vec':
return Vec(self.D[1], {})
if vn == 'Mat':
return Vec((v.D[0], self.D[1]), {})