quirk_url_to_circuit: Quirk url to circuit

Description Usage Arguments Value Raises See Also

View source: R/Importing_Exporting.R

Description

Parses a Cirq circuit out of a Quirk URL.

Usage

1
quirk_url_to_circuit(quirk_url, qubits, extra_cell_makers, max_operation_count)

Arguments

quirk_url

The URL of a bookmarked Quirk circuit. It is not required that the domain be "algassert.com/quirk". The only important part of the URL is the fragment (the part after the #).

qubits

Qubits to use in the circuit. The length of the list must be at least the number of qubits in the Quirk circuit (including unused qubits). The maximum number of qubits in a Quirk circuit is 16. This argument defaults to line_qubit_range(16) when not specified.

extra_cell_makers

Non-standard Quirk cells to accept. This can be used to parse URLs that come from a modified version of Quirk that includes gates that Quirk doesn’t define. This can be specified as either a list of cirq.interop.quirk.cells.CellMaker instances, or for more simple cases as a dictionary from a Quirk id string to a cirq Gate.

max_operation_count

If the number of operations in the circuit would exceed this value, the method raises a ValueError instead of attempting to construct the circuit. This is important to specify for servers parsing unknown input, because Quirk’s format allows for a billion laughs attack in the form of nested custom gates.

Value

The parsed circuit.

Raises

ValueError: Invalid circuit URL, or circuit would be larger than 'max_operations_count'.

See Also

Other Importing and Exporting: quirk_json_to_circuit()


henry090/Cirq documentation built on June 13, 2020, 1:28 a.m.