Skip to content

[datasets] Encode an empty batch of sequences in encode_sequences - #2210

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:encode-sequences-empty-batch
Nov 2, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:encode-sequences-empty-batch

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

Without a target_size (or with dynamic_seq_length=True), encode_sequences computes the length from
max(len(w) for w in sequences), which raises "max() iterable argument is empty" for an empty list. With a fixed
target_size an empty list already gives an empty (0, target_size) array. It now gives an empty (0, 1) array in
the other case too, instead of crashing. Two cases added to the existing parametrized test.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.75%. Comparing base (c828139) to head (d7134e7).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2210      +/-   ##
==========================================
- Coverage   97.76%   97.75%   -0.02%     
==========================================
  Files         170      170              
  Lines       10982    10986       +4     
==========================================
+ Hits        10737    10739       +2     
- Misses        245      247       +2     
Flag Coverage Δ
unittests 97.75% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@felixdittrich92 felixdittrich92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍🏼

@felixdittrich92 felixdittrich92 self-assigned this Oct 31, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Oct 31, 2026
@felixdittrich92 felixdittrich92 added type: enhancement Improvement ext: tests Related to tests folder module: datasets Related to doctr.datasets labels Nov 2, 2026
@felixdittrich92
felixdittrich92 merged commit b66fc9c into mindee:main Nov 2, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext: tests Related to tests folder module: datasets Related to doctr.datasets type: enhancement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants