cirq.quirk_json_to_circuit
Constructs a Cirq circuit from Quirk's JSON format.
cirq.quirk_json_to_circuit(
data: dict,
*,
qubits: Optional[Sequence['cirq.Qid']] = None,
extra_cell_makers: Union[Dict[str, 'cirq.Gate'], Iterable['cirq.interop.quirk.cells.CellMaker']] = (),
quirk_url: Optional[str] = None,
max_operation_count: int = (10 ** 6)
) -> 'cirq.Circuit'
Used in the notebooks
Args |
data
|
Data parsed from quirk's JSON representation.
|
qubits
|
Qubits to use in the circuit. See quirk_url_to_circuit.
|
extra_cell_makers
|
Non-standard Quirk cells to accept. See
quirk_url_to_circuit.
|
quirk_url
|
If given, the original URL from which the JSON was parsed, as
described in quirk_url_to_circuit.
|
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.
|
Examples:
print(cirq.quirk_json_to_circuit(
{"cols":[["H"], ["•", "X"]]}
))
0: ───H───@───
│
1: ───────X───
Returns |
The parsed circuit.
|
Raises |
ValueError
|
Invalid circuit URL, or circuit would be larger than
max_operations_count .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-06-27 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-06-27 UTC."],[],[]]