Skip to content
Snippets Groups Projects
Commit 126e52be authored by tuhe's avatar tuhe
Browse files

Removed pupdb dependency

parent 2a60682b
No related branches found
No related tags found
No related merge requests found
Showing
with 582 additions and 13 deletions
No preview for this file type
File added
File added
File added
File added
{"encoding_scheme": " from unitgrade_private.hidden_gather_upload import dict2picklestring, picklestring2dict;", "questions": "/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4AHyAVFdAEABDnx/coDphHtjJz/Hf6BMJ8jsKcX6D2GlIpCTdQefBtKe4zVRUqE7IM4RD5R3T2C+GesRy0Q5CgrFjodW6xsauaOPVgMwAO1n3axAyU1UhpvS1V4sPs0g7xaNtsCv8oRoe1AhKnl3IFDf6Gg6nXO36ces1MgE7xDz9CSsQ5T2chCmCFLNziwvyXiZKmi6MvcRQ49bpAWpgL4hLMkYc3stfxkRNFCND+MKghupeHwxC4fWNFnP648dKpkQg5xXbkFyD+544w0PH+PJ5pebdXG1+e6LAMSZhOnTHNgUV/SOoiYRLohCowLRTz82ihjKzZH+EqvquWg5r0Yx3Ja1gRz3xz+q4ucPm5sFnELtxqjQdRQYpfjlaDlfNe0GiwzrpgOXv1Vdggdv/bafsYvcXpOkHIRXexotRNAJX9b9f1h2y/P3pMnYlmmzbQXfJYsgvXoAAAAAyhvQuqp9FQ4AAe0C8wMAAPGI2oWxxGf7AgAAAAAEWVo=", "root_dir": "/home/tuhe/Documents/unitgrade_private/devel/example_devel/instructor", "relative_path": "cs108/report_devel.py", "modules": ["cs108", "report_devel"], "token_stub": "cs108/Report2_handin"}
\ No newline at end of file
{"encoding_scheme": " from unitgrade_private.hidden_gather_upload import dict2picklestring, picklestring2dict;", "questions": "/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4ALJAW9dAEABDnncV35phHsyxOZ/WAdcsRcnyJl1OO/vI8mjmhFI6lWS7SfFyihoIfXWjVmlOSPIYt5RtCJvS/3j4bxa5pi+3PPpcnS2VzmHCG1Ro9va9QyFawpcqgSSGVWVFndTK1xzGnFnOEsQAgiJ0VB9ATsnpaY1K5Z1aravch16BLCzLWocn3K1egojbjfRrL6HkB7XP21nDmqPeoHjVZNY6QM2BV9RrnccWViu+u9PVaH/q5YyjX36FQhwsGiMGmIM/LaZzWCyCJt7bbYjq1UXgqmMRrvYwHAXCeoFH1McQxAWLW4P2GU1rZqLMKc/OoQjEvMZdHxWkQBqE2wS4++OffV1YnQ7I0xOljxcxIxhVlPVxUFyj/D04h0CF/ekMP1FxoZsff7QPOLT6apxSDa9jtn1P+u4E9eo30YIdFqZt6hmAmAOyVtNVJxeV+gOFhQOLe8suClVF+MoeXta30NnnqCdXgsjq0/69kvgmi1jackAAPVvsIGknWNrAAGLA8oFAACfhrnvscRn+wIAAAAABFla", "root_dir": "/home/tuhe/Documents/unitgrade_private/devel/example_devel/instructor", "relative_path": "cs108/report_devel.py", "modules": ["cs108", "report_devel"], "token_stub": "cs108/Report2_handin"}
\ No newline at end of file
File added
import numpy as np
def reverse_list(mylist):
"""
Given a list 'mylist' returns a list consisting of the same elements in reverse order. E.g.
......@@ -21,7 +20,6 @@ def add(a,b):
raise NotImplementedError("Implement function body")
return a+b
def foo():
""" Comment. """
# TODO: 1 lines missing.
......@@ -41,7 +39,6 @@ def linear_predict(X, w):
raise NotImplementedError("Implement function body")
return y
if __name__ == "__main__":
print(f"Your result of 2 + 2 = {add(2,2)}")
print(f"Reversing a small list", reverse_list([2,3,5,7]))
......@@ -2,32 +2,111 @@ from unitgrade.framework import Report
from unitgrade.evaluate import evaluate_report_student
from cs108.homework1 import add, reverse_list, linear_regression_weights, linear_predict, foo
from unitgrade import UTestCase, cache
from unitgrade.framework import classmethod_dashboard
import time
import numpy as np
import pickle
import os
# from unitgrade.framework import dash
def mk_bad():
with open(os.path.dirname(__file__)+"/db.pkl", 'wb') as f:
d = {'x1': 100, 'x2': 300}
pickle.dump(d, f)
def mk_ok():
with open(os.path.dirname(__file__)+"/db.pkl", 'wb') as f:
d = {'x1': 1, 'x2': 2}
pickle.dump(d, f)
class Numpy(UTestCase):
z = 234
# def __getattr__(self, item):
# print("hi there ", item)
# return super().__getattr__(item)
#
# def __getattribute__(self, item):
# print("oh hello sexy. ", item)
# return super().__getattribute__(item)
@classmethod_dashboard
def setUpClass(cls) -> None:
print("Dum di dai, I am running some setup code here.")
for i in range(10):
print("Hello world", i)
print("Set up.") # must be handled seperately.
# assert False
# @cache
# def make_primes(self, n):
# return primes(n)
def test_bad(self):
"""
Hints:
* Remember to properly de-indent your code.
* Do more stuff which works.
"""
# raise Exception("This ended poorly")
# print("Here we go")
# return
# self.assertEqual(1, 1)
with open(os.path.dirname(__file__)+"/db.pkl", 'rb') as f:
d = pickle.load(f)
# print(d)
# assert False
# for i in range(10):
from tqdm import tqdm
for i in tqdm(range(100)):
# print("The current number is", i)
time.sleep(.01)
self.assertEqual(1, d['x1'])
for b in range(10):
self.assertEqualC(add(3, b))
def test_weights(self):
"""
Hints:
* Try harder!
* Check the chapter on linear regression.
"""
n = 3
m = 2
np.random.seed(5)
X = np.random.randn(n, m)
y = np.random.randn(n)
# from numpy import asdfaskdfj
# X = np.random.randn(n, m)
# y = np.random.randn(n)
foo()
self.assertL2(linear_regression_weights(X, y), msg="the message")
# assert 2 == 3
# raise Exception("Bad exit")
# self.assertEqual(2, np.random.randint(1000))
# self.assertEqual(2, np.random.randint(1000))
# self.assertL2(linear_regression_weights(X, y), msg="the message")
self.assertEqual(1, 1)
# self.assertEqual(1,2)
return "THE RESULT OF THE TEST"
class AnotherTest(UTestCase):
def test_more(self):
self.assertEqual(2,2)
def test_even_more(self):
self.assertEqual(2,2)
import cs108
class Report2(Report):
title = "CS 101 Report 2"
questions = [
(Numpy, 10),
(Numpy, 10), (AnotherTest, 20)
]
pack_imports = [cs108]
if __name__ == "__main__":
evaluate_report_student(Report2())
# import texttestrunner
import unittest
unittest.main()
# evaluate_report_student(Report2())
This diff is collapsed.
File added
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment