comnum.Native#

class comnum.Native(kind: str, /, **params: Any)#

A block of the registry of declarative links, Native("awgn_ebn0", ebn0_db=10); the classes of comnum.blocks build them.

Parameters:
  • kind (str) – the type of the block (positional only: a block may have a parameter of that name, as pulse_shape).

  • **params – its parameters; var() makes one a grid variable.

Example

>>> import comnum
>>> comnum.Native("awgn_ebn0", ebn0_db=10).spec("channel")
{'type': 'awgn_ebn0', 'label': 'channel', 'ebn0_db': 10}
bind(condition: Mapping[str, Any] | None, *, fiber: Mapping[str, Any] | None = None, name: str | None = None, label: str | None = None, profile: bool = False, base_dir: str | PathLike[str] | None = None) → Callable[[Frame, Rng], None]#

The block of a condition, built by the Rust registry (see Block.bind()): label is its name in the chain, name the campaign, and the condition is labelled as the Rust runner does, for the blocks that report or write files under their label (probe, dump).

Parameters:
  • condition (dict | None) – the values of the grid variables.

  • fiber (dict | None) – the fiber of the specification.

  • name (str | None) – the name of the campaign.

  • label (str | None) – the name of the block in the chain.

  • profile (bool) – unused (a single block).

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

Returns:

the apply method of a LinkBlock.

Return type:

Callable[[Frame, Rng], None]

Example

>>> import comnum
>>> from comnum import blocks as B
>>> apply = B.AwgnEbn0(ebn0_db=comnum.var("x")).bind({"x": 5.0})
>>> callable(apply)
True
spec(label: str | None = None) → dict[str, Any]#

The block as it appears in a specification.

Parameters:

label (str | None) – its name in the chain (kept when it differs from the type; an explicit label parameter, a probe’s, wins).

Returns:

{"type": …, "label": …, <parameters>}.

Return type:

dict