diff --git a/gdshelpers/geometry/chip.py b/gdshelpers/geometry/chip.py index 639d3eb..2bbf436 100644 --- a/gdshelpers/geometry/chip.py +++ b/gdshelpers/geometry/chip.py @@ -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) diff --git a/gdshelpers/tests/test_chip.py b/gdshelpers/tests/test_chip.py index 3002e41..3c101de 100644 --- a/gdshelpers/tests/test_chip.py +++ b/gdshelpers/tests/test_chip.py @@ -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"])