Skip to content

Commit

Permalink
Allow multiple children cells with equal names
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeutel committed May 25, 2022
1 parent 092adf9 commit a25d9f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gdshelpers/geometry/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ def get_desc(self):
"""
def walk_cells(cell, out_dict):
if cell.name not in out_dict:
out_dict[cell.name] = {
'cells': {child['cell'].name: dict(offset=tuple(child['origin']),
angle=child['angle'] or 0) for child in cell.cells},
**cell.desc
}
cellrefs = []
for child in cell.cells:
child_dict = child.copy()
child_dict['cell'] = child_dict['cell'].name
cellrefs.append(child_dict)

out_dict[cell.name] = {'cells': cellrefs, **cell.desc}

for child in cell.cells:
walk_cells(child['cell'], out_dict)
Expand Down
1 change: 1 addition & 0 deletions gdshelpers/tests/test_chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,4 @@ def test_desc(self):
self.assertTrue("desctest" in d["cells"])
self.assertEqual("desctest", d["root"])
self.assertEqual(2, len(d["cells"]["desctest"]["cells"]))
self.assertEqual("child1", d["cells"]["desctest"]["cells"][0]["cell"])

0 comments on commit a25d9f1

Please sign in to comment.