sf.program_utils

Warning

Unless you are a Strawberry Fields developer, you likely do not need to use these classes directly.

See the general Program class for details on creating a Strawberry Fields program.

This module contains various utility classes and functions used within the Program class.

Functions

list_to_grid(ls)

Transforms a list of Commands to a grid representation.

grid_to_DAG(grid)

Transforms a grid of Commands to a DAG representation.

DAG_to_list(dag)

Transforms a Command DAG to a list representation.

list_to_DAG(ls)

Transforms a list of Commands to a DAG representation.

group_operations(seq, predicate)

Group a set of Operations in a circuit together (if possible).

optimize_circuit(seq)

Try to simplify and optimize a quantum circuit.

Classes

RegRefError

Exception raised by Program when it encounters an invalid register reference.

CircuitError

Exception raised by Program when it encounters an illegal operation in the quantum circuit.

MergeFailure

Exception raised by strawberryfields.ops.Operation.merge() when an attempted merge fails.

Command(op, reg)

Represents a quantum operation applied on specific subsystems of the register.

RegRef(ind)

Quantum register reference.

Variables

Program_current_context

Context for inputting a Program.