def test_same_element(self): arr = [1000000 for i in range(100000)] res = lab6.radix_sort(arr) subject = 0 for x in range (100000): if res[x] >= subject: subject = res[x] else: subject = -1 break self.assertTrue(subject != -1)
def test_not_trivial(self): arr = [randint(0, 100000) for i in range(100000)] res = lab6.radix_sort(arr) subject = 0 for x in range (100000): if res[x] >= subject: subject = res[x] else: subject = -1 break self.assertTrue(subject != -1)
def test_consecutive_integers(self): arr = [i for i in range(100000)] res = lab6.radix_sort(arr) subject = 0 for x in range (100000): if res[x] >= subject: subject = res[x] else: subject = -1 break self.assertTrue(subject != -1)
import sys __author__ = 'alexkane' sys.path.insert(0, '/home/alexkane/PyRepository/lab4/Sadovnikov') sys.path.insert(0, '/home/alexkane/PyRepository/lab5/Sadovnikov') sys.path.insert(0, '/home/alexkane/PyRepository/lab6/Sadovnikov') import matplotlib.pyplot as plt import lab4 import lab5 import lab6 funcs = 4 * [None] funcs[0] = lambda x: x.sort() funcs[1] = lambda x: lab4.sort(x) funcs[2] = lambda x: lab5.quick_sort(x, 0, len(x) - 1) funcs[3] = lambda x: lab6.radix_sort(x) array_of_names = 4 * [None] array_of_names[0] = "Basic" array_of_names[1] = "Merge/insert" array_of_names[2] = "Quick" array_of_names[3] = "Radix" def universal_plot(fig, ax, term): xrng = xrange(100, 1000000, 100000) t = 0 for func in funcs: array_of_medians = 10 * [None] m = 0 for k in xrng:
def test_trivial(self): arr = [1, 333, 22] res = lab6.radix_sort(arr) expected = [1, 22, 333] self.assertEqual(expected, res)
def test_negative_element(self): arr = [-1, -333, -22] res = lab6.radix_sort(arr) expected = [-333, -22, -1] self.assertEqual(expected, res)
def test_empty(self): arr = [] res = lab6.radix_sort(arr) expected = [] self.assertEqual(expected, res)