Skip to content

Commit

Permalink
Merge pull request #2801 from gdsfactory/fix_tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
joamatab committed May 29, 2024
2 parents 6d83001 + a2e1801 commit 91f1904
Show file tree
Hide file tree
Showing 230 changed files with 471 additions and 683 deletions.
9 changes: 6 additions & 3 deletions gdsfactory/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,14 @@ def to_3d(
exclude_layers=exclude_layers,
)

def get_netlist(self, **kwargs) -> dict[str, Any]:
def get_netlist(self, flat: bool = False, **kwargs) -> dict[str, Any]:
"""Returns a netlist for circuit simulation."""
from gdsfactory.get_netlist import get_netlist
from gdsfactory.get_netlist import get_netlist as _get_netlist
from gdsfactory.get_netlist_flat import get_netlist_flat as _get_netlist_flat

return get_netlist(self, **kwargs)
return (
_get_netlist_flat(self, **kwargs) if flat else _get_netlist(self, **kwargs)
)

def write_netlist(self, filepath: str, **kwargs) -> None:
"""Write netlist in YAML."""
Expand Down
7 changes: 3 additions & 4 deletions gdsfactory/components/mode_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.components.bend_euler import bend_euler_s
from gdsfactory.components.bend_s import bend_s
from gdsfactory.components.coupler_straight_asymmetric import (
coupler_straight_asymmetric as coupler_straight_asymmetric_function,
)
Expand All @@ -17,7 +17,7 @@ def mode_converter(
gap: float = 0.3,
length: float = 10,
coupler_straight_asymmetric: ComponentSpec = coupler_straight_asymmetric_function,
bend: ComponentSpec = partial(bend_euler_s, angle=45),
bend: ComponentSpec = partial(bend_s, size=(25, 3)),
taper: ComponentSpec = taper_function,
mm_width: float = 1.2,
mc_mm_width: float = 1,
Expand Down Expand Up @@ -74,6 +74,7 @@ def mode_converter(
width1=mc_mm_width,
width2=mm_width,
length=taper_length,
cross_section=cross_section,
)

# directional coupler
Expand All @@ -98,8 +99,6 @@ def mode_converter(
c.add_port("o3", port=r_bot_straight.ports["o2"])
c.add_port("o2", port=l_bend.ports["o2"])
c.add_port("o4", port=r_bend.ports["o2"])

c.flatten()
return c


Expand Down
5 changes: 2 additions & 3 deletions gdsfactory/get_netlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ def _demo_mzi_lattice() -> None:
delta_lengths=delta_lengths,
)
c.get_netlist()
print(c.get_netlist_yaml())


DEFAULT_CONNECTION_VALIDATORS = get_default_connection_validators()
Expand All @@ -568,10 +567,10 @@ def _demo_mzi_lattice() -> None:
bend.connect("o1", mzi.ports["o2"])
bend.name = "bend"
n0 = c.get_netlist()
pprint(n0)
# pprint(n0)

gdspath = c.write_gds("test.gds")
c = gf.import_gds(gdspath)
n = c.get_netlist()
# pprint(n)
pprint(n)
c.show()
24 changes: 8 additions & 16 deletions gdsfactory/read/from_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from functools import partial
from typing import IO, Any, Literal

import kfactory as kf
from omegaconf import DictConfig, OmegaConf

from gdsfactory.add_pins import add_instance_label
Expand Down Expand Up @@ -260,14 +261,17 @@ def place(
rotation = placement_settings.get("rotation")
mirror = placement_settings.get("mirror")

if rotation:
if port:
ref.drotate(rotation, center=_get_anchor_point_from_name(ref, port))
else:
ref.drotate(rotation)

if mirror:
if mirror is True and port:
ref.dmirror_x(x=_get_anchor_value_from_name(ref, port, "x"))
elif mirror is True:
if x:
ref.dmirror_x(x=ref.dx)
else:
ref.dmirror_x()
ref.dcplx_trans *= kf.kdb.DCplxTrans(1, 0, True, 0, 0)
elif mirror is False:
pass
elif isinstance(mirror, str):
Expand Down Expand Up @@ -306,9 +310,6 @@ def place(
all_remaining_insts=all_remaining_insts,
)

# print(instance_name, x, xmin, xmax, y, ymin, ymax)
# print(ymin, y or ymin or ymax)

if y is not None:
ref.dy += _move_ref(
y,
Expand All @@ -320,15 +321,6 @@ def place(
all_remaining_insts=all_remaining_insts,
)

if rotation:
if port:
ref.drotate(rotation, center=_get_anchor_point_from_name(ref, port))
else:
origin = ref.dtrans.disp
x = origin.x
y = origin.y
ref.drotate(rotation, center=(x, y))

if ymin is not None and ymax is not None:
raise ValueError("You cannot set ymin and ymax")
elif ymax is not None:
Expand Down
12 changes: 9 additions & 3 deletions gdsfactory/read/import_gds.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ def import_gds(
temp_kcl.read(gdspath)
cellname = cellname or temp_kcl.top_cell().name
kcell = temp_kcl[cellname]
c = kcell_to_component(kcell)

if post_process:
post_process(c)
return c


def kcell_to_component(kcell: kf.KCell) -> Component:
c = Component()
c.name = cellname
c._kdb_cell.copy_tree(kcell._kdb_cell)
c.rebuild()
c.ports = kcell.ports
c._settings = kcell.settings.model_copy()
c.info = kcell.info.model_copy()
if post_process:
post_process(c)
c.name = kcell.name
return c


Expand Down
5 changes: 3 additions & 2 deletions gdsfactory/routing/route_bundle_all_angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from functools import partial

import kfactory as kf
import numpy as np
from kfactory.routing.aa.optical import (
BendFactory,
OpticalAllAngleRoute,
Expand All @@ -18,8 +19,8 @@ def route_bundle_all_angle(
component: ComponentSpec,
ports1: list[Port],
ports2: list[Port],
backbone: Sequence[tuple[float, float]],
separation: list[float] | float,
backbone: Sequence[tuple[float, float]] = [],
separation: list[float] | float = 3.0,
straight_factory: StraightFactory = straight,
bend_factory: BendFactory = partial(bend_euler, radius=5),
bend_ports: tuple[str, str] = ("o1", "o2"),
Expand Down
8 changes: 0 additions & 8 deletions gdsfactory/samples/netlists/bend_mirror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ instances:
route_info_xs_34e31a19_length: 15.708
route_info_n_bend_90: 1.0
settings:
radius: null
angle: 90.0
npoints: null
layer: null
width: null
cross_section: strip
allow_min_radius_violation: false
b2:
Expand All @@ -31,11 +27,7 @@ instances:
route_info_xs_34e31a19_length: 15.708
route_info_n_bend_90: 1.0
settings:
radius: null
angle: 90.0
npoints: null
layer: null
width: null
cross_section: strip
allow_min_radius_violation: false
placements:
Expand Down
Loading

0 comments on commit 91f1904

Please sign in to comment.