Last active
December 6, 2017 00:25
-
-
Save ramsesoriginal/5a906eed9bf1f312066279ca86710eff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
def debugPrint(n, R, expected): | |
start_time = timeit.default_timer() | |
result = ist_aequivalenzrelation(n, R) | |
elapsed = timeit.default_timer() - start_time | |
if result != expected or elapsed > 1.5: | |
rstring = str(R) | |
if len(rstring) > 100: | |
rstring = rstring[:100] + "...]" | |
print("ist_aequivalenzrelation(" + str(n) + ", " + rstring + ")") | |
print("expected: " + str(expected) + ", got: " + str(result)) | |
print("runtime: " + str(elapsed) + " seconds ") | |
print("") | |
def debugTests(): | |
debugPrint(0, [], True) | |
debugPrint(1, [(1, 1)], True) | |
debugPrint(1, [(1, 1), (2, 2)], False) # (2,2) > n | |
debugPrint(1, [(0, 0), (1, 1)], False) # (0, 0) < 1 | |
debugPrint(1, [(2, 2)], False) #nicht reflexiv bei (1, 1) | |
debugPrint(4, [(1, 1), (2, 2), (3, 3), (4, 4)], True) | |
debugPrint(3, [(2, 2), (1, 1), (3, 3), (1, 2), (2, 1), (2, 3), (3, 2)], False) #nicht transitiv bei (1, 3) | |
debugPrint(2, [(1, 1), (2, 2), (1, 2), (2, 1), (1, 1), (2, 2)], True) | |
debugPrint(3, [(2, 2), (1, 1), (3, 3), (1, 2), (2, 1), (2, 3), (3, 2), (1, 3)], False) #nicht symmetrisch bei (1, 3) | |
debugPrint(3, [(2, 2), (1, 1), (3, 3), (1, 2), (2, 1), (2, 3), (3, 2), (1, 3), (3, 1)], True) | |
debugPrint(3, [(2, 2), (1, 1), (3, 3), (4, 4), (1, 2), (2, 1), (2, 3), (3, 2), (1, 3), (3, 1)], False) # (4, 4) > n | |
debugPrint(20**4, list(map(lambda x: (x, x), range(1, (20**4) + 1))), True) | |
longtest = [] | |
longtest2 = [] | |
for i in range(0, 10**3 + 1): | |
longtest.append((i, i)) | |
if i > 0 and i <= 13**2: | |
longtest2.append((i, i)) | |
for j in range(0, 11**3 + 1): | |
longtest.append((i, j)) | |
if i > 0 and i <= 13**2 and j > 0 and j <= 13**2: | |
longtest2.append((i, j)) | |
debugPrint(13**2, longtest, False) # longtest > n | |
debugPrint(13**2, longtest2, True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment