mindquantum.device.QubitNode#
- class mindquantum.device.QubitNode(qubit_id: int, color: str = '#000000', poi_x: float = 0.0, poi_y: float = 0.0)#
Qubit node.
A qubit node has a id, a position and a color (if you want to draw it). You can connect two qubits with ‘>>’ or ‘<<’ and disconnect two qubits with ‘<’ or ‘>’.
- Parameters:
qubit_id (int) – the identity number of this qubit.
color (str) – the face color of this qubit.
poi_x (float) – x position in canvas.
poi_y (float) – y position in canvas.
Examples
>>> from mindquantum.device import QubitNode >>> q0 = QubitNode(0) >>> q1 = QubitNode(1) >>> q = q0 << q1 >>> q0.qubit_id == q.qubit_id True
- property color: str#
Get the color of this qubit.
- Returns:
str, the color of qubit node.
- property poi_x: float#
X position of this qubit.
- Returns:
float, the x position.
- property poi_y: float#
Y position of this qubit.
- Returns:
float, the y position.
- property qubit_id: int#
Get the id of this qubit.
- Returns:
int, the id of this qubit.
- set_color(color: str) None#
Set the color of this qubit.
- Parameters:
color (str) – The new color.
Examples
>>> from mindquantum.device import QubitNode >>> q0 = QubitNode(1) >>> q0.set_color('#ababab') >>> q0.color '#ababab'
- set_poi(poi_x: float, poi_y: float) None#
Set the position of this qubit.
- Parameters:
poi_x (float) – x position of qubit in canvas.
poi_y (float) – y position of qubit in canvas.
Examples
>>> from mindquantum.device import QubitNode >>> q0 = QubitNode(1, poi_x=0, poi_y=1) >>> q0.set_poi(1, 0) >>> print(q0.poi_x, q0.poi_y) 1 0