pyquil.quilbase

Contains the core pyQuil objects that correspond to Quil instructions.

class pyquil.quilbase.AbstractInstruction

Bases: object

Abstract class for representing single instructions.

out()
class pyquil.quilbase.BinaryClassicalInstruction(left, right)

Bases: pyquil.quilbase.AbstractInstruction

The abstract class for binary classical instructions.

out()
class pyquil.quilbase.ClassicalAnd(left, right)

Bases: pyquil.quilbase.BinaryClassicalInstruction

op = 'AND'
class pyquil.quilbase.ClassicalExchange(left, right)

Bases: pyquil.quilbase.BinaryClassicalInstruction

op = 'EXCHANGE'
class pyquil.quilbase.ClassicalFalse(target)

Bases: pyquil.quilbase.UnaryClassicalInstruction

op = 'FALSE'
class pyquil.quilbase.ClassicalMove(left, right)

Bases: pyquil.quilbase.BinaryClassicalInstruction

op = 'MOVE'
class pyquil.quilbase.ClassicalNot(target)

Bases: pyquil.quilbase.UnaryClassicalInstruction

op = 'NOT'
class pyquil.quilbase.ClassicalOr(left, right)

Bases: pyquil.quilbase.BinaryClassicalInstruction

op = 'OR'
class pyquil.quilbase.ClassicalTrue(target)

Bases: pyquil.quilbase.UnaryClassicalInstruction

op = 'TRUE'
class pyquil.quilbase.DefGate(name, matrix, parameters=None)

Bases: pyquil.quilbase.AbstractInstruction

A DEFGATE directive.

Parameters:
  • name (string) – The name of the newly defined gate.
  • matrix (array-like) – {list, nparray, np.matrix} The matrix defining this gate.
  • parameters (list) – list of parameters that are used in this gate
get_constructor()
Returns:A function that constructs this gate on variable qubit indices. E.g. mygate.get_constructor()(1) applies the gate to qubit 1.
num_args()
Returns:The number of qubit arguments the gate takes.
Return type:int
out()

Prints a readable Quil string representation of this gate.

Returns:String representation of a gate
Return type:string
class pyquil.quilbase.Gate(name, params, qubits)

Bases: pyquil.quilbase.AbstractInstruction

This is the pyQuil object for a quantum gate instruction.

out()
class pyquil.quilbase.Halt

Bases: pyquil.quilbase.SimpleInstruction

The HALT instruction.

op = 'HALT'
class pyquil.quilbase.Jump(target)

Bases: pyquil.quilbase.AbstractInstruction

Representation of an unconditional jump instruction (JUMP).

out()
class pyquil.quilbase.JumpConditional(target, condition)

Bases: pyquil.quilbase.AbstractInstruction

Abstract representation of an conditional jump instruction.

out()
class pyquil.quilbase.JumpTarget(label)

Bases: pyquil.quilbase.AbstractInstruction

Representation of a target that can be jumped to.

out()
class pyquil.quilbase.JumpUnless(target, condition)

Bases: pyquil.quilbase.JumpConditional

The JUMP-UNLESS instruction.

op = 'JUMP-UNLESS'
class pyquil.quilbase.JumpWhen(target, condition)

Bases: pyquil.quilbase.JumpConditional

The JUMP-WHEN instruction.

op = 'JUMP-WHEN'
class pyquil.quilbase.Measurement(qubit, classical_reg=None)

Bases: pyquil.quilbase.AbstractInstruction

This is the pyQuil object for a Quil measurement instruction.

out()
class pyquil.quilbase.Nop

Bases: pyquil.quilbase.SimpleInstruction

The RESET instruction.

op = 'NOP'
class pyquil.quilbase.Pragma(command, args=(), freeform_string='')

Bases: pyquil.quilbase.AbstractInstruction

A PRAGMA instruction.

This is printed in QUIL as:

PRAGMA <command> <arg1> <arg2> ... <argn> "<freeform_string>"
out()
class pyquil.quilbase.RawInstr(instr_str)

Bases: pyquil.quilbase.AbstractInstruction

A raw instruction represented as a string.

out()
class pyquil.quilbase.Reset

Bases: pyquil.quilbase.SimpleInstruction

The RESET instruction.

op = 'RESET'
class pyquil.quilbase.SimpleInstruction

Bases: pyquil.quilbase.AbstractInstruction

Abstract class for simple instructions with no arguments.

out()
class pyquil.quilbase.UnaryClassicalInstruction(target)

Bases: pyquil.quilbase.AbstractInstruction

The abstract class for unary classical instructions.

out()
class pyquil.quilbase.Wait

Bases: pyquil.quilbase.SimpleInstruction

The WAIT instruction.

op = 'WAIT'