Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: component to instance helper functions #20

Merged
merged 5 commits into from
Aug 18, 2023

Conversation

daquintero
Copy link
Contributor

Hi Floris,

Hope you're well. I have found these helper functions quite useful when iterating over a range of designs.

They work like:

import gdsfactory as gf
import sax
component = gf.components.mzi2x2_2x2()
component_netlist_recursive = component.get_netlist_recursive()
sax_recursive_netlist = sax.netlist(component_netlist_recursive)
sax.get_netlist_instances_by_prefix(sax_recursive_netlist, prefix="")
# > eg. ['mzi_d46c281f']
sax.get_component_instances(
    recursive_netlist=sax_recursive_netlist, top_level_prefix="mzi_d46c281f", component_name_prefix=""
)
"""
{'': ['bend_euler_1',
  'bend_euler_2',
  'bend_euler_3',
  'bend_euler_4',
  'bend_euler_5',
  'bend_euler_6',
  'bend_euler_7',
  'bend_euler_8',
  'cp1',
  'cp2',
  'straight_10',
  'straight_5',
  'straight_6',
  'straight_7',
  'straight_8',
  'straight_9',
  'sxb',
  'sxt',
  'syl',
  'sytl']}
"""
sax.get_component_instances(
    recursive_netlist=sax_recursive_netlist, top_level_prefix="mzi_d46c281f", component_name_prefix="straight"
)
"""
{'straight': ['straight_10',
  'straight_5',
  'straight_6',
  'straight_7',
  'straight_8',
  'straight_9',
  'sxb',
  'sxt',
  'syl',
  'sytl']}
"""

What do you think?

@flaport flaport merged commit 90b64d5 into flaport:main Aug 18, 2023
4 of 5 checks passed
@flaport
Copy link
Owner

flaport commented Aug 18, 2023

Thanks @daquintero . Will be available in sax>=0.8.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants