Skip to content

Commit

Permalink
docs: Restructure documentation
Browse files Browse the repository at this point in the history
The documentation got restructured, and cards have been added with
`sphinx-design`.

Also, several fixes got issued:
- The code blocks didn't render well in the ipython notebooks, and to fix this,
  the `IPython.sphinxext.ipython_console_highlighting` is added to the
  extension list in `conf.py`.
- Building on ReadtheDocs got fixed by adding the CMake build in
  a `post_install` job.
- The original documentation URLs got modified to the new one.
- Some tutorials got updated.
  • Loading branch information
Kolarovszki committed Oct 28, 2024
1 parent 704a6cc commit eeb40d6
Show file tree
Hide file tree
Showing 38 changed files with 447 additions and 160 deletions.
9 changes: 9 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Resulting state: <piquasso._simulators.gaussian.state.GaussianState object at 0x
Detected samples: [(0,), (2,), (1,), (2,), (2,), (4,), (1,), (1,), (4,), (1,)]
```

For more details, please refer to [docs.piquasso.com](https://docs.piquasso.com/).
For more details, please refer to [the Piquasso documentation](https://piquasso.readthedocs.io/).

## Install

Expand Down Expand Up @@ -138,7 +138,7 @@ If you are doing research using Piquasso, please cite us as follows:

## Documentation

The documentation is avaliable at [docs.piquasso.com](https://docs.piquasso.com/).
The documentation is avaliable at [https://piquasso.readthedocs.io/](https://piquasso.readthedocs.io/).

## How to contribute?

Expand Down
19 changes: 19 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,23 @@ div.nbinput.container div.input_area {
padding: .5rem!important;
/* border-radius: 0.5rem!important; */
box-shadow: 0 0 7px 2px rgba(0,0,0,.1);
}

.sd-card-title {
font-size: 1.4em;
text-align: center;
}

.sd-card-text {
font-size: 0.8em;
text-align: center;
}

.mission-statement {
font-size: 1.3em;
text-align: center;
}

h1 {
text-align: center;
}
8 changes: 4 additions & 4 deletions docs/advanced/connectors.rst
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
Connectors
===========
==========

Alongside NumPy, Piquasso also supports TensorFlow and JAX as simulators for calculations.


NumPy connector
----------------
---------------

.. automodule:: piquasso._simulators.connectors.numpy_.connector
:members:


TensorFlow connector
---------------------
--------------------

.. automodule:: piquasso._simulators.connectors.tensorflow_.connector
:members:


JAX connector
--------------
-------------

.. automodule:: piquasso._simulators.connectors.jax_.connector
:members:
7 changes: 1 addition & 6 deletions docs/advanced/cvqnn.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
CVQNN Module
============

Some tools for simulating CVQNN (Continuous-Variable Quantum Neural Networks) are also
available in Piquasso.

.. automodule:: piquasso.cvqnn
:noindex:
:members:
2 changes: 1 addition & 1 deletion docs/api/computer.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Computer
--------
========

.. automodule:: piquasso.api.computer
:members:
2 changes: 1 addition & 1 deletion docs/api/connector.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Connector
----------
=========

.. automodule:: piquasso.api.connector
:members:
2 changes: 1 addition & 1 deletion docs/api/exceptions.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Exceptions
----------
==========

.. automodule:: piquasso.api.exceptions
:show-inheritance:
Expand Down
18 changes: 18 additions & 0 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
API reference
=============

The API reference of Piquasso.

.. toctree::
:maxdepth: 1

program
simulator
config
mode
state
instruction
result
exceptions
computer
connector
2 changes: 1 addition & 1 deletion docs/api/instruction.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Instruction
-----------
===========

.. automodule:: piquasso.api.instruction
:members:
2 changes: 1 addition & 1 deletion docs/api/mode.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Q
-
=

.. automodule:: piquasso.api.mode
:members:
2 changes: 1 addition & 1 deletion docs/api/program.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Program
-------
=======

.. automodule:: piquasso.api.program
:members:
2 changes: 1 addition & 1 deletion docs/api/result.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Result
------
======

.. automodule:: piquasso.api.result
:members:
2 changes: 1 addition & 1 deletion docs/api/simulator.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Simulator
---------
=========

.. automodule:: piquasso.api.simulator
:show-inheritance:
Expand Down
2 changes: 1 addition & 1 deletion docs/api/state.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
State
-----
=====

.. automodule:: piquasso.api.state
:members:
Binary file added docs/code_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"nbsphinx",
"sphinx_design",
"IPython.sphinxext.ipython_console_highlighting",
]


Expand Down
160 changes: 93 additions & 67 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,108 +1,134 @@
Piquasso
********
======================
Piquasso documentation
======================


Piquasso is an open source Python package, which allows you to simulate a photonic
quantum computer. One could use Gaussian or Fock state corresponding to different
representations to run simulations.
|
.. container:: mission-statement

Installation
============
Piquasso is an open source Python package, which allows you to simulate a photonic
quantum computer.

One could easily install Piquasso with the following command:
|
.. code-block:: bash
.. grid:: 4

pip install piquasso
.. grid-item-card:: Installation
:link: installation
:link-type: doc
:class-title: cardclass

For a basic example, check out :doc:`tutorials/getting-started`.
Instructions on the installation of the Piquasso package

One can also use Piquasso along with TensorFlow, see, e.g.,
:doc:`tutorials/cvqnn-with-tensorflow`. To install Piquasso with TensorFlow, just enter
.. grid-item-card:: Tutorials
:link: tutorials/index
:link-type: doc

.. code-block:: bash
Basic tutorials for using Piquasso

pip install piquasso[tensorflow]
.. grid-item-card:: Simulators
:link: simulators/index
:link-type: doc

The built-in simulators in Piquasso

Similarly, Piquasso admits a JAX support, as described in :doc:`tutorials/jax-example`
To install Piquasso with JAX is done by
.. grid-item-card:: API reference
:link: api/index
:link-type: doc

.. code-block:: bash
API reference for Piquasso

pip install piquasso[jax]

|
.. toctree::
:maxdepth: 3
:caption: Tutorials:
:hidden:
Code example
============

tutorials/getting-started
tutorials/separating-programs
tutorials/boson-sampling
tutorials/gaussian-boson-sampling
tutorials/cvqnn-with-tensorflow
tutorials/jax-example
.. code-block::
.. toctree::
:maxdepth: 3
:caption: Simulators:
:hidden:
import numpy as np
import piquasso as pq
simulators/gaussian
simulators/fock
simulators/sampling
# Program definition
with pq.Program() as program:
# Prepare a Gaussian vacuum state
pq.Q() | pq.Vacuum()
# Displace the state on mode 0
pq.Q(0) | pq.Displacement(r=np.sqrt(2), phi=np.pi / 4)
# Use a beamsplitter gate on modes 0, 1
pq.Q(0, 1) | pq.Beamsplitter(theta=np.pi / 3, phi=np.pi / 2)
# Measurement on mode 0
pq.Q(0) | pq.HomodyneMeasurement(phi=0)
# Creating the Gaussian simulator
simulator = pq.GaussianSimulator(d=3)
# Apply the program with 10 shots
result = simulator.execute(program, shots=10)
How to cite us
==============

If you are doing research using Piquasso, please cite us as follows:

.. code-block::
@misc{piquasso2024,
title = {Piquasso: A Photonic Quantum Computer Simulation Software Platform},
author = {Z. Kolarovszki and
T. Rybotycki and
P. Rakyta and
Á. Kaposi and
B. Poór and
Sz. Jóczik and
D. T. R. Nagy and
H. Varga and
K. H. El-Safty and
G. Morse and
M. Oszmaniec and
T. Kozsik and
Z. Zimborás
},
year = {2024},
eprint = {2403.04006},
archiveprefix = {arXiv},
primaryclass = {quant-ph}
}
.. toctree::
:maxdepth: 3
:caption: States:
:hidden:
states/gaussian
states/fock
states/sampling
.. toctree::
:maxdepth: 3
:caption: Instructions:
:hidden:
:caption: Basics

installation
tutorials/index

instructions/preparations
instructions/gates
instructions/measurements
instructions/channels

.. toctree::
:maxdepth: 3
:caption: API:
:hidden:
:caption: Features

api/program
api/simulator
api/config
api/mode
api/state
api/instruction
api/result
api/exceptions
api/computer
api/connector
simulators/index
states/index
instructions/index

.. toctree::
:maxdepth: 3
:caption: Advanced:
:hidden:
:caption: Advanced

advanced/cvqnn
api/index
advanced/connectors
advanced/decompositions

advanced/cvqnn

.. toctree::
:maxdepth: 3
:caption: Experimental:
:hidden:
:caption: Experimental

experimental/fermionic
Loading

0 comments on commit eeb40d6

Please sign in to comment.