def test_denormalized_as_denormalized(): bbox = BBox.from_xywh(5, 10, 20, 50) assert bbox.as_denormalized(100, 100) is bbox
def test_denormalized_as_normalized(): bbox = BBox.from_xywh(5, 10, 20, 50) normalized = bbox.as_normalized(100, 100) assert isinstance(normalized, NormalizedBBox) assert normalized == bbox.normalize(100, 100)
def test_class_constructor(): bbox = BBox.from_xywh(1, 1, 5, 5) assert isinstance(bbox, BBox) bbox = NormalizedBBox.from_xywh(0.1, 0.1, 0.5, 0.5) assert isinstance(bbox, NormalizedBBox)
def test_rescale_at_center(): bbox = BBox.from_xywh(100, 200, 50, 100) assert bbox.rescale_at_center(2).xywh() == (75, 150, 100, 200)
def test_from_xywh(): bbox = BBox.from_xywh(5, 6, 10, 30) assert bbox.xmin == 5 assert bbox.xmax == 15 assert bbox.ymin == 6 assert bbox.ymax == 36