Skip to content

Commit 02071ec

Browse files
committed
Fixed Dataset.subset when buffer_size is None
1 parent 109f9b6 commit 02071ec

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

neuralmonkey/dataset.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,6 @@ def subset(self, start: int, length: int) -> "Dataset":
602602
start, start + length)
603603
for s_id in self.iterators}
604604

605-
# Workaround since self.buffer_size and self.buffer_min_size
606-
# may not be initialized
607-
buffer_size = None
608-
if hasattr(self, "buffer_min_size") and hasattr(self, "buffer_size"):
609-
buffer_size = (self.buffer_min_size, self.buffer_size)
610-
611605
# Here, the type: ignore is because of the tied argument to the lambda
612606
# function above, which made it Callable[[Any], ...] instead of just
613607
# Callable[[], ...].
@@ -616,5 +610,6 @@ def subset(self, start: int, length: int) -> "Dataset":
616610
iterators=slices,
617611
batching=self.batching,
618612
outputs=outputs,
619-
buffer_size=buffer_size,
613+
buffer_size=((self.buffer_min_size, self.buffer_size)
614+
if self.lazy else None),
620615
shuffled=self.shuffled)

0 commit comments

Comments
 (0)