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

straight propagates to route filter in get_bundle #914

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/pages.yml
Expand Up @@ -8,7 +8,6 @@ on:

jobs:
sphinx_docs_to_gh-pages:
needs: [pre-commit]
runs-on: ubuntu-latest
name: Sphinx docs to gh-pages
steps:
Expand Down
52 changes: 25 additions & 27 deletions gdsfactory/routing/get_bundle.py
Expand Up @@ -218,7 +218,7 @@ def test_north_to_south():
return get_bundle_udirect(**params)

elif end_angle == (start_angle + 180) % 360:
# print('get_bundle_uindirect')
# print("get_bundle_uindirect")
return get_bundle_uindirect(extension_length=extension_length, **params)
else:
raise NotImplementedError("This should never happen")
Expand Down Expand Up @@ -712,33 +712,31 @@ def test_get_bundle_small() -> Component:

import gdsfactory as gf

c = gf.Component("get_bundle_none_orientation")
pt = c << gf.components.pad_array(orientation=None, columns=3)
pb = c << gf.components.pad_array(orientation=None, columns=3)
pt.move((100, 200))

routes = gf.routing.get_bundle_electrical_multilayer(
pb.ports,
pt.ports,
start_straight_length=1,
end_straight_length=10,
separation=30,
)
# c = gf.Component("get_bundle_none_orientation")
# pt = c << gf.components.pad_array(orientation=None, columns=3)
# pb = c << gf.components.pad_array(orientation=None, columns=3)
# pt.move((100, 200))
# routes = gf.routing.get_bundle_electrical_multilayer(
# pb.ports,
# pt.ports,
# start_straight_length=1,
# end_straight_length=10,
# separation=30,
# )
# for route in routes:
# c.add(route.references)

c = gf.Component("demo")
c1 = c << gf.components.mmi2x2()
c2 = c << gf.components.mmi2x2()
c2.move((100, 40))
routes = get_bundle(
[c1.ports["o2"], c1.ports["o1"]],
[c2.ports["o1"], c2.ports["o2"]],
radius=5,
# layer=(2, 0),
straight=gf.partial(gf.components.straight, layer=(1, 0), width=1),
)
for route in routes:
c.add(route.references)

c.show(show_ports=True)

# c = gf.Component()
# c1 = c << gf.components.mmi2x2()
# c2 = c << gf.components.mmi2x2()
# c2.move((100, 40))
# routes = get_bundle(
# [c1.ports['o2'], c1.ports["E1"]],
# [c2.ports['o1'], c2.ports['o2']],
# radius=5,
# )
# for route in routes:
# assert np.isclose(route.length, 111.3) ,route.length
# c.add(route.references)
8 changes: 5 additions & 3 deletions gdsfactory/routing/get_bundle_u.py
Expand Up @@ -4,6 +4,7 @@
from numpy import float64, ndarray

from gdsfactory.components.bend_euler import bend_euler
from gdsfactory.components.straight import straight as straight_function
from gdsfactory.geometry.functions import remove_identicals
from gdsfactory.port import Port
from gdsfactory.routing.get_route import get_route_from_waypoints
Expand Down Expand Up @@ -95,8 +96,7 @@ def get_bundle_udirect(
|
X------/
"""
if "straight" in kwargs:
_ = kwargs.pop("straight")
straight = kwargs.pop("straight", straight_function)
routes = _get_bundle_udirect_waypoints(
ports1,
ports2,
Expand All @@ -119,7 +119,9 @@ def get_bundle_udirect(
**kwargs,
)

return [route_filter(route, bend=bend, **kwargs) for route in routes]
return [
route_filter(route, bend=bend, straight=straight, **kwargs) for route in routes
]


def _get_bundle_udirect_waypoints(
Expand Down
4 changes: 2 additions & 2 deletions gdsfactory/routing/get_route.py
Expand Up @@ -44,7 +44,7 @@
from gdsfactory.components.taper import taper as taper_function
from gdsfactory.components.via_corner import via_corner
from gdsfactory.components.wire import wire_corner
from gdsfactory.cross_section import metal2, metal3, strip
from gdsfactory.cross_section import metal2, metal3
from gdsfactory.port import Port
from gdsfactory.routing.manhattan import round_corners, route_manhattan
from gdsfactory.types import (
Expand Down Expand Up @@ -176,7 +176,7 @@ def get_route_from_waypoints(
bend: Callable = bend_euler,
straight: Callable = straight_function,
taper: Optional[Callable] = taper_function,
cross_section: CrossSectionSpec = strip,
cross_section: CrossSectionSpec = "strip",
**kwargs,
) -> Route:
"""Returns a route formed by the given waypoints with bends instead of \
Expand Down
1 change: 1 addition & 0 deletions gdsfactory/routing/manhattan.py
Expand Up @@ -882,6 +882,7 @@ def round_corners(
)
if straight_ports is None:
straight_ports = [p.name for p in _get_straight_ports(wg, layer=layer)]

pname_west, pname_east = straight_ports

wg_ref = wg.ref()
Expand Down
5 changes: 2 additions & 3 deletions gdsfactory/routing/path_length_matching.py
Expand Up @@ -5,7 +5,6 @@

import gdsfactory as gf
from gdsfactory.components.bend_euler import bend_euler
from gdsfactory.cross_section import strip
from gdsfactory.geometry.functions import path_length
from gdsfactory.routing.manhattan import (
_is_horizontal,
Expand All @@ -22,7 +21,7 @@ def path_length_matched_points(
extra_length: float = 0.0,
nb_loops: int = 1,
bend: ComponentSpec = bend_euler,
cross_section: Union[CrossSectionSpec, MultiCrossSectionAngleSpec] = strip,
cross_section: Union[CrossSectionSpec, MultiCrossSectionAngleSpec] = "strip",
**kwargs,
) -> List[ndarray]:
"""Several types of paths won't match correctly. We do not try to handle all the corner cases here. You will need to modify the input list of waypoints in some cases.
Expand Down Expand Up @@ -147,7 +146,7 @@ def path_length_matched_points_add_waypoints(
margin: float = 0.0,
extra_length: float = 0.0,
nb_loops: int = 1,
cross_section: Union[CrossSectionSpec, MultiCrossSectionAngleSpec] = strip,
cross_section: Union[CrossSectionSpec, MultiCrossSectionAngleSpec] = "strip",
**kwargs,
) -> List[ndarray]:
"""Args are the following.
Expand Down