<commit_before>from gdsfactory.components.bend_s import bend_s
from gdsfactory.port import Port
from gdsfactory.routing.sort_ports import sort_ports as sort_ports_function
from gdsfactory.types import Routes


def get_bundle_sbend(
    ports1: Port, ports2: Port, sort_ports: bool = True, **kwargs
) -> Routes:
    """Returns a Dict with the routes from ports1 to ports2.

    Args:
        ports1: start ports.
        ports2: end ports.
        sort_ports: sort ports.
        kwargs: cross_section settings.

    Returns:
        references: List of route references.
        lengths: list of floats.
        bend_radius: list of min bend_radius.

    """
    if sort_ports:
        ports1, ports2 = sort_ports_function(ports1, ports2)

    references = []
    lengths = []
    bend_radius = []

    for p1, p2 in zip(ports1, ports2):
        ysize = p2.center[1] - p1.center[1]
        xsize = p2.center[0] - p1.center[0]
        bend = bend_s(size=(xsize, ysize), **kwargs)
        sbend = bend.ref()
        sbend.connect("o1", p1)
        references.append(sbend)
        lengths.append(bend.info["length"])
        bend_radius.append(bend.info["min_bend_radius"])

    return Routes(references=references, lengths=lengths, bend_radius=bend_radius)


if __name__ == "__main__":
    import gdsfactory as gf

    c = gf.Component("test_get_route_sbend")
    pitch = 2.0
    ys_left = [0, 10, 20]
    N = len(ys_left)
    ys_right = [(i - N / 2) * pitch for i in range(N)]
<commit_msg>Update to return list of routes<commit_after>from typing import List

from gdsfactory.components.bend_s import bend_s
from gdsfactory.port import Port
from gdsfactory.routing.sort_ports import sort_ports as sort_ports_function
from gdsfactory.types import Route


def get_bundle_sbend(
    ports1: Port, ports2: Port, sort_ports: bool = True, **kwargs
) -> List[Route]:
    """Returns a list of routes from ports1 to ports2.

    Args:
        ports1: start ports.
        ports2: end ports.
        sort_ports: sort ports.
        kwargs: cross_section settings.

    Returns:
        list of routes.

    """
    if sort_ports:
        ports1, ports2 = sort_ports_function(ports1, ports2)

    routes = []

    for p1, p2 in zip(ports1, ports2):
        ysize = p2.center[1] - p1.center[1]
        xsize = p2.center[0] - p1.center[0]
        bend = bend_s(size=(xsize, ysize), **kwargs)
        sbend = bend.ref()
        sbend.connect("o1", p1)
        routes.append(
            Route(
                references=[sbend],
                ports=tuple(sbend.get_ports_list()),
                length=bend.info["length"],
            )
        )

    return routes


if __name__ == "__main__":
    import gdsfactory as gf

    c = gf.Component("test_get_route_sbend")
    pitch = 2.0
    ys_left = [0, 10, 20]
    N = len(ys_left)
    ys_right = [(i - N / 2) * pitch for i in range(N)]

{'fraction_non_alphanumeric': 0.10639777468706536, 'fraction_numerical': 0.022253129346314324, 'mean_word_length': 2.5128205128205128, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2477524', 'n_tokens_mistral': 987, 'n_tokens_neox': 964, 'n_words': 253}