Skip to content

docs: convert fenced examples to doctests in dataset/formats/createml.py - #2475

Merged
Borda merged 1 commit into
roboflow:developfrom
Swapnil-gautam:docs/createml-doctests
Aug 7, 2026
Merged

docs: convert fenced examples to doctests in dataset/formats/createml.py#2475
Borda merged 1 commit into
roboflow:developfrom
Swapnil-gautam:docs/createml-doctests

Conversation

@Swapnil-gautam

Copy link
Copy Markdown
Contributor
Before submitting
  • Self-reviewed the code
  • Updated documentation, follow Google-style
  • All tests pass locally

Description

Converts the 2 runnable fenced ```python examples in dataset/formats/createml.py to pycon doctest format so they are executed and verified by pytest --doctest-modules. Follow-up to #2474 (same conversion for dataset/formats/coco.py) and #2451 (draw/utils.py).

The save_createml_annotations example is intentionally left as a fenced block — it writes a file to disk, which CONTRIBUTING.md §Doctests lists as a case where fenced blocks are appropriate.

Type of Change

  • 📝 Documentation update

Motivation and Context

Fenced examples are rendered in the docs but never executed, so they can silently drift from real behaviour. Both converted examples use only supervision and NumPy, so per the contributing guidelines they should be doctests.

Changes Made

  • createml_annotations_to_detections: fenced example → doctest; verified output now also asserts class_id, covering the label→id mapping half of the function's contract alongside the centre→corner box conversion. Removed an import supervision as sv that the example never used.
  • detections_to_createml_annotations: fenced example → doctest with the full coordinates dict as verified output (round-trip of the example above).
  • Normalised Examples:Example: for Google-style consistency.

Testing

  • I have tested this code locally
  • All new and existing tests pass

uv run pytest --doctest-modules src/supervision/dataset/formats/createml.py — 2 passed.
Full suite: 3565 passed, 20 skipped (+2 doctests, no regressions). pre-commit run — all hooks pass, including check doctest fences.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88%. Comparing base (fb22686) to head (d6d4a24).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2475   +/-   ##
=======================================
- Coverage       88%     88%   -0%     
=======================================
  Files           85      85           
  Lines        12042   12042           
=======================================
- Hits         10543   10540    -3     
- Misses        1499    1502    +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates src/supervision/dataset/formats/createml.py docstrings to convert runnable fenced python examples into pycon-style doctests so they are executed under the repository’s pytest --doctest-modules configuration, reducing documentation drift.

Changes:

  • Converted the createml_annotations_to_detections docstring example from a fenced python snippet to a pycon doctest and added an explicit assertion of class_id.
  • Converted the detections_to_createml_annotations docstring example to a pycon doctest with verified structured output.
  • Normalized docstring section heading from Examples: to Example: (including keeping save_createml_annotations as a fenced block due to filesystem writes).

@Borda
Borda merged commit 7d325d2 into roboflow:develop Aug 7, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants