@@ -5526,7 +5526,7 @@ def test_correctness_image(self, mean, std, dtype, fn):
5526
5526
5527
5527
class TestClampBoundingBoxes :
5528
5528
@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 ))
5530
5530
@pytest .mark .parametrize ("dtype" , [torch .int64 , torch .float32 ])
5531
5531
@pytest .mark .parametrize ("device" , cpu_and_cuda ())
5532
5532
def test_kernel (self , format , clamping_mode , dtype , device ):
@@ -5542,7 +5542,7 @@ def test_kernel(self, format, clamping_mode, dtype, device):
5542
5542
)
5543
5543
5544
5544
@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 ))
5546
5546
def test_functional (self , format , clamping_mode ):
5547
5547
check_functional (F .clamp_bounding_boxes , make_bounding_boxes (format = format , clamping_mode = clamping_mode ))
5548
5548
@@ -5566,12 +5566,17 @@ def test_errors(self):
5566
5566
):
5567
5567
F .clamp_bounding_boxes (input_tv_tensor , format = format_ , canvas_size = canvas_size_ )
5568
5568
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
+
5569
5574
def test_transform (self ):
5570
5575
check_transform (transforms .ClampBoundingBoxes (), make_bounding_boxes ())
5571
5576
5572
5577
@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" ))
5575
5580
@pytest .mark .parametrize ("pass_pure_tensor" , (True , False ))
5576
5581
@pytest .mark .parametrize ("fn" , [F .clamp_bounding_boxes , transform_cls_to_functional (transforms .ClampBoundingBoxes )])
5577
5582
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,
5624
5629
5625
5630
class TestSetClampingMode :
5626
5631
@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 ))
5629
5634
def test_setter (self , format , constructor_clamping_mode , desired_clamping_mode ):
5630
5635
5631
5636
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):
5635
5640
assert out_boxes .clamping_mode == desired_clamping_mode
5636
5641
5637
5642
@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 ))
5639
5644
def test_pipeline_no_leak (self , format , constructor_clamping_mode ):
5640
5645
class AssertClampingMode (transforms .Transform ):
5641
5646
def __init__ (self , expected_clamping_mode ):
@@ -5669,6 +5674,10 @@ def transform(self, inpt, _):
5669
5674
# ClampBoundingBoxes doesn't set clamping_mode.
5670
5675
assert out_boxes .clamping_mode is None
5671
5676
5677
+ def test_error (self ):
5678
+ with pytest .raises (ValueError , match = "clamping_mode must be" ):
5679
+ transforms .SetClampingMode ("bad" )
5680
+
5672
5681
5673
5682
class TestClampKeyPoints :
5674
5683
@pytest .mark .parametrize ("dtype" , [torch .int64 , torch .float32 ])
0 commit comments