cirq.Qid

Identifies a quantum object such as a qubit, qudit, resonator, etc.

Child classes represent specific types of objects, such as a qubit at a particular location on a chip or a qubit with a particular name.

The main criteria that a custom qid must satisfy is comparability. Child classes meet this criteria by implementing the _comparison_key method. For example, cirq.LineQubit's _comparison_key method returns self.x. This ensures that line qubits with the same x are equal, and that line qubits will be sorted ascending by x. Qid implements all equality, comparison, and hashing methods via _comparison_key.

dimension Returns the dimension or the number of quantum levels this qid has. E.g. 2 for a qubit, 3 for a qutrit, etc.

Methods

validate_dimension

View source

Raises an exception if dimension is not positive.

Raises
ValueError dimension is not positive.

with_dimension

View source

Returns a new qid with a different dimension.

Child classes can override. Wraps the qubit object by default.

Args
dimension The new dimension or number of levels.

__eq__

View source

Return self==value.

__ge__

View source

Return self>=value.

__gt__

View source

Return self>value.

__le__

View source

Return self<=value.

__lt__

View source

Return self<value.

__ne__

View source

Return self!=value.