aboutsummaryrefslogtreecommitdiff
path: root/gn3/utility/chunks.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/utility/chunks.py')
-rw-r--r--gn3/utility/chunks.py32
1 files changed, 0 insertions, 32 deletions
diff --git a/gn3/utility/chunks.py b/gn3/utility/chunks.py
deleted file mode 100644
index fa27a39..0000000
--- a/gn3/utility/chunks.py
+++ /dev/null
@@ -1,32 +0,0 @@
-"""module for chunks functions"""
-
-import math
-
-
-def divide_into_chunks(the_list, number_chunks):
- """Divides a list into approximately number_chunks smaller lists
-
- >>> divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 3)
- [[1, 2, 7], [3, 22, 8], [5, 22, 333]]
- >>> divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 4)
- [[1, 2, 7], [3, 22, 8], [5, 22, 333]]
- >>> divide_into_chunks([1, 2, 7, 3, 22, 8, 5, 22, 333], 5)
- [[1, 2], [7, 3], [22, 8], [5, 22], [333]]
- >>>
-
- """
- length = len(the_list)
-
- if length == 0:
- return [[]]
-
- if length <= number_chunks:
- number_chunks = length
-
- chunksize = int(math.ceil(length / number_chunks))
-
- chunks = []
- for counter in range(0, length, chunksize):
- chunks.append(the_list[counter:counter+chunksize])
-
- return chunks