Skip to content

Commit

Permalink
Some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Aug 7, 2023
1 parent 8953ac0 commit 6237f0d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/test_datapoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ def test_detach_wrapping():
assert type(image_detached) is datapoints.Image


def test_no_wrapping_exceptions_with_metadata():
# Sanity checks for the ops in _NO_WRAPPING_EXCEPTIONS and datapoints with metadata
format, canvas_size = "XYXY", (32, 32)
bbox = datapoints.BoundingBoxes([[0, 0, 5, 5], [2, 2, 7, 7]], format=format, canvas_size=canvas_size)

bbox = bbox.clone()
assert bbox.format, bbox.canvas_size == (format, canvas_size)

bbox = bbox.to(torch.float64)
assert bbox.format, bbox.canvas_size == (format, canvas_size)

bbox = bbox.detach()
assert bbox.format, bbox.canvas_size == (format, canvas_size)

assert not bbox.requires_grad
bbox.requires_grad_(True)
assert bbox.format, bbox.canvas_size == (format, canvas_size)
assert bbox.requires_grad


def test_other_op_no_wrapping():
image = datapoints.Image(torch.rand(3, 16, 16))

Expand Down

0 comments on commit 6237f0d

Please sign in to comment.