Tests for all functions

This commit is contained in:
Kyle Swanson
2018-02-03 08:36:25 -05:00
parent 90ad4b30d0
commit ed7232d54e
2 changed files with 161 additions and 11 deletions
+3 -3
View File
@@ -154,14 +154,14 @@ def _sequential(function, *arrays, **kwargs):
def t_imap(function, *arrays, **kwargs):
"""Returns an iterator for a sequential map with a progress bar."""
iterator = sequential(function, *arrays, **kwargs)
iterator = _sequential(function, *arrays, **kwargs)
return iterator
def t_map(function, *arrays, **kwargs):
"""Performs a sequential map with a progress bar."""
iterator = sequential(function, *arrays, **kwargs)
result = list(iteratorZ)
iterator = _sequential(function, *arrays, **kwargs)
result = list(iterator)
return result
+158 -8
View File
@@ -20,7 +20,10 @@ def _test_one_list(self):
result = list(result)
correct_array = [2, 3, 4]
self.assertEqual(correct_array, result)
if self.ordered:
self.assertListEqual(correct_array, result)
else:
self.assertListEqual(sorted(correct_array), sorted(result))
def _test_two_lists(self):
array_1 = [1, 2, 3]
@@ -30,7 +33,10 @@ def _test_two_lists(self):
result = list(result)
correct_array = [11, 13, 15]
self.assertEqual(correct_array, result)
if self.ordered:
self.assertListEqual(correct_array, result)
else:
self.assertListEqual(sorted(correct_array), sorted(result))
def _test_two_lists_and_one_single(self):
array_1 = [1, 2, 3]
@@ -41,7 +47,10 @@ def _test_two_lists_and_one_single(self):
result = list(result)
correct_array = [16, 18, 20]
self.assertEqual(correct_array, result)
if self.ordered:
self.assertListEqual(correct_array, result)
else:
self.assertListEqual(sorted(correct_array), sorted(result))
def _test_one_list_and_two_singles(self):
array = [1, 2, 3]
@@ -52,7 +61,10 @@ def _test_one_list_and_two_singles(self):
result = list(result)
correct_array = [4, 5, 6]
self.assertEqual(correct_array, result)
if self.ordered:
self.assertListEqual(correct_array, result)
else:
self.assertListEqual(sorted(correct_array), sorted(result))
def _test_one_single(self):
single = 5
@@ -61,7 +73,10 @@ def _test_one_single(self):
result = list(result)
correct_array = [6]
self.assertEqual(correct_array, result)
if self.ordered:
self.assertListEqual(correct_array, result)
else:
self.assertListEqual(sorted(correct_array), sorted(result))
def _test_one_single_with_num_iter(self):
single = 5
@@ -71,7 +86,10 @@ def _test_one_single_with_num_iter(self):
result = list(result)
correct_array = [6]*num_iter
self.assertEqual(correct_array, result)
if self.ordered:
self.assertListEqual(correct_array, result)
else:
self.assertListEqual(sorted(correct_array), sorted(result))
def _test_two_singles(self):
single_1 = 5
@@ -81,7 +99,10 @@ def _test_two_singles(self):
result = list(result)
correct_array = [3]
self.assertEqual(correct_array, result)
if self.ordered:
self.assertListEqual(correct_array, result)
else:
self.assertListEqual(sorted(correct_array), sorted(result))
def _test_two_singles_with_num_iter(self):
single_1 = 5
@@ -92,13 +113,17 @@ def _test_two_singles_with_num_iter(self):
result = list(result)
correct_array = [3]*num_iter
self.assertEqual(correct_array, result)
if self.ordered:
self.assertListEqual(correct_array, result)
else:
self.assertListEqual(sorted(correct_array), sorted(result))
class Testp_imap(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(Testp_imap, self).__init__(*args, **kwargs)
self.func = p_tqdm.p_imap
self.generator = True
self.ordered = True
def test_one_list(self):
_test_one_list(self)
@@ -129,6 +154,131 @@ class Testp_map(unittest.TestCase):
super(Testp_map, self).__init__(*args, **kwargs)
self.func = p_tqdm.p_map
self.generator = False
self.ordered = True
def test_one_list(self):
_test_one_list(self)
def test_two_lists(self):
_test_two_lists(self)
def test_two_lists_and_one_single(self):
_test_two_lists_and_one_single(self)
def test_one_list_and_two_singles(self):
_test_one_list_and_two_singles(self)
def test_one_single(self):
_test_one_single(self)
def test_one_single_with_num_iter(self):
_test_one_single_with_num_iter(self)
def test_two_singles(self):
_test_two_singles(self)
def test_two_singles_with_num_iter(self):
_test_two_singles_with_num_iter(self)
class Testp_uimap(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(Testp_uimap, self).__init__(*args, **kwargs)
self.func = p_tqdm.p_uimap
self.generator = True
self.ordered = False
def test_one_list(self):
_test_one_list(self)
def test_two_lists(self):
_test_two_lists(self)
def test_two_lists_and_one_single(self):
_test_two_lists_and_one_single(self)
def test_one_list_and_two_singles(self):
_test_one_list_and_two_singles(self)
def test_one_single(self):
_test_one_single(self)
def test_one_single_with_num_iter(self):
_test_one_single_with_num_iter(self)
def test_two_singles(self):
_test_two_singles(self)
def test_two_singles_with_num_iter(self):
_test_two_singles_with_num_iter(self)
class Testp_umap(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(Testp_umap, self).__init__(*args, **kwargs)
self.func = p_tqdm.p_umap
self.generator = False
self.ordered = False
def test_one_list(self):
_test_one_list(self)
def test_two_lists(self):
_test_two_lists(self)
def test_two_lists_and_one_single(self):
_test_two_lists_and_one_single(self)
def test_one_list_and_two_singles(self):
_test_one_list_and_two_singles(self)
def test_one_single(self):
_test_one_single(self)
def test_one_single_with_num_iter(self):
_test_one_single_with_num_iter(self)
def test_two_singles(self):
_test_two_singles(self)
def test_two_singles_with_num_iter(self):
_test_two_singles_with_num_iter(self)
class Testt_imap(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(Testt_imap, self).__init__(*args, **kwargs)
self.func = p_tqdm.t_imap
self.generator = True
self.ordered = True
def test_one_list(self):
_test_one_list(self)
def test_two_lists(self):
_test_two_lists(self)
def test_two_lists_and_one_single(self):
_test_two_lists_and_one_single(self)
def test_one_list_and_two_singles(self):
_test_one_list_and_two_singles(self)
def test_one_single(self):
_test_one_single(self)
def test_one_single_with_num_iter(self):
_test_one_single_with_num_iter(self)
def test_two_singles(self):
_test_two_singles(self)
def test_two_singles_with_num_iter(self):
_test_two_singles_with_num_iter(self)
class Testt_map(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(Testt_map, self).__init__(*args, **kwargs)
self.func = p_tqdm.t_map
self.generator = False
self.ordered = True
def test_one_list(self):
_test_one_list(self)