@@ -1125,3 +1125,58 @@ def test_process_roboflow_result_compact_masks_rle_mask_size_mismatch() -> None:
11251125
11261126 assert isinstance (compact_result [3 ], CompactMask )
11271127 np .testing .assert_array_equal (compact_result [3 ].to_dense (), dense_result [3 ])
1128+
1129+
1130+ # ---------------------------------------------------------------------------
1131+ # cross_product — regression + unit tests (GitHub #2384)
1132+ # ---------------------------------------------------------------------------
1133+ import warnings # noqa: E402
1134+
1135+ from supervision .detection .utils .internal import cross_product # noqa: E402
1136+ from supervision .geometry .core import Point , Vector # noqa: E402
1137+
1138+
1139+ def test_cross_product_no_deprecation_warning () -> None :
1140+ """Regression for #2384: cross_product must not fire DeprecationWarning."""
1141+ anchors = np .array ([[[5.0 , 5.0 ]]])
1142+ v = Vector (start = Point (0 , 0 ), end = Point (10 , 0 ))
1143+ with warnings .catch_warnings ():
1144+ warnings .simplefilter ("error" , DeprecationWarning )
1145+ cross_product (anchors , v )
1146+
1147+
1148+ @pytest .mark .parametrize (
1149+ ("anchors" , "vector" , "expected_sign" ),
1150+ [
1151+ pytest .param (
1152+ np .array ([[[5.0 , 5.0 ]]]),
1153+ Vector (Point (0 , 0 ), Point (10 , 0 )),
1154+ 1 ,
1155+ id = "above" ,
1156+ ),
1157+ pytest .param (
1158+ np .array ([[[5.0 , - 5.0 ]]]),
1159+ Vector (Point (0 , 0 ), Point (10 , 0 )),
1160+ - 1 ,
1161+ id = "below" ,
1162+ ),
1163+ pytest .param (
1164+ np .array ([[[5.0 , 0.0 ]]]),
1165+ Vector (Point (0 , 0 ), Point (10 , 0 )),
1166+ 0 ,
1167+ id = "on-line" ,
1168+ ),
1169+ pytest .param (
1170+ np .array ([[[3.0 , 3.0 ]]]),
1171+ Vector (Point (1 , 1 ), Point (5 , 1 )),
1172+ 1 ,
1173+ id = "offset-start" ,
1174+ ),
1175+ ],
1176+ )
1177+ def test_cross_product_sign (
1178+ anchors : np .ndarray , vector : Vector , expected_sign : int
1179+ ) -> None :
1180+ """Verify cross_product returns correct sign for known anchor/vector pairs."""
1181+ result = cross_product (anchors , vector )
1182+ assert int (np .sign (result [0 , 0 ])) == expected_sign
0 commit comments