cirq.testing.ValidatingTestDevice

A fake device that was created to ensure certain Device validation features are

Inherits From: Device

leveraged in Circuit functions. It contains the minimum set of features that tests require. Feel free to extend the features here as needed.

qubits set of qubits on this device
name the name for repr
allowed_gates tuple of allowed gate types
allowed_qubit_types tuple of allowed qubit types
validate_locality 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
auto_decompose_gates when set, for given gates it calls the cirq.decompose protocol

metadata Returns the associated Metadata with the device if applicable.

Methods

can_add_operation_into_moment

View source

THIS FUNCTION IS DEPRECATED.

IT WILL BE REMOVED IN cirq v0.15.

can_add_operation_into_moment will be removed in the future. Consider using device.validate_circuit instead.

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.

    Args:
        operation: The operation being added.
        moment: The moment being transformed.

    Returns:
        Whether or not the moment will validate after adding the operation.

decompose_operation

View source

THIS FUNCTION IS DEPRECATED.

IT WILL BE REMOVED IN cirq v0.15.

Devices will no longer decompose operations.

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.

qid_pairs

View source

THIS FUNCTION IS DEPRECATED.

IT WILL BE REMOVED IN cirq v0.15.

qubit coupling data can now be found in device.metadata if provided.

Returns a set of qubit edges on the device, if possible.

    This property can be overridden in child classes for special handling.
    The default handling is: GridQids and LineQids will have neighbors as
    edges, and others will be fully connected.

    Returns:
        If the device has a finite set of qubits, then a set of all edges
        on the device is returned.

        If the device has no well defined finite set of qubits (e.g.
        `cirq.UnconstrainedDevice` has this property), then `None` is
        returned.

qubit_set

View source

THIS FUNCTION IS DEPRECATED.

IT WILL BE REMOVED IN cirq v0.15.

Use metadata.qubit_set if applicable.

Returns a set or frozenset of qubits on the device, if possible.

    Returns:
        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.
        `cirq.UnconstrainedDevice` has this property), then `None` is
        returned.

validate_circuit

View source

Raises an exception if a circuit is not valid.

Args
circuit The circuit to validate.

Raises
ValueError The circuit isn't valid for this device.

validate_moment

View source

Raises an exception if a moment is not valid.

Args
moment The moment to validate.

Raises
ValueError The moment isn't valid for this device.

validate_operation

View source

Raises an exception if an operation is not valid.

Args
operation The operation to validate.

Raises
ValueError The operation isn't valid for this device.