Circuit examination

Finding blocks

Circuit.getblocks(btype: type[Block|Addon]] = Block) Iterable

Return an iterable of all blocks or an iterator of btype blocks only.

Block type checking is implemented with isinstance, so the result includes also derived types. For example circuit.getblocks(edzed.SBlock) returns all sequential circuit blocks.

Without going into details about iterators and iterables, the result can be directly used in a for blk in getblocks(btype): loop or in a if blk in getblocks(btype): test, but if the result is going to be stored for later use, it should be converted to a list or a set.

Changed in version 24.3.4: The default btype value changed from None (meaning Block) directly to Block.

Circuit.findblock(name: str) Block

Get block by name. Raise a KeyError when not found.

Inspecting blocks

This section summarizes attributes and methods providing various block information. The application code should not modify any attributes listed here.

Block.oconnections: set[CBlock]

Set of all blocks where the output is connected to. The contents of the set are undefined before the circuit finalization - see Circuit.finalize().

For other attributes common to all blocks refer to the base class Block.

Inspecting SBlocks

SBlock.get_state() Any

Return the internal state.

Warning

The internal state is usually not defined before a successful initialization. Do not call get_state() on uninitialized blocks. It may raise or trigger assertion errors. See related Block.is_initialized() below and Circuit.wait_init().

The format and semantics of returned data depends on the block type.

Block.is_initialized() bool

Return True only if the block has been initialized.

This method simply checks if the output is not UNDEF relying on the fact that sequential block’s output is determined by its internal state.

Note

This method is defined for all blocks, but the test is helpful for sequential blocks only.

Inspecting CBlocks

CBlock.iconnections: set[Block]

A set of all blocks connected to inputs. The contents of the set are undefined before the circuit finalization - see Circuit.finalize().

CBlock.inputs: dict[str, Block | Const | tuple[Block | Const, ...]]

Block’s input connections as a dict, where keys are input names and values are:

  • either a single Block or a Const,

  • or tuples of blocks or Consts for input groups.

The structure directly corresponds to parameters given to CBlock.connect().

The same data, but with block names instead of block objects, can be obtained with Block.get_conf(); extract the 'inputs' value from the result.

The contents of the dict are undefined before the circuit finalization - see Circuit.finalize().

See also

Input signatures

Version information

edzed.__version__: str

edzed version as a string, e.g. “22.11.28”

New in version 22.11.28.

edzed.__version_info__: tuple[int]

edzed version as a tuple of three numbers, e.g. (22, 11, 28). The version numbers are derived from the release date: year-2000, month, day.

New in version 22.11.28.