piel.tools.gdsfactory.netlist#

Functions#

get_matched_ports_tuple_index(ports_index, ...)

This function returns the input connection of a component. However, input connection may have different sets of prefixes

get_input_ports_index(→ tuple)

This function returns the input connection of a component. However, input connection may have different sets of prefixes

get_netlist(*args, **kwargs)

get_netlist_recursive(*args, **kwargs)

Module Contents#

get_matched_ports_tuple_index(ports_index: dict, selected_ports_tuple: tuple | None = None, sorting_algorithm: Literal['prefix', 'selected_ports'] = 'prefix', prefix: str = 'in')[source]#

This function returns the input connection of a component. However, input connection may have different sets of prefixes and suffixes. This function implements different sorting algorithms for different connection names. The default algorithm is prefix, which sorts the connection by their prefix. The Endianness implementation means that the tuple order is determined according to the last numerical index order of the port numbering. Returns just a tuple of the index.

Returns the indices of connection that match specified criteria. The function supports sorting by a prefix or by a selected tuple of connection.

Args:

ports_index (dict): A dictionary where keys are port names and values are their indices. selected_ports_tuple (tuple, optional): A tuple of selected connection to match. Defaults to None. sorting_algorithm (Literal[“prefix”, “selected_ports”], optional): The sorting algorithm to use. Defaults to “prefix”. prefix (str, optional): The prefix to filter connection when using the “prefix” sorting algorithm. Defaults to “in”.

Returns:
tuple[tuple, tuple]:
  • The first tuple contains the indices of the matched connection in the specified order.

  • The second tuple contains the names of the matched connection in the specified order.

Raises:

ValueError: If an unsupported sorting algorithm is specified.

Examples:
>>> raw_ports_index = {
>>>     "in_o_0": 0,
>>>     "out_o_0": 1,
>>>     "out_o_1": 2,
>>>     "out_o_2": 3,
>>>     "out_o_3": 4,
>>>     "in_o_1": 5,
>>>     "in_o_2": 6,
>>>     "in_o_3": 7,
>>> }
>>> get_matched_ports_tuple_index(ports_index=raw_ports_index)
((0, 5, 6, 7), ("in_o_0", "in_o_1", "in_o_2", "in_o_3"))
get_input_ports_index(ports_index: dict, sorting_algorithm: Literal['prefix'] = 'prefix', prefix: str = 'in') tuple[source]#

This function returns the input connection of a component. However, input connection may have different sets of prefixes and suffixes. This function implements different sorting algorithms for different connection names. The default algorithm is prefix, which sorts the connection by their prefix. The Endianness implementation means that the tuple order is determined according to the last numerical index order of the port numbering. Returns the indices and names of input connection for a component, sorted by a specified algorithm. The default sorting algorithm uses a prefix.

Parameters:
  • ports_index (dict) – A dictionary where keys are port names and values are their indices.

  • sorting_algorithm (Literal["prefix"], optional) – The sorting algorithm to use. Defaults to “prefix”.

  • prefix (str, optional) – The prefix to filter and sort connection when using the “prefix” sorting algorithm. Defaults to “in”.

Returns:

A tuple where each element is a pair of port index and port name, sorted as specified.

Return type:

tuple

Examples

>>> raw_ports_index = {
>>>     "in_o_0": 0,
>>>     "out_o_0": 1,
>>>     "out_o_1": 2,
>>>     "out_o_2": 3,
>>>     "out_o_3": 4,
>>>     "in_o_1": 5,
>>>     "in_o_2": 6,
>>>     "in_o_3": 7,
>>> }
>>> get_input_ports_index(ports_index=raw_ports_index)
((0, "in_o_0"), (5, "in_o_1"), (6, "in_o_2"), (7, "in_o_3"))
get_netlist(*args, **kwargs)[source]#
get_netlist_recursive(*args, **kwargs)[source]#