qlearn3000 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.

Potentially problematic release.


This version of qlearn3000 might be problematic. Click here for more details.

Files changed (43) hide show
  1. qlearn3000-0.1.0/LICENSE +21 -0
  2. qlearn3000-0.1.0/PKG-INFO +144 -0
  3. qlearn3000-0.1.0/README.md +131 -0
  4. qlearn3000-0.1.0/pyproject.toml +52 -0
  5. qlearn3000-0.1.0/setup.cfg +4 -0
  6. qlearn3000-0.1.0/src/qlearn3000/__init__.py +7 -0
  7. qlearn3000-0.1.0/src/qlearn3000/circuit.py +1224 -0
  8. qlearn3000-0.1.0/src/qlearn3000/gates/__init__.py +143 -0
  9. qlearn3000-0.1.0/src/qlearn3000/gates/_abstract_gates.py +434 -0
  10. qlearn3000-0.1.0/src/qlearn3000/gates/_nonunitary_gates.py +266 -0
  11. qlearn3000-0.1.0/src/qlearn3000/gates/_other_instructions.py +25 -0
  12. qlearn3000-0.1.0/src/qlearn3000/gates/_unitary_gates.py +1792 -0
  13. qlearn3000-0.1.0/src/qlearn3000/gui/__init__.py +10 -0
  14. qlearn3000-0.1.0/src/qlearn3000/gui/angles.py +428 -0
  15. qlearn3000-0.1.0/src/qlearn3000/gui/canvas.py +787 -0
  16. qlearn3000-0.1.0/src/qlearn3000/gui/config.py +324 -0
  17. qlearn3000-0.1.0/src/qlearn3000/gui/dialogs.py +973 -0
  18. qlearn3000-0.1.0/src/qlearn3000/gui/items.py +982 -0
  19. qlearn3000-0.1.0/src/qlearn3000/gui/latex.py +450 -0
  20. qlearn3000-0.1.0/src/qlearn3000/gui/main_window.py +1234 -0
  21. qlearn3000-0.1.0/src/qlearn3000/gui/matrices.py +105 -0
  22. qlearn3000-0.1.0/src/qlearn3000/gui/palette.py +750 -0
  23. qlearn3000-0.1.0/src/qlearn3000/gui/placement.py +79 -0
  24. qlearn3000-0.1.0/src/qlearn3000/gui/widgets.py +243 -0
  25. qlearn3000-0.1.0/src/qlearn3000/plotting.py +92 -0
  26. qlearn3000-0.1.0/src/qlearn3000/state_vector.py +739 -0
  27. qlearn3000-0.1.0/src/qlearn3000.egg-info/PKG-INFO +144 -0
  28. qlearn3000-0.1.0/src/qlearn3000.egg-info/SOURCES.txt +41 -0
  29. qlearn3000-0.1.0/src/qlearn3000.egg-info/dependency_links.txt +1 -0
  30. qlearn3000-0.1.0/src/qlearn3000.egg-info/requires.txt +3 -0
  31. qlearn3000-0.1.0/src/qlearn3000.egg-info/top_level.txt +1 -0
  32. qlearn3000-0.1.0/tests/test_angles.py +227 -0
  33. qlearn3000-0.1.0/tests/test_circuit.py +1078 -0
  34. qlearn3000-0.1.0/tests/test_docs.py +40 -0
  35. qlearn3000-0.1.0/tests/test_docstrings.py +70 -0
  36. qlearn3000-0.1.0/tests/test_gates.py +906 -0
  37. qlearn3000-0.1.0/tests/test_gui_run.py +74 -0
  38. qlearn3000-0.1.0/tests/test_latex.py +103 -0
  39. qlearn3000-0.1.0/tests/test_matrices.py +117 -0
  40. qlearn3000-0.1.0/tests/test_palette.py +565 -0
  41. qlearn3000-0.1.0/tests/test_placement.py +43 -0
  42. qlearn3000-0.1.0/tests/test_state_vector.py +445 -0
  43. qlearn3000-0.1.0/tests/test_tutorials.py +113 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The QLearn3000 contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: qlearn3000
