Skip to content

Commit 102e4cd

Browse files
committed
Fix partition line generation for substrates with no spacing
1 parent 3a33bba commit 102e4cd

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

kikit/substrate.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,32 @@ def seedFilter(idA, idB, v, l):
869869
return False
870870
return idA not in ghosts or idB not in ghosts
871871
self._partition = BoxPartitionLines(
872-
boxes,
872+
self._preprocessBoxes(boxes),
873873
seedFilter,
874874
safeHorizontalMargin, safeVerticalMargin)
875875

876+
def _preprocessBoxes(self, boxes):
877+
"""
878+
BoxPartitionLines assumes non-overlapping boxes. However, when we
879+
specify zero spacing, the boxes share an edge which violates the initial
880+
condition. It is safe to shrink the boxes if they are not the outer-most
881+
edges.
882+
"""
883+
minx = min(map(lambda x: x[0], boxes.values()))
884+
miny = min(map(lambda x: x[1], boxes.values()))
885+
maxx = max(map(lambda x: x[2], boxes.values()))
886+
maxy = min(map(lambda x: x[3], boxes.values()))
887+
888+
newBoxes = {}
889+
for i, b in boxes.items():
890+
newBoxes[i] = (
891+
b[0] + SHP_EPSILON if b[0] != minx else minx,
892+
b[1] + SHP_EPSILON if b[1] != miny else miny,
893+
b[2] - SHP_EPSILON if b[2] != maxx else maxx,
894+
b[3] - SHP_EPSILON if b[3] != maxy else maxy
895+
)
896+
return newBoxes
897+
876898
@property
877899
def query(self):
878900
return self._partition.query

0 commit comments

Comments
 (0)