Skip to content

Commit

Permalink
🔧 fix multiple ports
Browse files Browse the repository at this point in the history
  • Loading branch information
daquintero committed Oct 31, 2024
1 parent 65aaeac commit f139688
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gdsfactory/get_netlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def get_netlist(
get_instance_name: Callable[..., str] = get_instance_name_from_alias,
allow_multiple: bool = False,
merge_info: bool = False,
extend_recursive_port_names: bool = False,
) -> dict[str, Any]:
"""Returns instances, connections and placements from :class:`Component` as a dict.
Expand Down Expand Up @@ -144,6 +145,7 @@ def get_netlist(
allow_multiple: False to raise an error if more than two ports share the same connection. \
if True, will return key: [value] pairs with [value] a list of all connected instances.
merge_info: True to merge info and settings into the same dict.
extend_recursive_port_names: Compatibility with recursive get_netlist port name identifiers.
Returns:
Dictionary containing the following:
Expand Down Expand Up @@ -236,7 +238,10 @@ def get_netlist(
# a bit of a hack... get the top-level port for the
# ComponentArray, by our known naming convention. I hope no one
# renames these ports!
parent_port = component[top_name]
if extend_recursive_port_names:
parent_port = component[parent_port_name] # otherwise links to non existent component ports
else:
parent_port = component[top_name]
name2port[lower_name] = parent_port
top_ports_list.add(top_name)
ports_by_type[parent_port.port_type].append(lower_name)
Expand Down
1 change: 1 addition & 0 deletions tests/test_get_netlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_get_netlist_cell_array() -> None:
gf.components.straight(length=10), spacing=(0, 100), columns=1, rows=5
)
n = c.get_netlist()
print(n)
assert len(c.ports) == 10
assert not n["connections"]
assert len(n["ports"]) == 10
Expand Down

0 comments on commit f139688

Please sign in to comment.