b_asic.graph_component

Inheritance diagram of b_asic.graph_component

B-ASIC Graph Component Module.

Contains the base for all components with an ID in a signal flow graph.

class b_asic.graph_component.AbstractGraphComponent(name: str = '')

Bases: GraphComponent

Generic abstract graph component base class.

Concrete graph components should normally derive from this to get the default behavior.

copy(*args, **kwargs) GraphComponent

Get a new instance of this graph component type.

The new instance will have the same name, id, and parameters.

property graph_id: GraphID

Get the graph id of this graph component.

property name: str

Get the name of this graph component.

param(name: str) Any

Get the value of a parameter.

Returns None if the parameter is not defined.

property params: Mapping[str, Any]

Get a dictionary of all parameter values.

set_param(name: str, value: Any) None

Set the value of a parameter.

Adds the parameter if it is not already defined.

traverse() Generator[GraphComponent, None, None]

Get a generator for traversing the all connected components.

The generator recursively iterates through all components that are connected to this operation, as well as the ones that they are connected to.

class b_asic.graph_component.GraphComponent

Bases: ABC

Graph component interface.

Each graph component has a type name, a name and a unique ID. Graph components also contain parameters and provide an interface for copying that automatically copies each parameter in its default implementation.

Graph components also provide an interface for traversing connected graph components and accessing their direct neighbors.

abstract copy(*args, **kwargs) GraphComponent

Get a new instance of this graph component type.

The new instance will have the same name, id, and parameters.

abstract property graph_id: GraphID

Get the graph id of this graph component.

abstract property name: str

Get the name of this graph component.

abstract property neighbors: Iterable[GraphComponent]

Get all components that are directly connected to this operation.

abstract param(name: str) Any

Get the value of a parameter.

Returns None if the parameter is not defined.

abstract property params: Mapping[str, Any]

Get a dictionary of all parameter values.

abstract set_param(name: str, value: Any) None

Set the value of a parameter.

Adds the parameter if it is not already defined.

abstract traverse() Generator[GraphComponent, None, None]

Get a generator for traversing the all connected components.

The generator recursively iterates through all components that are connected to this operation, as well as the ones that they are connected to.

abstract classmethod type_name() TypeName

Get the type name of this graph component.