Scaffold

class fugu.scaffold.scaffold.Scaffold

Bases: object

Class to handle a scaffold of bricks

supported_backends = ['snn', 'ds_legacy', 'snn_legacy', 'pynn']
add_brick(brick, input_nodes=[], metadata=None, name=None, output=False)

Add a brick to the scaffold. Newer code that calls this function should only pass the brick itself. The job of connecting ports between bricks is handled separately by calls to connect(). Older code that calls this function may pass values for the other arguments. These will be automatically translated into equivalent port connections.

Parameters:
  • brick (obj) – object of type brick

  • input_nodes (list) – list of node numbers (Default: [])

  • metadata – dictionary of shapes and parameters of the brick (Default: None)

  • name (any) – string of the brick’s name (Default: none)

  • output (bool) – bool flag to indicate if a brick is an output brick (Default: False)

Returns:

The brick. This allows you to collapse brick creation and addition scaffold into single call, while retaining a reference to the created object for making connections. Example:

A = scaffold.add_brick(SomeBrick())

Raises:

ValueError – Raises if node name is already used.

connect(from_brick, to_brick, from_port='0', to_port='0')

Binds an output port to an input port in the circuit graph. The port names are determined by their respective bricks. These can be queried by calling input_ports() and output_ports() on a given brick class.

For binding auto-ports, you may either use an explicit suffix or specify the base name without a suffix. For example, if name=”input”, then you can bind to “input3” explicitly, or bind to “input”. In the latter case, the exact suffix will be determined during lay_bricks(). Note: the current logic does not allow multiple connections from one brick to the same auto-port on another brick unless the suffixes are explicit.

all_in_neighbors_built(node)

Check if all neighbors of a node are built.

Parameters:

node (any) – node whose neighbors are checked

Returns:

indicates if all neighbors are built.

Return type:

built_graph (bool)

lay_bricks(verbose=0)

Build a computational graph that can be used by the backend.

Parameters:

verbose (int) – value to specify level of verbosity (Default: 0 to indicate None)

Returns:

networkX diGraph

Return type:

built_graph

summary(verbose=0)

Display a summary of the scaffold. Prints information about the scaffold. :param verbose: verbosity level can be 0, 1 or >1 (Default: 0) :type verbose: int