3
+ Version: 0.1.0
4
+ Summary: Quantum circuit simulator with a GUI and tutorials, for people new to quantum computing
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.14
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: matplotlib>=3.11.2
10
+ Requires-Dist: numpy>=2.5.4
11
+ Requires-Dist: pyside6>=6.12.0
12
+ Dynamic: license-file
13
+
14
+ # QLearn3000
15
+
16
+ QLearn3000 is a quantum circuit simulator for people new to quantum computing. You can build circuits in Python or in a drag-and-drop GUI, see the quantum state after every gate, and work through tutorials that go from superposition to quantum algorithms and error correction.
17
+
18
+ - **Python package:** build circuits from single- and two-qubit gates, measurements and resets on any number of qubits, simulate their state vector, and get the exact probability of each measurement outcome in the X, Y or Z basis.
19
+ - **GUI:** build 1- and 2-qubit circuits by dragging gates onto wires, and see the state and outcome probabilities update as you go.
20
+ - **Tutorials:** 11 Jupyter notebooks with exercises that check your answers.
21
+
22
+ The full documentation, with a GUI guide and the API reference, runs on your computer: see [Documentation](#documentation) to open it.
23
+
24
+ ## Installation
25
+
26
+ You need [uv](https://docs.astral.sh/uv/getting-started/installation/). It installs Python 3.14 for you if you don't have it.
27
+
28
+ ```bash
29
+ git clone https://github.com/QC2-python-SE/QLearn3000.git
30
+ cd QLearn3000
31
+ uv sync
32
+ ```
33
+
34
+ This creates a `.venv` folder with the package, JupyterLab for the tutorials, and the development tools.
35
+
36
+ Without uv, use Python 3.14 or later and run `pip install -e .`, plus `pip install jupyterlab` for the tutorials.
37
+
38
+ ## Quickstart
39
+
40
+ Prepare the Bell state $(|00\rangle + |11\rangle)/\sqrt{2}$ and look at its measurement outcomes:
41
+
42
+ ```python
43
+ from qlearn3000 import Circuit, gates
44
+
45
+ qc = Circuit("00", [gates.H(target=0), gates.CX(control=0, target=1)])
46
+ print(qc)
47
+
48
+ state = qc.run_circuit()
49
+ print(state)
50
+
51
+ probs = qc.outcome_probabilities()
52
+ print({outcome: round(p, 3) for outcome, p in probs.items()})
53
+ ```
54
+
55
+ ```text
56
+ q0: ─[H]────●────
57
+ │
58
+ q1: ───────[CX]──
59
+ 0.707|00> + 0.707|11>
60
+ {'00': 0.5, '01': 0.0, '10': 0.0, '11': 0.5}
61
+ ```
62
+
63
+ Qubit 0 is always written first: in `"01"`, qubit 0 is in $|0\rangle$ and qubit 1 in $|1\rangle$.
64
+
65
+ Run the code with `uv run python your_script.py`, or in a notebook (see [Tutorials](#tutorials)).
66
+
67
+ ## The GUI
68
+
69
+ Open a circuit in the GUI with `run`. It waits until you close the window, then returns the circuit as you left it:
70
+
71
+ ```python
72
+ from qlearn3000 import Circuit, gates, run
73
+
74
+ qc = Circuit("00", [gates.H(target=0), gates.CX(control=0, target=1)])
75
+ qc = run(circuit=qc)
76
+ ```
77
+
78
+ To open an empty circuit from a terminal:
79
+
80
+ ```bash
81
+ uv run python -c "from qlearn3000 import run; run()"
82
+ ```
83
+
84
+ The GUI supports circuits with 1 or 2 qubits. Measurements must be at the end of the circuit, where they become the measurement shown at the end of each wire, and resets aren't supported. Tutorial 3 is a tour of the GUI.
85
+
86
+ ## Tutorials
87
+
88
+ Start JupyterLab and open the notebooks in the `tutorials` folder:
89
+
90
+ ```bash
91
+ uv run jupyter lab tutorials
92
+ ```
93
+
94
+ | Notebook | Topic |
95
+ | :--- | :--- |
96
+ | 1. Superposition and Interference | Single-qubit gates, superposition and interference |
97
+ | 2. Measurement, Basis Changes and Shot Noise | Measuring in different bases, and sampling a finite number of shots |
98
+ | 3. Interactive Circuit Building with the GUI | A tour of the GUI |
99
+ | 4. BB84 Quantum Key Distribution | Sharing a secret key, and catching an eavesdropper |
100
+ | 5. Entanglement and the Four Bell States | Entanglement and measuring one qubit of a pair |
101
+ | 6. Superdense Coding | Sending two classical bits with one qubit |
102
+ | 7. Quantum Teleportation | Moving a qubit's state using entanglement |
103
+ | 8. Phase Kickback and the Deutsch–Jozsa Algorithm | A first quantum algorithm |
104
+ | 9. Grover's Search Algorithm | Finding a marked item with fewer queries |
105
+ | 10. The 3-Qubit Bit-Flip Code | Detecting and correcting errors |
106
+ | 11. Testing Bell's Inequality (CHSH) | Correlations that no classical model can explain |
107
+
108
+ Each tutorial ends with exercises, followed by a cell that checks your answer. `solutions.ipynb` has worked solutions for all of them.
109
+
110
+ Cells that open the GUI keep running until you close its window.
111
+
112
+ ## Documentation
113
+
114
+ The documentation has an installation guide, the tutorials, a guide to the GUI, a page explaining how QLearn3000 writes states, gates and measurements, and the API reference. It isn't hosted online, so you build it on your computer:
115
+
116
+ 1. From the project folder, run:
117
+
118
+ ```bash
119
+ uv run --group docs mkdocs serve
120
+ ```
121
+
122
+ The first time, this also installs the tools that build the documentation.
123
+
124
+ 2. Open http://127.0.0.1:8000 in your browser. The pages reload when you edit the documentation or a docstring.
125
+
126
+ 3. Press Ctrl+C in the terminal to stop.
127
+
128
+ To build the site as HTML files in the `site` folder instead, run `uv run --group docs mkdocs build`.
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ uv run pytest # run the tests, including the tutorial notebooks
134
+ uv run ruff check . # lint
135
+ uv run ruff format . # format
136
+ ```
137
+
138
+ ## Contributors
139
+
140
+ See the [list of contributors](docs/contributors.md).
141
+
142
+ ## License
143
+
144
+ QLearn3000 is released under the [MIT License](LICENSE).
@@ -0,0 +1,131 @@
1
+ # QLearn3000
2
+
3
+ QLearn3000 is a quantum circuit simulator for people new to quantum computing. You can build circuits in Python or in a drag-and-drop GUI, see the quantum state after every gate, and work through tutorials that go from superposition to quantum algorithms and error correction.
4
+
5
+ - **Python package:** build circuits from single- and two-qubit gates, measurements and resets on any number of qubits, simulate their state vector, and get the exact probability of each measurement outcome in the X, Y or Z basis.
6
+ - **GUI:** build 1- and 2-qubit circuits by dragging gates onto wires, and see the state and outcome probabilities update as you go.
7
+ - **Tutorials:** 11 Jupyter notebooks with exercises that check your answers.
8
+
9
+ The full documentation, with a GUI guide and the API reference, runs on your computer: see [Documentation](#documentation) to open it.
10
+
11
+ ## Installation
12
+
13
+ You need [uv](https://docs.astral.sh/uv/getting-started/installation/). It installs Python 3.14 for you if you don't have it.
14
+
15
+ ```bash
16
+ git clone https://github.com/QC2-python-SE/QLearn3000.git
17
+ cd QLearn3000
18
+ uv sync
19
+ ```
20
+
21
+ This creates a `.venv` folder with the package, JupyterLab for the tutorials, and the development tools.
22
+
23
+ Without uv, use Python 3.14 or later and run `pip install -e .`, plus `pip install jupyterlab` for the tutorials.
24
+
25
+ ## Quickstart
26
+
27
+ Prepare the Bell state $(|00\rangle + |11\rangle)/\sqrt{2}$ and look at its measurement outcomes:
28
+
29
+ ```python
30
+ from qlearn3000 import Circuit, gates
31
+
32
+ qc = Circuit("00", [gates.H(target=0), gates.CX(control=0, target=1)])
33
+ print(qc)
34
+
35
+ state = qc.run_circuit()
36
+ print(state)
37
+
38
+ probs = qc.outcome_probabilities()
39
+ print({outcome: round(p, 3) for outcome, p in probs.items()})
40
+ ```
41
+
42
+ ```text
43
+ q0: ─[H]────●────
44
+ │
45
+ q1: ───────[CX]──
46
+ 0.707|00> + 0.707|11>
47
+ {'00': 0.5, '01': 0.0, '10': 0.0, '11': 0.5}
48
+ ```
49
+
50
+ Qubit 0 is always written first: in `"01"`, qubit 0 is in $|0\rangle$ and qubit 1 in $|1\rangle$.
51
+
52
+ Run the code with `uv run python your_script.py`, or in a notebook (see [Tutorials](#tutorials)).
53
+
54
+ ## The GUI
55
+
56
+ Open a circuit in the GUI with `run`. It waits until you close the window, then returns the circuit as you left it:
57
+
58
+ ```python
59
+ from qlearn3000 import Circuit, gates, run
60
+
61
+ qc = Circuit("00", [gates.H(target=0), gates.CX(control=0, target=1)])
62
+ qc = run(circuit=qc)
63
+ ```
64
+
65
+ To open an empty circuit from a terminal:
66
+
67
+ ```bash
68
+ uv run python -c "from qlearn3000 import run; run()"
69
+ ```
70
+
71
+ The GUI supports circuits with 1 or 2 qubits. Measurements must be at the end of the circuit, where they become the measurement shown at the end of each wire, and resets aren't supported. Tutorial 3 is a tour of the GUI.
72
+
73
+ ## Tutorials
74
+
75
+ Start JupyterLab and open the notebooks in the `tutorials` folder:
76
+
77
+ ```bash
78
+ uv run jupyter lab tutorials
79
+ ```
80
+
81
+ | Notebook | Topic |
82
+ | :--- | :--- |
83
+ | 1. Superposition and Interference | Single-qubit gates, superposition and interference |
84
+ | 2. Measurement, Basis Changes and Shot Noise | Measuring in different bases, and sampling a finite number of shots |
85
+ | 3. Interactive Circuit Building with the GUI | A tour of the GUI |
86
+ | 4. BB84 Quantum Key Distribution | Sharing a secret key, and catching an eavesdropper |
87
+ | 5. Entanglement and the Four Bell States | Entanglement and measuring one qubit of a pair |
88
+ | 6. Superdense Coding | Sending two classical bits with one qubit |
89
+ | 7. Quantum Teleportation | Moving a qubit's state using entanglement |
90
+ | 8. Phase Kickback and the Deutsch–Jozsa Algorithm | A first quantum algorithm |
91
+ | 9. Grover's Search Algorithm | Finding a marked item with fewer queries |
92
+ | 10. The 3-Qubit Bit-Flip Code | Detecting and correcting errors |
93
+ | 11. Testing Bell's Inequality (CHSH) | Correlations that no classical model can explain |
94
+
95
+ Each tutorial ends with exercises, followed by a cell that checks your answer. `solutions.ipynb` has worked solutions for all of them.
96
+
97
+ Cells that open the GUI keep running until you close its window.
98
+
99
+ ## Documentation
100
+
101
+ The documentation has an installation guide, the tutorials, a guide to the GUI, a page explaining how QLearn3000 writes states, gates and measurements, and the API reference. It isn't hosted online, so you build it on your computer:
102
+
103
+ 1. From the project folder, run:
104
+
105
+ ```bash
106
+ uv run --group docs mkdocs serve
107
+ ```
108
+
109
+ The first time, this also installs the tools that build the documentation.
110
+
111
+ 2. Open http://127.0.0.1:8000 in your browser. The pages reload when you edit the documentation or a docstring.
112
+
113
+ 3. Press Ctrl+C in the terminal to stop.
114
+
115
+ To build the site as HTML files in the `site` folder instead, run `uv run --group docs mkdocs build`.
116
+
117
+ ## Development
118
+
119
+ ```bash
120
+ uv run pytest # run the tests, including the tutorial notebooks
121
+ uv run ruff check . # lint
122
+ uv run ruff format . # format
123
+ ```
124
+
125
+ ## Contributors
126
+
127
+ See the [list of contributors](docs/contributors.md).
128
+
129
+ ## License
130
+
131
+ QLearn3000 is released under the [MIT License](LICENSE).
@@ -0,0 +1,52 @@
1
+ [project]
2
+ name = "qlearn3000"
3
+ version = "0.1.0"
4
+ description = "Quantum circuit simulator with a GUI and tutorials, for people new to quantum computing"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.14"
9
+ dependencies = [
10
+ "matplotlib>=3.11.2",
11
+ "numpy>=2.5.4",
12
+ "pyside6>=6.12.0",
13
+ ]
14
+
15
+ [dependency-groups]
16
+ dev = [
17
+ "mypy>=2.4.1",
18
+ "pylint>=4.1.4",
19
+ "pytest>=9.2.0",
20
+ "ruff>=0.17.6",
21
+ ]
22
+ docs = [
23
+ "mkdocs>=1.6.1",
24
+ "mkdocs-jupyter>=0.27.0",
25
+ "mkdocs-material>=9.8.0",
26
+ "mkdocstrings[python]>=1.0.8",
27
+ ]
28
+ tutorials = [
29
+ "jupyterlab>=4.6.6",
30
+ ]
31
+
32
+ [tool.uv]
33
+ # Install the tutorial and documentation dependencies with a plain `uv sync`.
34
+ default-groups = ["dev", "tutorials", "docs"]
35
+
36
+ [build-system]
37
+ requires = ["setuptools>=77"]
38
+ build-backend = "setuptools.build_meta"
39
+
40
+ [tool.ruff]
41
+ line-length = 88
42
+
43
+ [tool.ruff.lint]
44
+ select = ["E", "F", "I", "B", "UP"]
45
+
46
+ [tool.ty.environment]
47
+ extra-paths = ["tutorials"]
48
+
49
+ [[tool.uv.index]]
50
+ name = "testpypi"
51
+ url = "https://test.pypi.org/legacy/"
52
+ publish = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ """QLearn 3000 — Quantum Circuit Simulator."""
2
+
3
+ from qlearn3000.circuit import Circuit
4
+ from qlearn3000.gui import run
5
+ from qlearn3000 import gates
6
+
7
+ __all__ = ["Circuit", "run", "gates"]