aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/chunks.py
diff options
context:
space:
mode:
authorArthur Centeno2021-04-09 20:38:21 +0000
committerArthur Centeno2021-04-09 20:38:21 +0000
commite2b04a322f26670782fe7f7c39bcebc508fdabdd (patch)
treea51c32bae4d544cc0beea19f455ccc52f0544a4c /wqflask/utility/chunks.py
parent187cd40bd3273b50d2813bfccf98bfadbb8c14ff (diff)
parentef51e08753defdfc7f3e67f8788cd1362d2cf631 (diff)
downloadgenenetwork2-e2b04a322f26670782fe7f7c39bcebc508fdabdd.tar.gz
Merge branch 'testing' of github.com:genenetwork/genenetwork2 into acenteno
Diffstat (limited to 'wqflask/utility/chunks.py')
-rw-r--r--wqflask/utility/chunks.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/wqflask/utility/chunks.py b/wqflask/utility/chunks.py
index b0e33c08..9a7db102 100644
--- a/wqflask/utility/chunks.py
+++ b/wqflask/utility/chunks.py
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, print_function, division
-
import math
import time
@@ -31,66 +29,3 @@ def divide_into_chunks(the_list, number_chunks):
chunks.append(the_list[counter:counter+chunksize])
return chunks
-
-def _confirm_chunk(original, result):
- all_chunked = []
- for chunk in result:
- all_chunked.extend(chunk)
- print("length of all chunked:", len(all_chunked))
- assert original == all_chunked, "You didn't chunk right"
-
-
-def _chunk_test(divide_func):
- import random
- random.seed(7)
-
- number_exact = 0
- total_amount_off = 0
-
- for test in range(1, 1001):
- print("\n\ntest:", test)
- number_chunks = random.randint(1, 20)
- number_elements = random.randint(0, 100)
- the_list = list(range(1, number_elements))
- result = divide_func(the_list, number_chunks)
-
- print("Dividing list of length {} into approximately {} chunks - got {} chunks".format(
- len(the_list), number_chunks, len(result)))
- print("result:", result)
-
- _confirm_chunk(the_list, result)
-
- amount_off = abs(number_chunks - len(result))
- if amount_off == 0:
- number_exact += 1
- else:
- total_amount_off += amount_off
-
-
- print("\n{} exact out of {} [Total amount off: {}]".format(number_exact,
- test,
- total_amount_off))
- assert number_exact == 558
- assert total_amount_off == 1580
- return number_exact, total_amount_off
-
-
-def _main():
- info = dict()
- #funcs = (("sam", sam_divide_into_chunks), ("zach", zach_divide_into_chunks))
- funcs = (("only one", divide_into_chunks),)
- for name, func in funcs:
- start = time.time()
- number_exact, total_amount_off = _chunk_test(func)
- took = time.time() - start
- info[name] = dict(number_exact=number_exact,
- total_amount_off=total_amount_off,
- took=took)
-
- print("info is:", info)
-
-if __name__ == '__main__':
- _main()
- print("\nConfirming doctests...")
- import doctest
- doctest.testmod()