Skip to content

[utils] Return exactly num_colors colors from get_colors - #2190

Merged
felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:get-colors-exact-count
Oct 30, 2026
Merged

felixdittrich92 merged 1 commit into
mindee:mainfrom
RavSinghChandan:get-colors-exact-count

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

get_colors stepped through the hues with np.arange(0.0, 360.0, 360.0 / num_colors). A float step can include one more value, close to 360°, so get_colors(161) returned 162 colors (the last one is red again, like the first), and get_colors(0) raised ZeroDivisionError. The layout views work around the zero case with max(len(region_classes), 1), but visualize_kie_page does not, so a KIE page without any prediction class failed to render.

The hues now come from an integer range (i / num_colors), which gives exactly num_colors colors, and none for 0. For other counts the hues are the same as before

@felixdittrich92 felixdittrich92 self-assigned this Oct 29, 2026
@felixdittrich92 felixdittrich92 added this to the 1.2.0 milestone Oct 29, 2026
@felixdittrich92 felixdittrich92 added type: bug Something isn't working module: utils Related to doctr.utils ext: tests Related to tests folder labels Oct 29, 2026

@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 @RavSinghChandan 👍

@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 (fe09ef9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2190   +/-   ##
=======================================
  Coverage   97.75%   97.75%           
=======================================
  Files         170      170           
  Lines       10959    10959           
=======================================
  Hits        10713    10713           
  Misses        246      246           
Flag Coverage Δ
unittests 97.75% <100.00%> (ø)

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 merged commit 5244593 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: utils Related to doctr.utils type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants