qiskit-documentation/docs/api/qiskit/0.45/qiskit.circuit.Qubit.mdx

54 lines
2.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Qubit
description: API reference for qiskit.circuit.Qubit
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.circuit.Qubit
---
# Qubit
<Class id="qiskit.circuit.Qubit" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.45/qiskit/circuit/quantumregister.py" signature="qiskit.circuit.Qubit(register=None, index=None)" modifiers="class">
Bases: [`Bit`](qiskit.circuit.Bit "qiskit.circuit.bit.Bit")
Implement a quantum bit.
Creates a qubit.
**Parameters**
* **register** ([*QuantumRegister*](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")) Optional. A quantum register containing the bit.
* **index** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")) Optional. The index of the bit in its containing register.
**Raises**
[**CircuitError**](circuit#qiskit.circuit.CircuitError "qiskit.circuit.CircuitError") if the provided register is not a valid [`QuantumRegister`](qiskit.circuit.QuantumRegister "qiskit.circuit.QuantumRegister")
## Attributes
### index
<Attribute id="qiskit.circuit.Qubit.index">
Get the index of an old-style bit in the register that owns it.
In modern Qiskit Terra (version 0.17+), bits are the fundamental object and registers are aliases to collections of bits. A bit can be in many registers depending on the circuit, so a single containing register is no longer a property of a bit. It is an error to access this attribute on bits that were not constructed as “owned” by a register.
<Admonition title="Deprecated since version 0.17" type="danger">
The property `qiskit.circuit.bit.Bit.index` is deprecated as of qiskit-terra 0.17. It will be removed no earlier than 3 months after the release date. Instead, use `find_bit()` to find all the containing registers within a circuit and the index of the bit within the circuit.
</Admonition>
</Attribute>
### register
<Attribute id="qiskit.circuit.Qubit.register">
Get the register of an old-style bit.
In modern Qiskit Terra (version 0.17+), bits are the fundamental object and registers are aliases to collections of bits. A bit can be in many registers depending on the circuit, so a single containing register is no longer a property of a bit. It is an error to access this attribute on bits that were not constructed as “owned” by a register.
<Admonition title="Deprecated since version 0.17" type="danger">
The property `qiskit.circuit.bit.Bit.register` is deprecated as of qiskit-terra 0.17. It will be removed no earlier than 3 months after the release date. Instead, use `find_bit()` to find all the containing registers within a circuit and the index of the bit within the circuit.
</Admonition>
</Attribute>
</Class>