piel.connectivity#

Submodules#

Functions#

create_all_connections(→ list[piel.types.ConnectionTypes])

This function receives a list of connection and creates the connections between them as two-port relationships.

create_component_connections(...)

The way this function works is by composing the connection namespaces from the names of the components,

create_sequential_component_path(...)

This function takes in a list of components and creates a sequential path connectivity of components with all the connection defined in each component.

create_connection_list_from_ports_lists(...)

When a list of a list of connection is provided, we construct all the required connections accordingly. TODO more docs.

get_port_index_from_name(→ int)

Extracts the numerical index from a port identifier and adjusts based on starting index.

Package Contents#

create_all_connections(ports: list[piel.types.Port], connection_factory: Callable[[list[piel.types.Port]], piel.types.Connection] | None = None, connection_type_output: piel.types.ConnectionTypes | None = Connection) list[piel.types.ConnectionTypes][source]#

This function receives a list of connection and creates the connections between them as two-port relationships. It returns a list of connections. More than two connection can be provided, and it will create all the possible connections.

Parameters:
  • ports (list[Port]) – The connection list to create connections.

  • connection_factory (Optional[Callable[[list[Port]], Connection]], optional) – A function that creates a connection object from a list of connection. The function should receive a list of connection and return a connection object. If not provided, a default connection factory will be used. The default connection factory creates a tuple of connection as a connection object. The default is None.

  • connection_type_output (Optional[type[Connection]], optional) –

    The type of connection object to return.

    If not provided, the default connection factory will be used.

    The default is None

Returns:

A list of connections that were created.

Return type:

list[Connection]

create_component_connections(components: list[piel.types.ComponentTypes], connection_reference_str_list: list[str] | list[list[str]]) list[piel.types.ConnectionTypes][source]#

The way this function works is by composing the connection namespaces from the names of the components, and a given connection dot notation which corresponds to that component.

Notes

The dot notation would be in the format "component_1.port1". Hence, the input to a connection would be ["component1.port1", "component2.port1"] and this function would compile into generating the corresponding connection. This is by splitting the component name and port name accordingly and then programmatically acquiring the corresponding Port reference and creating the Connection from this.

Parameters:
  • components (list[ComponentTypes]) – The components to create connections from.

  • connection_reference_str_list (list[str] | list[list[str]]) – The list of strings that represent the connections to create.

Returns:

The list of connections created from the components.

Return type:

list[ConnectionTypes]

create_sequential_component_path(components: list[piel.types.ComponentTypes], name: str = '', **kwargs) piel.types.ComponentTypes[source]#

This function takes in a list of components and creates a sequential path connectivity of components with all the connection defined in each component. By default, the connectivity will be implemented with the first two connection of the components. There is a clear input and output on each component. The timing metric calculations is provided by the timing model of each connection of the component, if there is none defined it will assume a default zero time connectivity between the relevant connection. For the output component collection, it will output the timing of the network as a whole based on the defined subcomponents. This will create an output component with all the subcomponents, TODO more than two connection, and the list of connection

Creates a sequential path connectivity of components with all the connection defined in each component.

Parameters:#

componentsList[ComponentTypes]

A list of components to be connected sequentially.

Returns:#

: ComponentTypes

A new component that encapsulates the sequential path of input components.

create_connection_list_from_ports_lists(port_connection_list: list[list[piel.types.Port]]) list[piel.types.ConnectionTypes][source]#

When a list of a list of connection is provided, we construct all the required connections accordingly. TODO more docs.

get_port_index_from_name(port: piel.types.Port, starting_index: int | None = None) int[source]#

Extracts the numerical index from a port identifier and adjusts based on starting index. If port numbering starts at 0, adds 1. If starts at 1 or is None, leaves as is.

Parameters: - port (int or str): The port identifier. - starting_index (int, optional): The starting index (0 or 1). Defaults to None.

Returns: - int: The adjusted numerical index of the port.

Raises: - ValueError: If starting_index is not 0, 1, or None. - ValueError: If the port string does not contain a numerical index. - TypeError: If the port is neither int nor str.