Skip to content

[datasets] Reject negative indices in decode_sequence - #2189

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:decode-sequence-negative-index
Oct 30, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:decode-sequence-negative-index

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

decode_sequence rejected an index at or above the mapping size, but a negative one was read from the end of the mapping. The default EOS of encode_sequences is -1, so decode_sequence(encode_sequences(["ab"], "abc")[0], "abc") returned "abc": the EOS came back as the last char of the vocab, with no error. Lists were not checked at all, so [2, 10] raised a bare IndexError.

Negative indices now raise the same AssertionError as the indices that are too large, for arrays and lists. The recognition post-processors pass non-negative argmax indices, so they are not affected (the post-processor tests pass)

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.75%. Comparing base (9ae237d) to head (21ff071).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2189   +/-   ##
=======================================
  Coverage   97.75%   97.75%           
=======================================
  Files         170      170           
  Lines       10959    10961    +2     
=======================================
+ Hits        10713    10715    +2     
  Misses        246      246           
Flag Coverage Δ
unittests 97.75% <100.00%> (+<0.01%) ⬆️

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 30, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Oct 30, 2026
@felixdittrich92 felixdittrich92 added type: enhancement Improvement ext: tests Related to tests folder topic: text recognition Related to the task of text recognition module: datasets Related to doctr.datasets labels Oct 30, 2026
@felixdittrich92
felixdittrich92 merged commit 9468c85 into mindee:main Oct 30, 2026
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 topic: text recognition Related to the task of text recognition type: enhancement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants