Skip to content

Commit ca0c431

Browse files
committed
Add trans_path member to JunctionEntry
Keep track of transformation path of junction element
1 parent fae7dae commit ca0c431

2 files changed

Lines changed: 26 additions & 15 deletions

File tree

klayout_package/python/kqcircuits/util/replace_junctions.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,18 @@
3838
class JunctionEntry:
3939
"""All junction properties we want to store when extracting junctions"""
4040

41-
def __init__(self, class_type: type, trans: pya.DCplxTrans, parameters: Dict, parent_name: str, name: str) -> None:
41+
def __init__(
42+
self,
43+
class_type: type,
44+
trans: pya.DCplxTrans,
45+
trans_path: List[pya.DCplxTrans],
46+
parameters: Dict,
47+
parent_name: str,
48+
name: str,
49+
) -> None:
4250
self.type = class_type
4351
self.trans = trans
52+
self.trans_path = trans_path
4453
self.parameters = parameters
4554
self.parent_name = parent_name
4655
self.name = name
@@ -246,7 +255,7 @@ def extract_junctions(top_cell: pya.Cell, tuned_junction_parameters: Dict) -> Li
246255
if not is_pcell:
247256
logging.warning("Top cell doesn't contain PCell parameter data")
248257

249-
def recursive_junction_search(inst, parent_name, prev_trans):
258+
def recursive_junction_search(inst, parent_name, prev_trans, trans_path):
250259
cell = layout.cell(inst.cell_index)
251260
name = inst.property("id")
252261
trans = prev_trans * inst.dcplx_trans
@@ -305,14 +314,16 @@ def recursive_junction_search(inst, parent_name, prev_trans):
305314
parent_name,
306315
name,
307316
)
308-
found_junctions.append(JunctionEntry(type(junction_type), trans, params, parent_name, name))
317+
found_junctions.append(
318+
JunctionEntry(type(junction_type), trans, trans_path + [inst.dcplx_trans], params, parent_name, name)
319+
)
309320
for i in cell.each_inst():
310321
# For pcell oas, accumulate transformation starting from root
311322
# For static oas, only use parent.dcplx_trans * this.dcplx_trans
312-
recursive_junction_search(i, name, trans if is_pcell else prev_trans)
323+
recursive_junction_search(i, name, trans if is_pcell else prev_trans, trans_path + [inst.dcplx_trans])
313324

314325
for i in top_cell.each_inst():
315-
recursive_junction_search(i, None, i.dcplx_trans)
326+
recursive_junction_search(i, None, i.dcplx_trans, [])
316327
# Need to know face of junctions before performing chip specific transformation,
317328
# because we need to know for which face we need to perform the marker position test
318329
if found_junctions:

tests/util/replace_junctions/test_extract_junctions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,33 @@ def test_junction_entry_equality():
7171
t1 = pya.DCplxTrans(1, 0, False, pya.DVector(1, 2))
7272
t1_ = pya.DCplxTrans(1, 0, False, pya.DVector(1, 2))
7373
t2 = pya.DCplxTrans(1, 180, False, pya.DVector(2, 3))
74-
junction_entry = JunctionEntry(Manhattan, t1, {"a": 10, "b": 6}, "qb_0", "squid")
74+
junction_entry = JunctionEntry(Manhattan, t1, [t1], {"a": 10, "b": 6}, "qb_0", "squid")
7575
assert junction_entry == JunctionEntry(
76-
Manhattan, t1_, {"b": 6, "a": 10}, "qb_0", "squid"
76+
Manhattan, t1_, [t1_], {"b": 6, "a": 10}, "qb_0", "squid"
7777
), "Expected these JunctionEntry objects to be considered equal"
7878
assert junction_entry != JunctionEntry(
79-
ManhattanSingleJunction, t1, {"a": 10, "b": 6}, "qb_0", "squid"
79+
ManhattanSingleJunction, t1, [t1], {"a": 10, "b": 6}, "qb_0", "squid"
8080
), "JunctionEntry objects should not be considered equal if they have different type"
8181
assert junction_entry != JunctionEntry(
82-
type(None), t1, {"a": 10, "b": 6}, "qb_0", "squid"
82+
type(None), t1, [t1], {"a": 10, "b": 6}, "qb_0", "squid"
8383
), "JunctionEntry objects should not be considered equal if they have different type"
8484
assert junction_entry != JunctionEntry(
85-
Manhattan, t2, {"a": 10, "b": 6}, "qb_0", "squid"
85+
Manhattan, t2, [t2], {"a": 10, "b": 6}, "qb_0", "squid"
8686
), "JunctionEntry objects should not be considered equal if they have different transformation"
8787
assert junction_entry != JunctionEntry(
88-
Manhattan, t1, {"a": 10, "b": 7}, "qb_0", "squid"
88+
Manhattan, t1, [t1], {"a": 10, "b": 7}, "qb_0", "squid"
8989
), "JunctionEntry objects should not be considered equal if they have different parameters"
9090
assert junction_entry != JunctionEntry(
91-
Manhattan, t1, {"a": 10, "b": 6, "c": 0}, "qb_0", "squid"
91+
Manhattan, t1, [t1], {"a": 10, "b": 6, "c": 0}, "qb_0", "squid"
9292
), "JunctionEntry objects should not be considered equal if they have different parameters"
9393
assert junction_entry != JunctionEntry(
94-
Manhattan, t1, {"b": 6}, "qb_0", "squid"
94+
Manhattan, t1, [t1], {"b": 6}, "qb_0", "squid"
9595
), "JunctionEntry objects should not be considered equal if they have different parameters"
9696
assert junction_entry != JunctionEntry(
97-
Manhattan, t1, {"a": 10, "b": 6}, "qb_1", "squid"
97+
Manhattan, t1, [t1], {"a": 10, "b": 6}, "qb_1", "squid"
9898
), "JunctionEntry objects should not be considered equal if they have different parent name"
9999
assert junction_entry != JunctionEntry(
100-
Manhattan, t1, {"a": 10, "b": 6}, "qb_0", "squid_1"
100+
Manhattan, t1, [t1], {"a": 10, "b": 6}, "qb_0", "squid_1"
101101
), "JunctionEntry objects should not be considered equal if they have different parent name"
102102

103103

0 commit comments

Comments
 (0)