MCPcopy
hub / github.com/pytorch/vision / test_edge_cases

Method test_edge_cases

test/test_transforms_v2.py:7778–7799  ·  view source on GitHub ↗

Test edge cases and boundary conditions.

(self)

Source from the content-addressed store, hash-verified

7776 assert_equal(out_other_labels, other_labels)
7777
7778 def test_edge_cases(self):
7779 """Test edge cases and boundary conditions."""
7780 canvas_size = (10, 10)
7781
7782 # Test empty keypoints
7783 empty_keypoints = tv_tensors.KeyPoints(torch.empty(0, 2), canvas_size=canvas_size)
7784 result, valid_mask = F.sanitize_keypoints(empty_keypoints)
7785 print(empty_keypoints, result, valid_mask)
7786 assert tuple(result.shape) == (0, 2)
7787 assert valid_mask.shape[0] == 0
7788
7789 # Test single valid keypoint
7790 single_valid = tv_tensors.KeyPoints([[5, 5]], canvas_size=canvas_size)
7791 result, valid_mask = F.sanitize_keypoints(single_valid)
7792 assert tuple(result.shape) == (1, 2)
7793 assert valid_mask.all()
7794
7795 # Test single invalid keypoint
7796 single_invalid = tv_tensors.KeyPoints([[-1, -1]], canvas_size=canvas_size)
7797 result, valid_mask = F.sanitize_keypoints(single_invalid)
7798 assert tuple(result.shape) == (0, 2)
7799 assert not valid_mask.any()
7800
7801 def test_errors_functional(self):
7802 """Test error conditions for the functional interface."""

Callers

nothing calls this directly

Calls 1

printFunction · 0.50

Tested by

no test coverage detected