Skip to content

Commit

Permalink
Merge pull request #603 from gdsfactory/fix-clear-cells
Browse files Browse the repository at this point in the history
Fix clear kcells
  • Loading branch information
MatthewMckee4 authored Feb 9, 2025
2 parents f440b75 + 70d02bf commit 65696b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/kfactory/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,9 @@ def top_kcell(self) -> KCell:

def clear_kcells(self) -> None:
"""Clears all cells in the Layout object."""
for kc in self.kcells.values():
kc.locked = False
for tc in self.top_kcells():
tc.locked = False
tc.kdb_cell.prune_cell()
self.tkcells = {}

Expand Down
3 changes: 3 additions & 0 deletions tests/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,15 @@ def test_no_output_type(): # type: ignore[no-untyped-def] # noqa: ANN202


def test_clear_kcells(kcl: kf.KCLayout, layers: Layers) -> None:
c = kcl.kcell(name="c")
straight = kf.factories.straight.straight_dbu_factory(kcl)(
length=1000, width=1000, layer=layers.WG
)
c << straight
kcl.clear_kcells()
assert len(kcl.kcells) == 0
assert straight.destroyed()
assert c.destroyed()


if __name__ == "__main__":
Expand Down

0 comments on commit 65696b7

Please sign in to comment.