25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
from dataclasses import replace
|
|
|
|
from shapely.geometry import Polygon
|
|
|
|
from inire.router._capacity import cut_capacity, port_conflicts
|
|
from inire.tests.routing_corpus import CASE_GROUPS
|
|
|
|
|
|
def test_cut_capacity_requires_rectangular_obstacles() -> None:
|
|
(case,) = CASE_GROUPS["overloaded-gate"]
|
|
bound = cut_capacity(case.problem, case.options)
|
|
assert bound is not None
|
|
assert (bound.crossing_nets, bound.tracks, bound.max_routed) == (4, 3, case.routing_bound)
|
|
|
|
triangle = Polygon([(10, 10), (20, 10), (10, 20)])
|
|
changed = replace(case.problem, static_obstacles=(*case.problem.static_obstacles, triangle))
|
|
assert cut_capacity(changed, case.options) is None
|
|
|
|
|
|
def test_fixed_port_conflicts_are_disjoint_and_depend_on_clearance() -> None:
|
|
(case,) = CASE_GROUPS["lidar-clements-8x8"]
|
|
pairs = port_conflicts(case.problem, case.options)
|
|
assert len(case.problem.nets) - len(pairs) == case.routing_bound
|
|
assert len({net_id for pair in pairs for net_id in pair}) == 2 * len(pairs)
|
|
assert port_conflicts(replace(case.problem, clearance=0), case.options) == ()
|