|View source on GitHub|
A fake device that was created to ensure certain Device validation features are
cirq.testing.ValidatingTestDevice( qubits: AbstractSet[
cirq.ops.Qid], name: str = 'ValidatingTestDevice', allowed_gates: Tuple[type, ...] = (ops.Gate,), allowed_qubit_types: Tuple[type, ...] = (devices.GridQubit,), validate_locality: bool = False, auto_decompose_gates: Tuple[type, ...] = tuple() )
leveraged in Circuit functions. It contains the minimum set of features that tests require. Feel free to extend the features here as needed.
||set of qubits on this device|
||the name for repr|
||tuple of allowed gate types|
||tuple of allowed qubit types|
||if True, device will validate 2 qubit operations (except MeasurementGateOperations) whether the two qubits are adjacent. If True, GridQubits are assumed to be part of the allowed_qubit_types|
||when set, for given gates it calls the cirq.decompose protocol|
can_add_operation_into_moment( operation: "cirq.Operation", moment: "cirq.Moment" ) -> bool
Determines if it's possible to add an operation into a moment.
For example, on the XmonDevice two CZs shouldn't be placed in the same moment if they are on adjacent qubits.
||The operation being added.|
||The moment being transformed.|
|Whether or not the moment will validate after adding the operation.|
decompose_operation( operation: "ops.Operation" ) -> "ops.OP_TREE"
Returns a device-valid decomposition for the given operation.
This method is used when adding operations into circuits with a device specified, to avoid spurious failures due to e.g. using a Hadamard gate that must be decomposed into native gates.
qubit_set() -> Optional[AbstractSet['cirq.Qid']]
Returns a set or frozenset of qubits on the device, if possible.
If the device has a finite set of qubits, then a set or frozen set
of all qubits on the device is returned.
If the device has no well defined finite set of qubits (e.g.
validate_circuit( circuit: "cirq.Circuit" ) -> None
Raises an exception if a circuit is not valid.
||The circuit to validate.|
||The circuit isn't valid for this device.|
validate_moment( moment: "cirq.Moment" ) -> None
Raises an exception if a moment is not valid.
||The moment to validate.|
||The moment isn't valid for this device.|
cirq.ops.Operation) -> None
Raises an exception if an operation is not valid.
||The operation to validate.|
||The operation isn't valid for this device.|