cirq.ops.NamedQubit

A qubit identified by name.

Inherits From: Qid

Used in the notebooks

Used in the tutorials

By default, NamedQubit has a lexicographic order. However, numbers within the name are handled correctly. So, for example, if you print a circuit containing cirq.NamedQubit('qubit22') and cirq.NamedQubit('qubit3'), the wire for 'qubit3' will correctly come before 'qubit22'.

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

Methods

range

View source

Returns a range of NamedQubit\s.

The range returned starts with the prefix, and followed by a qubit for each number in the range, e.g.:

    cirq.NamedQubit.range(3, prefix='a')
    # doctest: +NORMALIZE_WHITESPACE
        [cirq.NamedQubit('a0'), cirq.NamedQubit('a1'),
            cirq.NamedQubit('a2')]
    cirq.NamedQubit.range(2, 4, prefix='a')
        [cirq.NamedQubit('a2'), cirq.NamedQubit('a3')]
        

Args
*args Args to be passed to Python's standard range function.
prefix A prefix for constructed NamedQubits.

Returns
A list of NamedQubit\s.

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.