Skip to content

Commit 95b976e

Browse files
author
Philip Guo
committed
updated tests for Python 3.2 (doesn't work on 3.3 though)
1 parent a97efd3 commit 95b976e

16 files changed

+82992
-10349
lines changed

v3/example-code/chris-meyers/optFib.golden_py3

Lines changed: 51160 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 339 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,339 @@
1+
{
2+
"code": "# o p t K n a p s a c k . p y\n#\n# Chris Meyers. 09/25/2013\n#\nfrom htmlFrame import HtmlFrame\nfrom matrix import Matrix\n\nmaxwgt = 10\nvals = [0,10,40,30,50]\nwgts = [0, 5, 4, 6, 3]\n\nhtmlPage = HtmlFrame()\nhtmlPage.banner = \"Knapsack Problem\"\nheaders=['wt'+str(i) for i in range(maxwgt+1)]\n\ninp = Matrix(len(vals),3)\ninp.title = \"Sack holds weight %s\" % maxwgt\ninp.dftFormat = \"<pre>%03s</pre>\"\ninp.tableAttr = 'border=\"1\" cellspacing=\"0\" cellpadding=\"4\"',\ninp.tableHeaders=['Item #','Weight','Value'] \nfor i in range(len(vals)) :\n inp.setrowVals(i, [i, wgts[i], vals[i]])\n\nframe = Matrix(1,2)\nframe[0,0] = inp.renderHtml()\nnItems = len(vals)\nbest = Matrix(nItems,maxwgt+1)\nbest.dftFormat = \"<pre>%03s</pre>\"\n\nfor i in range(1,nItems) :\n best.setrowVal(i,0)\nfor i in range(1,nItems) :\n for w in range(0,maxwgt+1) :\n remBest = best[i-1,w-wgts[i]]\n if remBest == None : remBest = 0\n newSolution = vals[i]+remBest\n if ((wgts[i] <= w and newSolution > best[i-1,w])) :\n best[i,w] = newSolution\n best.style[i,w] = \"background-color:pink\"\n best.title = \"Optimal solution for weight %s includes item %s\" % (w,i)\n best.tableAttr='border=\"1\" cellspacing=\"0\" cellpadding=\"4\"'\n best.tableHeaders=headers\n frame[0,1] = best.renderHtml()\n htmlPage.item1 = frame.renderHtml()\n htmlPage.makeFrame() #break\n else :\n best[i,w] = best[i-1,w]\n",
3+
"trace": [
4+
{
5+
"ordered_globals": [
6+
"HtmlFrame",
7+
"Matrix",
8+
"maxwgt",
9+
"vals",
10+
"wgts",
11+
"htmlPage",
12+
"headers",
13+
"inp",
14+
"i",
15+
"frame",
16+
"nItems",
17+
"best",
18+
"w",
19+
"remBest",
20+
"newSolution"
21+
],
22+
"stdout": "",
23+
"exception_msg": "TypeError: unorderable types: int() > NoneType()",
24+
"func_name": "<module>",
25+
"stack_to_render": [],
26+
"globals": {
27+
"wgts": [
28+
"REF",
29+
19
30+
],
31+
"nItems": 5,
32+
"Matrix": [
33+
"REF",
34+
5
35+
],
36+
"maxwgt": 10,
37+
"i": 1,
38+
"frame": [
39+
"REF",
40+
24
41+
],
42+
"inp": [
43+
"REF",
44+
23
45+
],
46+
"headers": [
47+
"REF",
48+
22
49+
],
50+
"w": 5,
51+
"vals": [
52+
"REF",
53+
18
54+
],
55+
"remBest": 0,
56+
"htmlPage": [
57+
"REF",
58+
20
59+
],
60+
"HtmlFrame": [
61+
"REF",
62+
1
63+
],
64+
"newSolution": 10,
65+
"best": [
66+
"REF",
67+
25
68+
]
69+
},
70+
"heap": {
71+
"1": [
72+
"CLASS",
73+
"HtmlFrame",
74+
[],
75+
[
76+
"__init__",
77+
[
78+
"REF",
79+
2
80+
]
81+
],
82+
[
83+
"makeEofPage",
84+
[
85+
"REF",
86+
3
87+
]
88+
],
89+
[
90+
"makeFrame",
91+
[
92+
"REF",
93+
4
94+
]
95+
]
96+
],
97+
"2": [
98+
"FUNCTION",
99+
"__init__(self, template, banner)",
100+
null
101+
],
102+
"3": [
103+
"FUNCTION",
104+
"makeEofPage(self)",
105+
null
106+
],
107+
"4": [
108+
"FUNCTION",
109+
"makeFrame(self, template)",
110+
null
111+
],
112+
"5": [
113+
"CLASS",
114+
"Matrix",
115+
[],
116+
[
117+
"__getitem__",
118+
[
119+
"REF",
120+
6
121+
]
122+
],
123+
[
124+
"__init__",
125+
[
126+
"REF",
127+
7
128+
]
129+
],
130+
[
131+
"__setitem__",
132+
[
133+
"REF",
134+
8
135+
]
136+
],
137+
[
138+
"__str__",
139+
[
140+
"REF",
141+
9
142+
]
143+
],
144+
[
145+
"getcol",
146+
[
147+
"REF",
148+
10
149+
]
150+
],
151+
[
152+
"getrow",
153+
[
154+
"REF",
155+
11
156+
]
157+
],
158+
[
159+
"populate",
160+
[
161+
"REF",
162+
12
163+
]
164+
],
165+
[
166+
"renderHtml",
167+
[
168+
"REF",
169+
13
170+
]
171+
],
172+
[
173+
"setcolVal",
174+
[
175+
"REF",
176+
14
177+
]
178+
],
179+
[
180+
"setcolVals",
181+
[
182+
"REF",
183+
15
184+
]
185+
],
186+
[
187+
"setrowVal",
188+
[
189+
"REF",
190+
16
191+
]
192+
],
193+
[
194+
"setrowVals",
195+
[
196+
"REF",
197+
17
198+
]
199+
]
200+
],
201+
"6": [
202+
"FUNCTION",
203+
"__getitem__(self, coords)",
204+
null
205+
],
206+
"7": [
207+
"FUNCTION",
208+
"__init__(self, nrows, ncols, data, dftFormat, dftStyle, title, tableAttr, tableHeaders, Expand)",
209+
null
210+
],
211+
"8": [
212+
"FUNCTION",
213+
"__setitem__(self, coords, value)",
214+
null
215+
],
216+
"9": [
217+
"FUNCTION",
218+
"__str__(self)",
219+
null
220+
],
221+
"10": [
222+
"FUNCTION",
223+
"getcol(self, col)",
224+
null
225+
],
226+
"11": [
227+
"FUNCTION",
228+
"getrow(self, row)",
229+
null
230+
],
231+
"12": [
232+
"FUNCTION",
233+
"populate(self, lists)",
234+
null
235+
],
236+
"13": [
237+
"FUNCTION",
238+
"renderHtml(self, wrap)",
239+
null
240+
],
241+
"14": [
242+
"FUNCTION",
243+
"setcolVal(self, col, value)",
244+
null
245+
],
246+
"15": [
247+
"FUNCTION",
248+
"setcolVals(self, col, values)",
249+
null
250+
],
251+
"16": [
252+
"FUNCTION",
253+
"setrowVal(self, row, value)",
254+
null
255+
],
256+
"17": [
257+
"FUNCTION",
258+
"setrowVals(self, row, values)",
259+
null
260+
],
261+
"18": [
262+
"LIST",
263+
0,
264+
10,
265+
40,
266+
30,
267+
50
268+
],
269+
"19": [
270+
"LIST",
271+
0,
272+
5,
273+
4,
274+
6,
275+
3
276+
],
277+
"20": [
278+
"INSTANCE",
279+
"HtmlFrame",
280+
[
281+
"banner",
282+
"Knapsack Problem"
283+
],
284+
[
285+
"item1",
286+
""
287+
],
288+
[
289+
"item2",
290+
""
291+
],
292+
[
293+
"item3",
294+
""
295+
],
296+
[
297+
"outputOn",
298+
true
299+
],
300+
[
301+
"template",
302+
"\n<html><body>\n<h3>%(banner)s</h3>\n<div>%(item1)s</div>\n<div>%(item2)s</div>\n<div>%(item3)s</div>\n</html></body>\n"
303+
]
304+
],
305+
"22": [
306+
"LIST",
307+
"wt0",
308+
"wt1",
309+
"wt2",
310+
"wt3",
311+
"wt4",
312+
"wt5",
313+
"wt6",
314+
"wt7",
315+
"wt8",
316+
"wt9",
317+
"wt10"
318+
],
319+
"23": [
320+
"INSTANCE_PPRINT",
321+
"Matrix",
322+
"Matrix-5x3"
323+
],
324+
"24": [
325+
"INSTANCE_PPRINT",
326+
"Matrix",
327+
"Matrix-1x2"
328+
],
329+
"25": [
330+
"INSTANCE_PPRINT",
331+
"Matrix",
332+
"Matrix-5x11"
333+
]
334+
},
335+
"line": 37,
336+
"event": "exception"
337+
}
338+
]
339+
}

0 commit comments

Comments
 (0)