Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 9a27d8d

Browse files
authored
Fix get_chunks for zeros (#624)
1 parent 69c950f commit 9a27d8d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sdc/tests/test_prange_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def _get_chunks_data(self):
6868
Chunk(start=3, stop=6),
6969
Chunk(start=6, stop=9),
7070
]
71+
yield (0, 5), []
72+
yield (5, 0), []
7173

7274
def _check_get_chunks(self, args, expected_chunks):
7375
pyfunc = get_chunks

sdc/utilities/prange_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ def get_pool_size():
4747

4848
@sdc_register_jitable
4949
def get_chunks(size, pool_size):
50+
chunks = []
51+
52+
if size < 1 or pool_size < 1:
53+
return chunks
54+
5055
pool_size = min(pool_size, size)
5156
chunk_size = size // pool_size
5257
overload_size = size % pool_size
5358

54-
chunks = []
5559
for i in range(pool_size):
5660
start = i * chunk_size + min(i, overload_size)
5761
stop = (i + 1) * chunk_size + min(i + 1, overload_size)

0 commit comments

Comments
 (0)