MCPcopy Index your code
hub / github.com/Layout-Parser/layout-parser / test_rectangle

Function test_rectangle

tests/test_elements.py:44–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43
44def test_rectangle():
45
46 r = Rectangle(1, 2, 3, 4)
47 r.to_interval(axis="x")
48 r.to_quadrilateral()
49 assert r.pad(left=1, right=5, top=2, bottom=4) == Rectangle(0, 0, 8, 8)
50 assert r.shift([1, 2]) == Rectangle(2, 4, 4, 6)
51 assert r.shift(1) == Rectangle(2, 3, 4, 5)
52 assert r.scale([3, 2]) == Rectangle(3, 4, 9, 8)
53 assert r.scale(2) == Rectangle(2, 4, 6, 8)
54 assert r.area == 4
55
56 img = np.random.randint(12, 24, (40, 40))
57 r.crop_image(img).shape == (2, 2)
58
59
60def test_quadrilateral():

Callers

nothing calls this directly

Calls 7

to_intervalMethod · 0.95
to_quadrilateralMethod · 0.95
padMethod · 0.95
shiftMethod · 0.95
scaleMethod · 0.95
crop_imageMethod · 0.95
RectangleClass · 0.90

Tested by

no test coverage detected