code.main
1import Utils 2import Sym 3import Num 4import Data 5 6def bad(): 7 print("-" * 50) 8 print("!!!!!! CRASH BAD false\n") 9 assert True 10 11def lists(): 12 print("-" * 50) 13 print("!!!!!! FAIL LIST true\n") 14 assert True 15 16def ls(): 17 eg = ['BAD', 'ALL', 'LIST', 'bignum', 'csv', 'data', 'num', 'stats', 'the', 'sym'] 18 print("-" * 50) 19 print("\nExamples of pytest test_lua.py -v...") 20 for i in range(len(eg)): 21 print(f' {eg[i]}\t') 22 print("!!!!!! PASS LS true\n\n") 23 assert True 24 25def test_the(): 26 print("-" * 50) 27 Utils.oo(Utils.the) 28 print("!!!!!! PASS the true\n!!!!!! PASS ALL true\n\n") 29 return True 30 31def test_sym(): 32 sym = Sym.Sym() 33 for x in ["a", "a", "a", "a", "b", "b", "c"]: 34 sym.add(x) 35 mode, entropy = sym.mid(), sym.div() 36 entropy = (1000 * entropy) // 1 / 1000 37 print("-" * 50) 38 Utils.oo({"mid": mode, "div": entropy}) 39 print("!!!!!! PASS sym true\n\n") 40 return mode == "a" and 1.37 <= entropy and entropy <= 1.38 41 42def test_num(): 43 num = Num.Num() 44 Utils.the['nums'] = 101 45 for i in range(1, 100): 46 num.add(i) 47 mid, div = num.mid(), num.div() 48 print("-" * 50) 49 print(mid, div) 50 print("!!!!!! PASS num true\n\n") 51 return 50 <= mid and mid <= 52 and 30.5 < div and div < 32 52 53def test_bignum(): 54 num = Num.Num() 55 Utils.the['nums'] = 32 56 for i in range(1, 1000): 57 num.add(i) 58 res = dict(sorted(num.nums().items(), key=lambda item: item[1])) 59 t = list(res.values()) 60 out = "{" 61 for i in range(len(t)): 62 out += " " + str(t[i]) 63 print("-" * 50) 64 print(out, "}") 65 print("!!!!!! PASS bignum true\n\n") 66 return 32 == len(num._has) 67 68def test_data(): 69 d = Data.Data("./data/source.csv") 70 print("-" * 50) 71 for y in d.cols.y: 72 Utils.oo(y) 73 print("!!!!!! PASS data true\n\n") 74 return True 75 76def test_stats(): 77 data = Data.Data("./data/source.csv") 78 def div(col): 79 return col.div() 80 81 def mid(col): 82 return col.mid() 83 84 print("-" * 50) 85 print('xmid=', Utils.o(data.stats(2, data.cols.x, mid))) 86 print('xdiv=', Utils.o(data.stats(3, data.cols.x, div))) 87 print('ymid=', Utils.o(data.stats(2, data.cols.y, mid))) 88 print('ymid=', Utils.o(data.stats(3, data.cols.y, div))) 89 print("!!!!!! PASS stats true\n\n") 90 return True 91 92def test_csv(): 93 global n 94 n=0 95 96 def function_row(r): 97 global n 98 n+=1 99 return n if n>10 else Utils.oo(r) 100 print("-" * 50) 101 Utils.parse_csv("./data/source.csv", function_row) 102 print("!!!!!! PASS csv true\n\n") 103 return True 104 105bad() 106lists() 107ls() 108test_bignum() 109test_csv() 110test_data() 111test_num() 112test_stats() 113test_sym() 114test_the()
def
bad():
def
lists():
def
ls():
def
test_the():
def
test_sym():
32def test_sym(): 33 sym = Sym.Sym() 34 for x in ["a", "a", "a", "a", "b", "b", "c"]: 35 sym.add(x) 36 mode, entropy = sym.mid(), sym.div() 37 entropy = (1000 * entropy) // 1 / 1000 38 print("-" * 50) 39 Utils.oo({"mid": mode, "div": entropy}) 40 print("!!!!!! PASS sym true\n\n") 41 return mode == "a" and 1.37 <= entropy and entropy <= 1.38
def
test_num():
def
test_bignum():
54def test_bignum(): 55 num = Num.Num() 56 Utils.the['nums'] = 32 57 for i in range(1, 1000): 58 num.add(i) 59 res = dict(sorted(num.nums().items(), key=lambda item: item[1])) 60 t = list(res.values()) 61 out = "{" 62 for i in range(len(t)): 63 out += " " + str(t[i]) 64 print("-" * 50) 65 print(out, "}") 66 print("!!!!!! PASS bignum true\n\n") 67 return 32 == len(num._has)
def
test_data():
def
test_stats():
77def test_stats(): 78 data = Data.Data("./data/source.csv") 79 def div(col): 80 return col.div() 81 82 def mid(col): 83 return col.mid() 84 85 print("-" * 50) 86 print('xmid=', Utils.o(data.stats(2, data.cols.x, mid))) 87 print('xdiv=', Utils.o(data.stats(3, data.cols.x, div))) 88 print('ymid=', Utils.o(data.stats(2, data.cols.y, mid))) 89 print('ymid=', Utils.o(data.stats(3, data.cols.y, div))) 90 print("!!!!!! PASS stats true\n\n") 91 return True
def
test_csv():