Instruction#

class Instruction(*, params: Optional[dict] = None, extra_params: Optional[dict] = None)#

Base class for all instructions.

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

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

classmethod from_dict(dict_: dict) piquasso.api.instruction.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[piquasso.api.instruction.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[piquasso.api.instruction.Instruction]#

Returns the instruction subclass specified by its name.

Returns

The instruction class.

Return type

Type[Instruction]

class Preparation(*, params: Optional[dict] = None, extra_params: Optional[dict] = None)#

Base class for preparations.

class Gate(*, params: Optional[dict] = None, extra_params: Optional[dict] = None)#

Base class for gates.

class Measurement(*, params: Optional[dict] = None, extra_params: Optional[dict] = None)#

Base class for measurements.