Skip to content

Commit 84b1b8b

Browse files
committed
add test_max_total_size
1 parent 190e5f9 commit 84b1b8b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/test_bucket.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,16 @@ def test_bucket():
1919
assert dynamic_batched_buckets == [
2020
[10, 5], [7, 8], [1, 2], [4, 3], [6, 9], [20], [1]
2121
]
22+
23+
24+
def test_max_total_size():
25+
examples = [6, 7, 9, 5, 6, 3, 7, 4]
26+
examples = {str(j): i for j, i in enumerate(examples)}
27+
ds = lazy_dataset.new(examples)
28+
29+
dynamic_batched_buckets = list(ds.batch_dynamic_time_series_bucket(
30+
batch_size=3, len_key=lambda x: x, max_padding_rate=0.9, max_total_size=21,
31+
))
32+
assert dynamic_batched_buckets == [
33+
[6, 7, 5], [9, 6], [3, 7, 4]
34+
]

0 commit comments

Comments
 (0)