fix chunked_shuffle crash with empty list

This commit is contained in:
Damian Stewart 2023-06-14 09:44:37 +02:00
parent ded73f088f
commit 403f7ddf07
1 changed files with 2 additions and 0 deletions

View File

@ -253,6 +253,8 @@ def chunked_shuffle(l: List, chunk_size: int, randomizer: random.Random) -> List
Shuffles l in chunks, preserving the chunk boundaries and the order of items within each chunk. Shuffles l in chunks, preserving the chunk boundaries and the order of items within each chunk.
If the last chunk is incomplete, it is not shuffled (i.e. preserved as the last chunk) If the last chunk is incomplete, it is not shuffled (i.e. preserved as the last chunk)
""" """
if len(l) == 0:
return []
# chunk by effective batch size # chunk by effective batch size
chunks = chunk(l, chunk_size) chunks = chunk(l, chunk_size)