diff --git a/.readthedocs.yaml b/.readthedocs.yaml index bd0d7746..3ab492b2 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -6,6 +6,15 @@ build: os: ubuntu-22.04 tools: python: "3.12" + jobs: + post_install: + # These steps are required for building the documentation on ReadtheDocs. + # If Piquasso is not compiled, several modules will not be imported by the + # documentation, and will not appear. + - pip install cmake pybind11[global] + - cmake -B build -DCMAKE_INSTALL_PREFIX=$(pwd) + - cmake --build build + - cmake --install build sphinx: configuration: docs/conf.py diff --git a/README.md b/README.md index 4c3168c6..583b21fc 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Resulting state: " + "Result(samples=[(-8.201970710129283, 6.806985248163985)], state=GaussianState(d=5, config=Config(), connector=NumpyConnector()))" ] }, - "execution_count": 1, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -60,7 +60,60 @@ "id": "be2a4757", "metadata": {}, "source": [ - "Using this syntax, one could embed subprograms on different modes. In this example, the `interferometer` subprogram is embedded twice for two different sets of modes." + "Using this syntax, one could embed subprograms on different modes. In this example, the `interferometer` subprogram is embedded twice for two different sets of modes. Note, that the subprogram is registered to the specified only via [pq.Q](https://piquasso.readthedocs.io/en/latest/api/mode.html).\n", + "\n", + "One can use this syntax to define custom gates as follows:" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "df8c05c3", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Instructions:\n", + "\t Squeezing2(r=1, phi=0.7853981633974483, modes=(0, 1))\n", + "\t Squeezing2(r=2, phi=1.0471975511965976, modes=(2, 3))\n", + "\t Phaseshifter(phi=1.0471975511965976, modes=(0,))\n", + "\t Beamsplitter(theta=0.7853981633974483, phi=0.0, modes=(0, 1))\n", + "\t Phaseshifter(phi=0.5235987755982988, modes=(1,))\n", + "\t Beamsplitter(theta=0.6283185307179586, phi=0.0, modes=(1, 2))\n", + "\t ParticleNumberMeasurement(modes=(3,))\n" + ] + } + ], + "source": [ + "def MyBeamsplitter(theta, phi):\n", + " my_beamsplitter = pq.Program(\n", + " instructions=[\n", + " pq.Phaseshifter(phi=phi).on_modes(0),\n", + " pq.Beamsplitter(theta=theta, phi=0.0).on_modes(0, 1),\n", + " ]\n", + " )\n", + "\n", + " return my_beamsplitter\n", + "\n", + "\n", + "with pq.Program() as preparation:\n", + " pq.Q(0, 1) | pq.Squeezing2(r=1, phi=np.pi / 4)\n", + " pq.Q(2, 3) | pq.Squeezing2(r=2, phi=np.pi / 3)\n", + "\n", + "with pq.Program() as program:\n", + " pq.Q(all) | preparation\n", + "\n", + " pq.Q(0, 1) | MyBeamsplitter(theta=np.pi / 4, phi=np.pi / 3)\n", + " pq.Q(1, 2) | MyBeamsplitter(theta=np.pi / 5, phi=np.pi / 6)\n", + "\n", + " pq.Q(3) | pq.ParticleNumberMeasurement()\n", + "\n", + "\n", + "print(\"Instructions:\")\n", + "for instruction in program.instructions:\n", + " print(\"\\t\", instruction)" ] } ], @@ -83,7 +136,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.8.10" } }, "nbformat": 4, diff --git a/piquasso/cvqnn.py b/piquasso/cvqnn.py index 94898bf6..ee54c9d9 100644 --- a/piquasso/cvqnn.py +++ b/piquasso/cvqnn.py @@ -13,6 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +CVQNN Module +============ + +Some tools for simulating CVQNN (Continuous-Variable Quantum Neural Networks) are also +available in Piquasso. +""" + from typing import List, Optional import numpy as np diff --git a/piquasso/fermionic/__init__.py b/piquasso/fermionic/__init__.py index aad1d34a..91a1754f 100644 --- a/piquasso/fermionic/__init__.py +++ b/piquasso/fermionic/__init__.py @@ -14,7 +14,6 @@ # limitations under the License. r""" -================= Fermionic package ================= diff --git a/piquasso/instructions/channels.py b/piquasso/instructions/channels.py index 4fa986bf..e9242560 100644 --- a/piquasso/instructions/channels.py +++ b/piquasso/instructions/channels.py @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Channels +======== + +The built-in channel instructions in Piquasso. +""" + import numpy as np from piquasso._math.linalg import is_positive_semidefinite, is_real_2n_by_2n diff --git a/piquasso/instructions/gates.py b/piquasso/instructions/gates.py index 4987f288..779f2634 100644 --- a/piquasso/instructions/gates.py +++ b/piquasso/instructions/gates.py @@ -14,6 +14,11 @@ # limitations under the License. r""" +Gates +----- + +The built-in gates in Piquasso. + Gates can be characterized by a unitary operator :math:`U`, which evolves the quantum state in the following manner diff --git a/piquasso/instructions/measurements.py b/piquasso/instructions/measurements.py index cfb3fb9b..3580bfd8 100644 --- a/piquasso/instructions/measurements.py +++ b/piquasso/instructions/measurements.py @@ -14,6 +14,12 @@ # limitations under the License. """ +Measurements +============ + +All the built-in measurement instructions in Piquasso. Measurement instructions should +be placed at the end of the Piquasso program. + .. note:: When multiple shots are specified and the evolution of the choses simulated state is diff --git a/piquasso/instructions/preparations.py b/piquasso/instructions/preparations.py index cf10fe73..1b70817f 100644 --- a/piquasso/instructions/preparations.py +++ b/piquasso/instructions/preparations.py @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Preparations +------------ + +The built-in preparation instructions in Piquasso. Preparation instructions should +be placed at the beginning of the Piquasso program. +""" + + from typing import Iterable import numpy as np diff --git a/pyproject.toml b/pyproject.toml index f5f312cc..1971107e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ [project.urls] Homepage = "https://piquasso.com" -Documentation = "https://docs.piquasso.com" +Documentation = "https://piquasso.readthedocs.io" Repository = "https://github.com/Budapest-Quantum-Computing-Group/piquasso" [project.optional-dependencies] @@ -43,7 +43,13 @@ dev = [ "nbmake~=1.5.4", "black~=24.2.0", ] -docs = ["sphinx~=7.1.2", "nbsphinx~=0.8.8", "furo~=2024.8.6"] +docs = [ + "sphinx~=7.1.2", + "nbsphinx~=0.8.8", + "furo~=2024.8.6", + "ipython~=8.12.3", + "sphinx-design~=0.5.0", +] benchmark = [ "matplotlib~=3.7.5", "pytest-profiling~=1.7.0",