Skip to content

Commit

Permalink
Merge pull request #373 from gdsfactory/better-error-for-wrong-top-ce…
Browse files Browse the repository at this point in the history
…ll-spice

Better error for wrong `top_cell` in netlist to networkx
  • Loading branch information
nikosavola committed Apr 8, 2024
2 parents 97fa9d9 + 72a393c commit 7e9bc89
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions gplugins/klayout/netlist_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ def netlist_to_networkx(
)

if top_cell:
top_circuits = (
next(c for c in top_circuits if c.name.casefold() == top_cell.casefold()),
)
try:
top_circuits = (
next(
c for c in top_circuits if c.name.casefold() == top_cell.casefold()
),
)
except StopIteration as e:
available_top_cells = [cell.name for cell in top_circuits]
raise ValueError(
f"{top_cell=!r} not found in the netlist. Available top cells: {available_top_cells!r}"
) from e

all_used_nets = set()
for circuit in top_circuits:
Expand Down

0 comments on commit 7e9bc89

Please sign in to comment.