ClassicalFunction

class ClassicalFunction(source, name=None)[source]

Represent a classical function function and its logic network.

Creates a ClassicalFunction from Python source code in source.

The code should be a single function with types.

Parameters
  • source (str) – Python code with type hints.

  • name (str) – Optional. Default: “classicalfunction”. ClassicalFunction name.

Raises
  • ImportError – If tweedledum is not installed.

  • QiskitError – If source is not a string.

Attributes

ClassicalFunction.args

Returns the classicalfunction arguments

ClassicalFunction.decompositions

Get the decompositions of the instruction from the SessionEquivalenceLibrary.

ClassicalFunction.definition

Return definition in terms of other basic gates.

ClassicalFunction.duration

Get the duration.

ClassicalFunction.label

Return gate label

ClassicalFunction.network

Returns the logical network

ClassicalFunction.params

return instruction params.

ClassicalFunction.qregs

The list of qregs used by the classicalfunction

ClassicalFunction.scopes

Returns the scope dict

ClassicalFunction.types

Dumps a list of scopes with their variables and types.

ClassicalFunction.unit

Get the time unit of duration.

Methods

ClassicalFunction.add_decomposition(…)

Add a decomposition of the instruction to the SessionEquivalenceLibrary.

ClassicalFunction.assemble()

Assemble a QasmQobjInstruction

ClassicalFunction.broadcast_arguments(qargs, …)

Validation and handling of the arguments and its relationship.

ClassicalFunction.c_if(classical, val)

Add classical condition on register classical and value val.

ClassicalFunction.compile()

Parses and creates the logical circuit

ClassicalFunction.control([num_ctrl_qubits, …])

Return controlled version of gate.

ClassicalFunction.copy([name])

Copy of the instruction.

ClassicalFunction.inverse()

Invert this instruction.

ClassicalFunction.is_parameterized()

Return True .IFF.

ClassicalFunction.mirror()

DEPRECATED: use instruction.reverse_ops().

ClassicalFunction.power(exponent)

Creates a unitary gate as gate^exponent.

ClassicalFunction.qasm()

Return a default OpenQASM string for the instruction.

ClassicalFunction.repeat(n)

Creates an instruction with gate repeated n amount of times.

ClassicalFunction.reverse_ops()

For a composite instruction, reverse the order of sub-instructions.

ClassicalFunction.simulate()

Runs tweedledum.simulate on the logic network.

ClassicalFunction.synth([registerless])

Synthesis the logic network into a QuantumCircuit.

ClassicalFunction.to_matrix()

Return a Numpy.array for the gate unitary matrix.

ClassicalFunction.validate_parameter(parameter)

Gate parameters should be int, float, or ParameterExpression