quantum-emotion 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quantum_emotion-0.1.0/PKG-INFO +59 -0
- quantum_emotion-0.1.0/README.md +40 -0
- quantum_emotion-0.1.0/pyproject.toml +62 -0
- quantum_emotion-0.1.0/pyproject.toml.orig +50 -0
- quantum_emotion-0.1.0/src/quantum_emotion/__init__.py +57 -0
- quantum_emotion-0.1.0/src/quantum_emotion/_register.py +580 -0
- quantum_emotion-0.1.0/src/quantum_emotion/core.py +2056 -0
- quantum_emotion-0.1.0/src/quantum_emotion/gates.py +506 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/__init__.py +1 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/circuit_tests.py +387 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/gate_addition_tests.py +166 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/gate_tests.py +476 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/mid_circuit_measurement_tests.py +536 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/modular_gate_tests.py +86 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/module_structure_tests.py +187 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/outer_product_tests.py +137 -0
- quantum_emotion-0.1.0/src/quantum_emotion/tests/state_tests.py +55 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: quantum-emotion
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Classical simulation of quantum circuits.
|
|
5
|
+
Author: Tanishka Birdavade, Hendrik Kuehne, Matthew Howarth
|
|
6
|
+
Author-email: Tanishka Birdavade <tanishka.birdavade.22@ucl.ac.uk>, Hendrik Kuehne <hendrik.kuehne.26@ucl.ac.uk>, Matthew Howarth <matthew.howarth.26@ucl.ac.uk>
|
|
7
|
+
Requires-Dist: cotengra>=0.8.3
|
|
8
|
+
Requires-Dist: matplotlib>=3.11.2
|
|
9
|
+
Requires-Dist: networkx>=3.7
|
|
10
|
+
Requires-Dist: numpy>=2.5.4
|
|
11
|
+
Requires-Dist: scipy>=1.18.1
|
|
12
|
+
Requires-Dist: tqdm>=4.70.1
|
|
13
|
+
Requires-Dist: mkdocs>=1.6.1 ; extra == 'docs'
|
|
14
|
+
Requires-Dist: mkdocs-material>=9.7.7 ; extra == 'docs'
|
|
15
|
+
Requires-Dist: mkdocstrings[python]>=1.0.8 ; extra == 'docs'
|
|
16
|
+
Requires-Python: >=3.13
|
|
17
|
+
Provides-Extra: docs
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
[](https://github.com/QC2-python-SE/quantum-emotion/actions/workflows/tests.yml)
|
|
21
|
+
|
|
22
|
+
<img src="logo.png" alt="Logo" width="25%">
|
|
23
|
+
|
|
24
|
+
The `quantum-emotion` package provides educational tools for quantum circuit simulation. Users may...
|
|
25
|
+
|
|
26
|
+
+ assemble quantum circuits using a variety of gates, including mid-circuit measurements and classical control,
|
|
27
|
+
+ visualise circuits,
|
|
28
|
+
+ calculate the quantum states that circuits produce, or get access to probability distributions over mid-circuit measurements,
|
|
29
|
+
+ add their own gates.
|
|
30
|
+
|
|
31
|
+
Under the hood, a quantum circuit is represented by a tensor network. Adding an operation to the circuit corresponds to connecting another tensor to the network, and calculating quantum states means contracting the entire tensor network.
|
|
32
|
+
|
|
33
|
+
# Getting Started
|
|
34
|
+
|
|
35
|
+
`quantum-emotion` may be installed from PyPi:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
pip install quantum-emotion
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The package is designed to closely follow the way in which quantum states and operators behave mathematically. As a result, assembling a circuit looks just like matrix multiplication. Consider for example a circuit that produces the Bell state $\frac{1}{\sqrt{2}} (|00\rangle + |11\rangle)$:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import matplotlib.pyplot as plt
|
|
45
|
+
from quantum_emotion import KetState, Hadamard, CNOT
|
|
46
|
+
|
|
47
|
+
# Create the quantum state and apply the circuit
|
|
48
|
+
psi0 = KetState(N=2)
|
|
49
|
+
psi_final = CNOT(wires=(0, 1)) @ Hadamard(wires=0) @ psi0
|
|
50
|
+
|
|
51
|
+
# Calculate the output state
|
|
52
|
+
print(psi_final.eval())
|
|
53
|
+
|
|
54
|
+
# Plot the circuit
|
|
55
|
+
ax = psi_final.plot()
|
|
56
|
+
plt.show()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
More examples, along with tutorials on how to use all aspects of `quantum-emotion`, can be found in [`notebooks/`](https://github.com/QC2-python-SE/quantum-emotion/tree/main/notebooks).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[](https://github.com/QC2-python-SE/quantum-emotion/actions/workflows/tests.yml)
|
|
2
|
+
|
|
3
|
+
<img src="logo.png" alt="Logo" width="25%">
|
|
4
|
+
|
|
5
|
+
The `quantum-emotion` package provides educational tools for quantum circuit simulation. Users may...
|
|
6
|
+
|
|
7
|
+
+ assemble quantum circuits using a variety of gates, including mid-circuit measurements and classical control,
|
|
8
|
+
+ visualise circuits,
|
|
9
|
+
+ calculate the quantum states that circuits produce, or get access to probability distributions over mid-circuit measurements,
|
|
10
|
+
+ add their own gates.
|
|
11
|
+
|
|
12
|
+
Under the hood, a quantum circuit is represented by a tensor network. Adding an operation to the circuit corresponds to connecting another tensor to the network, and calculating quantum states means contracting the entire tensor network.
|
|
13
|
+
|
|
14
|
+
# Getting Started
|
|
15
|
+
|
|
16
|
+
`quantum-emotion` may be installed from PyPi:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
pip install quantum-emotion
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The package is designed to closely follow the way in which quantum states and operators behave mathematically. As a result, assembling a circuit looks just like matrix multiplication. Consider for example a circuit that produces the Bell state $\frac{1}{\sqrt{2}} (|00\rangle + |11\rangle)$:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import matplotlib.pyplot as plt
|
|
26
|
+
from quantum_emotion import KetState, Hadamard, CNOT
|
|
27
|
+
|
|
28
|
+
# Create the quantum state and apply the circuit
|
|
29
|
+
psi0 = KetState(N=2)
|
|
30
|
+
psi_final = CNOT(wires=(0, 1)) @ Hadamard(wires=0) @ psi0
|
|
31
|
+
|
|
32
|
+
# Calculate the output state
|
|
33
|
+
print(psi_final.eval())
|
|
34
|
+
|
|
35
|
+
# Plot the circuit
|
|
36
|
+
ax = psi_final.plot()
|
|
37
|
+
plt.show()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
More examples, along with tutorials on how to use all aspects of `quantum-emotion`, can be found in [`notebooks/`](https://github.com/QC2-python-SE/quantum-emotion/tree/main/notebooks).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "quantum-emotion"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Classical simulation of quantum circuits."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"cotengra>=0.8.3",
|
|
9
|
+
"matplotlib>=3.11.2",
|
|
10
|
+
"networkx>=3.7",
|
|
11
|
+
"numpy>=2.5.4",
|
|
12
|
+
"scipy>=1.18.1",
|
|
13
|
+
"tqdm>=4.70.1",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[[project.authors]]
|
|
17
|
+
name = "Tanishka Birdavade"
|
|
18
|
+
email = "tanishka.birdavade.22@ucl.ac.uk"
|
|
19
|
+
|
|
20
|
+
[[project.authors]]
|
|
21
|
+
name = "Hendrik Kuehne"
|
|
22
|
+
email = "hendrik.kuehne.26@ucl.ac.uk"
|
|
23
|
+
|
|
24
|
+
[[project.authors]]
|
|
25
|
+
name = "Matthew Howarth"
|
|
26
|
+
email = "matthew.howarth.26@ucl.ac.uk"
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
docs = [
|
|
30
|
+
"mkdocs>=1.6.1",
|
|
31
|
+
"mkdocs-material>=9.7.7",
|
|
32
|
+
"mkdocstrings[python]>=1.0.8",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
37
|
+
build-backend = "uv_build"
|
|
38
|
+
|
|
39
|
+
[dependency-groups]
|
|
40
|
+
dev = [
|
|
41
|
+
"asttokens>=3.0.2",
|
|
42
|
+
"pytest>=9.2.0",
|
|
43
|
+
"ruff>=0.17.3",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
testpaths = ["src/quantum_emotion/tests"]
|
|
48
|
+
python_files = [
|
|
49
|
+
"test_*.py",
|
|
50
|
+
"*_tests.py",
|
|
51
|
+
"*_test.py",
|
|
52
|
+
]
|
|
53
|
+
pythonpath = ["src"]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
line-length = 79
|
|
57
|
+
|
|
58
|
+
[tool.ruff.lint]
|
|
59
|
+
ignore = [
|
|
60
|
+
"FLY002",
|
|
61
|
+
"TRY004",
|
|
62
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "quantum-emotion"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Classical simulation of quantum circuits."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Tanishka Birdavade", email = "tanishka.birdavade.22@ucl.ac.uk" },
|
|
8
|
+
{ name = "Hendrik Kuehne", email = "hendrik.kuehne.26@ucl.ac.uk" },
|
|
9
|
+
{ name = "Matthew Howarth", email = "matthew.howarth.26@ucl.ac.uk" },
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.13"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"cotengra>=0.8.3",
|
|
14
|
+
"matplotlib>=3.11.2",
|
|
15
|
+
"networkx>=3.7",
|
|
16
|
+
"numpy>=2.5.4",
|
|
17
|
+
"scipy>=1.18.1",
|
|
18
|
+
"tqdm>=4.70.1",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
docs = [
|
|
23
|
+
"mkdocs>=1.6.1",
|
|
24
|
+
"mkdocs-material>=9.7.7",
|
|
25
|
+
"mkdocstrings[python]>=1.0.8",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[build-system]
|
|
29
|
+
requires = ["uv_build>=0.13.1,<0.14.0"]
|
|
30
|
+
build-backend = "uv_build"
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
dev = [
|
|
34
|
+
"asttokens>=3.0.2",
|
|
35
|
+
"pytest>=9.2.0",
|
|
36
|
+
"ruff>=0.17.3",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[tool.pytest.ini_options]
|
|
40
|
+
testpaths = ["src/quantum_emotion/tests",]
|
|
41
|
+
python_files = ["test_*.py", "*_tests.py", "*_test.py"]
|
|
42
|
+
pythonpath = ["src"]
|
|
43
|
+
|
|
44
|
+
[tool.ruff]
|
|
45
|
+
line-length = 79
|
|
46
|
+
|
|
47
|
+
[tool.ruff.lint]
|
|
48
|
+
ignore = ["FLY002", "TRY004"]
|
|
49
|
+
|
|
50
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Educational quantum circuit simulator based on tensor networks.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from quantum_emotion.core import (
|
|
8
|
+
BaseGate,
|
|
9
|
+
BraState,
|
|
10
|
+
CircuitOp,
|
|
11
|
+
ClassicallyControlledGate,
|
|
12
|
+
CompositeGate,
|
|
13
|
+
KetState,
|
|
14
|
+
Measure,
|
|
15
|
+
ModularGate,
|
|
16
|
+
)
|
|
17
|
+
from quantum_emotion.gates import (
|
|
18
|
+
CNOT,
|
|
19
|
+
BellModule,
|
|
20
|
+
ControlledPhaseGate,
|
|
21
|
+
ControlledY,
|
|
22
|
+
ControlledZ,
|
|
23
|
+
Hadamard,
|
|
24
|
+
PauliX,
|
|
25
|
+
PauliY,
|
|
26
|
+
PauliZ,
|
|
27
|
+
PhaseGate,
|
|
28
|
+
QFTModule,
|
|
29
|
+
SGate,
|
|
30
|
+
TeleportationModule,
|
|
31
|
+
TGate,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"CNOT",
|
|
36
|
+
"BaseGate",
|
|
37
|
+
"BellModule",
|
|
38
|
+
"BraState",
|
|
39
|
+
"CircuitOp",
|
|
40
|
+
"ClassicallyControlledGate",
|
|
41
|
+
"CompositeGate",
|
|
42
|
+
"ControlledPhaseGate",
|
|
43
|
+
"ControlledY",
|
|
44
|
+
"ControlledZ",
|
|
45
|
+
"Hadamard",
|
|
46
|
+
"KetState",
|
|
47
|
+
"Measure",
|
|
48
|
+
"ModularGate",
|
|
49
|
+
"PauliX",
|
|
50
|
+
"PauliY",
|
|
51
|
+
"PauliZ",
|
|
52
|
+
"PhaseGate",
|
|
53
|
+
"QFTModule",
|
|
54
|
+
"SGate",
|
|
55
|
+
"TGate",
|
|
56
|
+
"TeleportationModule",
|
|
57
|
+
]
|