-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathplayground.py
191 lines (149 loc) · 4.3 KB
/
playground.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
from lolviz import *
def hashcode(o): return ord(o) # assume keys are single-element strings
# test linked list node
class Node:
def __str__(self):
return "Node(%s,%s)" % (self.value, str(self.next))
def __repr__(self):
return str(self)
def __init__(self, value, next=None):
self.value = value
self.next = next
class User:
def __init__(self, name, ID):
self.name = name
self.ID = ID
class Tree:
def __str__(self):
return "Tree(%s)" % (self.value)
def __repr__(self):
return str(self)
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def g(x):
s = "hi"
g1 = callsviz(varnames=None)
print(g1.source)
g1.view()
def f(x):
a = {Node('parrt'),Node('mary')}
b = {'hi','mom','heh', 'jude'}
a = {'hi','mom','mom1','mom2','mom3','mom4','mom5','mom6','mom7','mom8','mom9','mom10','foo','bar','mom','mom'}
# a = [i for i in range(15)]
d = dict([(c, chr(c)) for c in range(ord('a'), ord('f'))])
c = ['a','b','c','d']
listviz(d.items()).view()
# callsviz(varnames=['a','b','c','x','y','BLUE','ctr','head','users','root']).view()
def hashcode(o): return ord(o) # assume keys are single-element strings
foo = [99,100]
table = [ [], [], [], [], [] ]
key = 'a'
value = 99
bucket_index = hashcode(key) % len(table)
bucket = table[bucket_index]
bucket.append( (key,value) ) # add association to the bucket
bucket.append( (key+'x',value+100) ) # add association to the bucket
table[4].append( [9,8,7,6] )
# lolviz(table).view()
# g2 = lolviz(table)
# g2 = strviz('parrt')
# print g2.source
# g2.view()
# table = [[]]*5
# ggg=lolviz(table)
# print ggg.source
# ggg.view()
# callsviz(varnames=['value','x','GREEN','BLUE']).view()
mike = Tree('mike')
root = Tree('parrt',
Tree('mary',
Tree('jim',
Tree('srinivasan'),
Tree('april'))),
Tree('xue',None,mike))
mike.backptr = root
from collections import Counter
text = "the cat in the hat sat"
ctr = Counter(text.split(' '))
# objviz(ctr).view()
# exit(3)
# t=treeviz(root)
# print t.source
# t.view()
longlist = ['kkkkkkkkkkkkkkkkkkkkkkkkk','aaaaaaaaaaaaaaaaaaa', 'jjjjjjjjjjjjjjjjjjjjjjjjj', 'abcabc', 'kakakakakakakakakakakakakak']
# objviz(longlist).view()
table = [[3,4], ["aaa",5.3]]
d = {'super cool':table, 'bar':99}
table.append(d)
head = Node('tombu')
head = Node('parrt', head)
head = Node('foo', head)
h = Node('blort', Node(head))
# objviz(root).view()
# lolviz(bucket).view()
# g = llistviz(head)
users = [User('name'+str(i), i+100) for i in range(3)]
# gg = callviz(varnames=['root', 'head'])
# gg.view()
# print gg.source
# gg.view()
#f(989)
d = dict([(c,chr(c)) for c in range(ord('a'),ord('f'))])
tuplelist = d.items()
g = objviz(tuplelist)
#g.view()
# data = ['hi','mom',{3,4},{"parrt":"user"}]
# g = listviz(data)
# g.view()
# head2 = ('parrt',('mary',None))
# objviz(head2).view()
# print(root)
# g = callsviz()
# treeviz(root)
# print(g.source)
# g.view(cleanup=True)
# g.render('lolviz', view=True)
#g = callviz()
# print "hashcode =", hashcode(key)
# bucket_index = hashcode(key) % len(table)
# print "bucket_index =", bucket_index
# bucket = table[bucket_index]
# bucket.append((key, value)) # add association to the bucket
# lolviz(table)
# i = 3
# price = 9.4
# name = 'parrt'
# s = [3, 9, 10]
# t = {'a': 999, 'b': 1}
# JUNK DRAWER
#
# from subprocess import check_call
# check_call(['dot','-Tpng','InputFile.dot','-o','OutputFile.png'])
#
# s2 = """
# digraph G {
# nodesep=.2;
# ranksep=.2;
# node [shape=box, penwidth="0.5",width=.1,height=.1];
#
# """
# s2 += obj_nodes(g)
# s2 += obj_edges(g)
# s2 += '}'
# tr = graphviz.Source(s2)
# tr.save('lolviz_subgraph.dot')
# check_call(['dot', '-Tpng', 'lolviz_subgraph.dot', '-Gdpi=300', '-o', 'lolviz_subgraph.png'])
# check_call(['dot', '-Tpdf', 'lolviz_subgraph.dot', '-o', 'lolviz_subgraph.pdf'])
# check_call(['dot', '-Tgif', 'lolviz_subgraph.dot', '-o', 'lolviz_subgraph.gif'])
# s += 'nodedfadsfasdfasdf [image="lolviz_subgraph.pdf"]'
import numpy as np
B = np.ones((100,100))
for i in range(100):
for j in range(100):
B[i,j] = i+j
A = np.array([1,3,5])
g = callviz(varnames=['A'])
print(g.source)
g.view()