- Remove unused compatibility operations and use focused Pillow and NumPy paths to reduce maintained fallback code. - Preserve numerical decisions and hot-path performance with exact regression coverage and bounded algorithms. - Preserve INTER_LINEAR uint8 reductions within one LSB while retaining the resize performance budget and numeric RGBA handling. - Restore repeated-endpoint contour anchors and bound cross-platform chamfer coefficient drift in regression tests. --------- Co-authored-by: Codex <codex@openai.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
28 lines
705 B
Python
28 lines
705 B
Python
"""Tests for private transform and filter fallbacks."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
from supervision._cv2._transform import _blur
|
|
|
|
try:
|
|
cv2 = importlib.import_module("cv2")
|
|
except (ImportError, OSError):
|
|
pytest.skip(
|
|
"OpenCV is required as the reference implementation for this test module",
|
|
allow_module_level=True,
|
|
)
|
|
|
|
|
|
def test_fallback_blur_preserves_shape_and_dtype() -> None:
|
|
"""Preserve source shape and dtype during blurring."""
|
|
source = np.arange(25, dtype=np.uint8).reshape(5, 5)
|
|
blurred = _blur(source, (3, 3))
|
|
|
|
assert blurred.shape == source.shape
|
|
assert blurred.dtype == source.dtype
|