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

Function test_rectangle_relations

tests/test_elements.py:120–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118
119
120def test_rectangle_relations():
121
122 i = Interval(4, 5, axis="y")
123 q = Quadrilateral(np.array([[2, 2], [6, 2], [6, 7], [2, 5]]))
124 r = Rectangle(3, 3, 5, 6)
125
126 assert not r.is_in(q)
127 assert r.is_in(q, soft_margin={"bottom": 1})
128 assert r.is_in(q.to_rectangle())
129 assert r.is_in(q.to_interval(axis="x"))
130
131 # convert to absolute then convert back to relative
132 assert r.condition_on(i).relative_to(i) == r
133 assert r.condition_on(r).relative_to(r) == r
134 assert r.condition_on(q).relative_to(q) == r.to_quadrilateral()
135
136 # convert to relative then convert back to absolute
137 assert r.relative_to(i).condition_on(i) == r
138 assert r.relative_to(r).condition_on(r) == r
139 assert r.relative_to(q).condition_on(q) == r.to_quadrilateral()
140
141
142def test_quadrilateral_relations():

Callers

nothing calls this directly

Calls 11

is_inMethod · 0.95
to_rectangleMethod · 0.95
to_intervalMethod · 0.95
condition_onMethod · 0.95
to_quadrilateralMethod · 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