From 09565ddacdddfa82f450ce62865b7a2c0a90b173 Mon Sep 17 00:00:00 2001 From: jirka <6035284+Borda@users.noreply.github.com> Date: Mon, 2 Feb 2026 08:34:27 +0100 Subject: [PATCH] Convert `supervision/detection/tools/csv_sink.py` docstrings to doctests --- Co-authored-by: copilot-swe-agent[bot] <198982749+copilot@users.noreply.github.com> --- supervision/detection/tools/csv_sink.py | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/supervision/detection/tools/csv_sink.py b/supervision/detection/tools/csv_sink.py index 5a899fee..8431486c 100644 --- a/supervision/detection/tools/csv_sink.py +++ b/supervision/detection/tools/csv_sink.py @@ -34,20 +34,23 @@ class CSVSink: Defaults to 'output.csv'. Example: - ```python - import supervision as sv - from ultralytics import YOLO - - model = YOLO() - csv_sink = sv.CSVSink() - frames_generator = sv.get_video_frames_generator() - - with csv_sink as sink: - for frame in frames_generator: - result = model(frame)[0] - detections = sv.Detections.from_ultralytics(result) - sink.append(detections, custom_data={'':''}) - ``` + >>> import supervision as sv + >>> import numpy as np + >>> import tempfile + >>> import os + >>> # Create synthetic detections + >>> detections = sv.Detections( + ... xyxy=np.array([[10, 20, 30, 40], [50, 60, 70, 80]]), + ... confidence=np.array([0.9, 0.8]), + ... class_id=np.array([0, 1]) + ... ) + >>> # Use temporary file + >>> temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.csv', delete=False) + >>> temp_file.close() + >>> csv_sink = sv.CSVSink(temp_file.name) + >>> with csv_sink as sink: + ... sink.append(detections, custom_data={'frame': 0}) + >>> os.unlink(temp_file.name) # Clean up """ def __init__(self, file_name: str = "output.csv") -> None: