MCPcopy Create free account
hub / github.com/Layout-Parser/layout-parser / test_quadrilateral_relations

Function test_quadrilateral_relations

tests/test_elements.py:142–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

140
141
142def test_quadrilateral_relations():
143
144 i = Interval(4, 5, axis="y")
145 q = Quadrilateral(np.array([[2, 2], [6, 2], [6, 7], [2, 5]]))
146 r = Rectangle(3, 3, 5, 6)
147
148 assert not q.is_in(r)
149 assert q.is_in(i, soft_margin={"top": 2, "bottom": 2})
150 assert q.is_in(r, soft_margin={"left": 1, "top": 1, "right": 1, "bottom": 1})
151 assert q.is_in(q)
152
153 # convert to absolute then convert back to relative
154 assert q.condition_on(i).relative_to(i) == q
155 assert q.condition_on(r).relative_to(r) == q
156 assert q.condition_on(q).relative_to(q) == q
157
158 # convert to relative then convert back to absolute
159 assert q.relative_to(i).condition_on(i) == q
160 assert q.relative_to(r).condition_on(r) == q
161 assert q.relative_to(q).condition_on(q) == q
162
163
164def test_textblock():

Callers

nothing calls this directly

Calls 8

is_inMethod · 0.95
condition_onMethod · 0.95
relative_toMethod · 0.95
IntervalClass · 0.90
QuadrilateralClass · 0.90
RectangleClass · 0.90
relative_toMethod · 0.45
condition_onMethod · 0.45

Tested by

no test coverage detected