Beispiel #1
0
def remove_empty_cells(gds, recursive=True, recurse_depth=0):
    """
    returns the list of removed cells
    """
    if type(gds) == str:
        gds = import_gds(gds)

    cells = gds.get_dependencies(recursive=True)
    _to_remove = []
    for c in cells:
        if is_empty(c):
            _to_remove += [c]

    for c in _to_remove:
        print(c.name)
        remove_cell(gds, c.name)

    if recursive:
        while (len(_to_remove)) > 0:
            print(recurse_depth)
            sys.stdout.flush()
            _to_remove = remove_empty_cells(gds,
                                            recursive=True,
                                            recurse_depth=recurse_depth + 1)

    return _to_remove
Beispiel #2
0
def plotgds(
    gds,
    show_ports=True,
    show_subports=False,
    label_ports=True,
    label_aliases=False,
    new_window=False,
):
    if isinstance(gds, (str, pathlib.Path)):
        gds = import_gds(gds)

    quickplot(
        gds,
        show_ports=show_ports,
        label_ports=label_ports,
        label_aliases=label_aliases,
        new_window=new_window,
    )
Beispiel #3
0
def test_properties_components(component_type):
    """Write component to GDS with setttings_label"""
    cnew = pp.Component()
    c1 = component_factory[component_type]()
    c1ref = cnew << c1

    _add_settings_label(cnew, reference=c1ref)
    gdspath = pp.write_component(cnew)

    c2 = import_gds(gdspath)
    add_settings_from_label(c2)
    c1s = sort_dict(tuplify(c1.get_settings()))
    c2s = sort_dict(tuplify(c2.get_settings()))
    d = diff(c1s, c2s)
    print(c1s)
    print(c2s)
    assert len(d) == 0
    return c2
Beispiel #4
0
def remove_empty_cells_from_gds_file(gdspath):
    gds = import_gds(gdspath)
    remove_empty_cells(gds)
    write_gds(gds, gdspath[:-4] + "_cleaned.gds")
Beispiel #5
0
def test_components_ports(gdspath, num_regression):
    c = import_gds(gdspath)
    add_ports_from_markers_center(c)
    auto_rename_ports(c)
    num_regression.check(c.get_ports_array())
Beispiel #6
0
import pp
from pp.import_gds import add_ports_from_markers_center, import_gds
from pp.port import auto_rename_ports

gdspaths = [
    pp.CONFIG["gdsdir"] / name for name in ["mmi1x2.gds", "mzi2x2.gds"]
]


@pytest.mark.parametrize("gdspath", gdspaths)
def test_components_ports(gdspath, num_regression):
    c = import_gds(gdspath)
    add_ports_from_markers_center(c)
    auto_rename_ports(c)
    num_regression.check(c.get_ports_array())


if __name__ == "__main__":
    c = import_gds(gdspaths[0])
    add_ports_from_markers_center(c)
    auto_rename_ports(c)
    print(c.ports.keys())
    print(c.name)

    c = import_gds(gdspaths[1])
    add_ports_from_markers_center(c)
    auto_rename_ports(c)
    print(c.ports.keys())
    print(c.name)