@@ -5526,7 +5526,7 @@ def test_correctness_image(self, mean, std, dtype, fn):
55265526
55275527class TestClampBoundingBoxes :
55285528 @pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
5529- @pytest .mark .parametrize ("clamping_mode" , ("hard" , None )) # TODOBB add soft
5529+ @pytest .mark .parametrize ("clamping_mode" , ("soft" , " hard" , None ))
55305530 @pytest .mark .parametrize ("dtype" , [torch .int64 , torch .float32 ])
55315531 @pytest .mark .parametrize ("device" , cpu_and_cuda ())
55325532 def test_kernel (self , format , clamping_mode , dtype , device ):
@@ -5542,7 +5542,7 @@ def test_kernel(self, format, clamping_mode, dtype, device):
55425542 )
55435543
55445544 @pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
5545- @pytest .mark .parametrize ("clamping_mode" , ("hard" , None )) # TODOBB add soft
5545+ @pytest .mark .parametrize ("clamping_mode" , ("soft" , " hard" , None ))
55465546 def test_functional (self , format , clamping_mode ):
55475547 check_functional (F .clamp_bounding_boxes , make_bounding_boxes (format = format , clamping_mode = clamping_mode ))
55485548
@@ -5566,12 +5566,17 @@ def test_errors(self):
55665566 ):
55675567 F .clamp_bounding_boxes (input_tv_tensor , format = format_ , canvas_size = canvas_size_ )
55685568
5569+ with pytest .raises (ValueError , match = "clamping_mode must be soft," ):
5570+ F .clamp_bounding_boxes (input_tv_tensor , clamping_mode = "bad" )
5571+ with pytest .raises (ValueError , match = "clamping_mode must be soft," ):
5572+ transforms .ClampBoundingBoxes (clamping_mode = "bad" )(input_tv_tensor )
5573+
55695574 def test_transform (self ):
55705575 check_transform (transforms .ClampBoundingBoxes (), make_bounding_boxes ())
55715576
55725577 @pytest .mark .parametrize ("rotated" , (True , False ))
5573- @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , None ))
5574- @pytest .mark .parametrize ("clamping_mode" , ("hard" , None , "auto" )) # TODOBB add soft here.
5578+ @pytest .mark .parametrize ("constructor_clamping_mode" , ("soft" , " hard" , None ))
5579+ @pytest .mark .parametrize ("clamping_mode" , ("soft" , " hard" , None , "auto" ))
55755580 @pytest .mark .parametrize ("pass_pure_tensor" , (True , False ))
55765581 @pytest .mark .parametrize ("fn" , [F .clamp_bounding_boxes , transform_cls_to_functional (transforms .ClampBoundingBoxes )])
55775582 def test_clamping_mode (self , rotated , constructor_clamping_mode , clamping_mode , pass_pure_tensor , fn ):
@@ -5624,8 +5629,8 @@ def test_clamping_mode(self, rotated, constructor_clamping_mode, clamping_mode,
56245629
56255630class TestSetClampingMode :
56265631 @pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
5627- @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , None )) # TODOBB add soft
5628- @pytest .mark .parametrize ("desired_clamping_mode" , ("hard" , None )) # TODOBB add soft
5632+ @pytest .mark .parametrize ("constructor_clamping_mode" , ("soft" , " hard" , None ))
5633+ @pytest .mark .parametrize ("desired_clamping_mode" , ("soft" , " hard" , None ))
56295634 def test_setter (self , format , constructor_clamping_mode , desired_clamping_mode ):
56305635
56315636 in_boxes = make_bounding_boxes (format = format , clamping_mode = constructor_clamping_mode )
@@ -5635,7 +5640,7 @@ def test_setter(self, format, constructor_clamping_mode, desired_clamping_mode):
56355640 assert out_boxes .clamping_mode == desired_clamping_mode
56365641
56375642 @pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
5638- @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , None )) # TODOBB add soft
5643+ @pytest .mark .parametrize ("constructor_clamping_mode" , ("soft" , " hard" , None ))
56395644 def test_pipeline_no_leak (self , format , constructor_clamping_mode ):
56405645 class AssertClampingMode (transforms .Transform ):
56415646 def __init__ (self , expected_clamping_mode ):
@@ -5669,6 +5674,10 @@ def transform(self, inpt, _):
56695674 # ClampBoundingBoxes doesn't set clamping_mode.
56705675 assert out_boxes .clamping_mode is None
56715676
5677+ def test_error (self ):
5678+ with pytest .raises (ValueError , match = "clamping_mode must be" ):
5679+ transforms .SetClampingMode ("bad" )
5680+
56725681
56735682class TestClampKeyPoints :
56745683 @pytest .mark .parametrize ("dtype" , [torch .int64 , torch .float32 ])
0 commit comments