Fix spacy.util.minibatch when the size iterator is finished (#6745)

This commit is contained in:
Santiago Castro 2021-01-17 08:48:43 -03:00 committed by GitHub
parent e649242927
commit 28256522c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -513,7 +513,7 @@ def minibatch(items, size=8):
size_ = size
items = iter(items)
while True:
batch_size = next(size_)
batch_size = next(size_, 0) # StopIteration isn't handled in generators in Python >= 3.7.
batch = list(itertools.islice(items, int(batch_size)))
if len(batch) == 0:
break