Instruction#

class Instruction(*, params: dict | None = None, extra_params: dict | None = None)#

Base class for all instructions.

Parameters:
  • params – Mapping of parameters specified by the users.

  • extra_params – Mapping of extra parameters, typically calculated ones.

property params: dict#

The parameters of the instruction as a dict.

property modes: Tuple[int, ...]#

The qumodes on which the instruction is applied.

on_modes(*modes: int) Instruction#

Specifies the modes on which the state should be executed.

Returns:

The same instruction with the modes specified.

Return type:

Instruction

classmethod from_dict(dict_: dict) Instruction#

Creates an Instruction instance from a dict specified.

Parameters:

dict (dict) – The desired Instruction instance in the format of a dict.

Returns:

An Instruction initialized using the specified dict.

Return type:

Instruction

classmethod set_subclass(instruction: Type[Instruction]) None#

Registers a class in the instruction subclass map.

This is meaningful in contexts when one has multiple instructions with the same name.

Example

When one creates a custom beamsplitter with name Beamsplitter and subclasses Beamsplitter, then for e.g. executing a Blackbird code will be performed with the custom one, not the original one. When one wants to use the original one in this case, one can reset it with this method.

Parameters:

instruction (Type[Instruction]) – The instruction class to be registered.

Raises:

PiquassoException – When the class is not actually an instance of Insruction.

classmethod get_subclass(name: str) Type[Instruction]#

Returns the instruction subclass specified by its name.

Returns:

The instruction class.

Return type:

Type[Instruction]

class BatchInstruction(*, params: dict | None = None, extra_params: dict | None = None)#

Base class to control batch processing.

class Preparation(*, params: dict | None = None, extra_params: dict | None = None)#

Base class for preparations.

class Gate(*, params: dict | None = None, extra_params: dict | None = None)#

Base class for gates.

class Measurement(*, params: dict | None = None, extra_params: dict | None = None)#

Base class for measurements.