comnum.LinkBlock#

class comnum.LinkBlock(spec, *, fiber=None, name=None, condition=None, base_dir=None)#

One block of the registry of declarative links (see spec_blocks()), built from its specification {"type": ..., <parameters>}.

Parameters:
  • spec (dict) – the block, its type and its parameters (no variable left).

  • fiber (dict, optional) – the fiber of the specification, for the optical blocks.

  • name (str, optional) – the name of the campaign, for the blocks that write files.

  • condition (dict, optional) – the condition, labelled as the Rust runner labels it (k=v, k=v), for the blocks that write files.

  • base_dir (str | os.PathLike, optional) – the directory the relative paths of the block are resolved against (the directory of its specification file).

Raises:

ValueError – for an invalid parameter or input (the message names it).

Examples

>>> import comnum
>>> f = comnum.Frame()
>>> comnum.LinkBlock({"type": "source", "constellation": "QPSK", "n_symbols": 8}).apply(f, comnum.Rng(1))
>>> f.samples.size
8
apply(frame, rng)#

Apply the block to a frame in place.

Parameters:
  • frame (Frame) – the frame, modified.

  • rng (Rng) – the generator of the block.

Raises:

ValueError – for an invalid parameter (the message names it).