Skip to content

Commit

Permalink
new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
purva-thakre committed Jun 23, 2021
1 parent 794afed commit 6d7bcdc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
30 changes: 16 additions & 14 deletions doc/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ In addition
are used to build and test the documentation.

.. _circuit_plot_packages:

Additional software for Plotting Circuits
=========================================
In order to plot circuits, the following non-Python softwares are needed:
In order to plot circuits, the following non-Python packages are needed:

LaTeX
-----
Expand All @@ -71,25 +72,17 @@ has some useful discussion on selectively installing part of the packages. In pa
environment.

**For Windows** :
We recommend installing `MiKTeX <https://miktex.org/>`_, which will automatically install necessary packages like `qcircuit` for you when it is used. It will only take a few more minutes in your first attempt at plotting a circuit.
We recommend installing `MiKTeX <https://miktex.org/>`_, which will automatically install necessary packages like ``qcircuit`` for you when it is used. It will only take a few more minutes in your first attempt at plotting a circuit.
In addition, you also need to install perl for ``pdfcrop``.

ImageMagick and Ghostscript
---------------------------
The output of a circuit plot will be output in a `Jupyter notebook <https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html>`_.
In your virtual environment, start a Jupyter notebook and run your examples
in a notebook. If you try to access a circuit plot in a terminal or IPython console,
you will be able to access the location of this image in memory.
In order to display the circuit in Jupyter notebook, we need to convert it to png
format. To do that, you will need to install `Ghostscript <https://www.ghostscript.com/doc/current/Make.htm>`_
and `ImageMagick <https://imagemagick.org/script/install-source.php>`_.
The first is responsible for reading the pdf file while the second will convert it to png.


In order to display the circuit in Jupyter notebook, we need to convert it to png format. To do that, you will need to isntall `Ghostscript <https://www.ghostscript.com/>`_ and `ImageMagick <https://imagemagick.org/script/download.php>`_.
The first is responsible for reading the pdf file while the second converting it to png.

``ImageMagick`` can be installed as a conda package via `this link <https://github.com/conda-forge/imagemagick-feedstock#installing-imagemagick>`_
or use this `link <https://imagemagick.org/script/download.php>`_ to install
via source. This package along with ``pdfcrop`` and ``pdflatex`` are
needed to display the circuit diagrams.

.. note::
You `might need to make changes <https://stackoverflow.com/a/52863413/10241324>`_ to ``policy.xml`` if the following error occurs :

Expand All @@ -98,6 +91,14 @@ needed to display the circuit diagrams.
RuntimeError: convert-im6.q16: not authorized `qcirc.pdf' @ error/constitute.c/ReadImage/412.
convert-im6.q16: no images defined `qcirc.png' @ error/convert.c/ConvertImageCommand/3258.
The output of a circuit plot will be output in a `Jupyter notebook <https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html>`_.
In your virtual environment, start a Jupyter notebook and run your examples
in a notebook. If you try to access a circuit plot in a terminal or IPython console,
you will only be able to access the location of this image in your device's memory.



pdf2svg
-------
To convert the circuit into svg format, you will need to install ``pdf2svg``.
Expand Down Expand Up @@ -129,6 +130,7 @@ If you want to edit the code, use instead
pip install -e .
To test the installation from a download of the source code, run from the `qutip-qip` directory

```
pytest tests
```
15 changes: 0 additions & 15 deletions doc/source/qip-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,9 @@ Plotting a Quantum Circuit
A quantum circuit (described above) can directly be plotted using the QCircuit library (https://github.com/CQuIC/qcircuit).
QCiruit is a quantum circuit drawing application and is implemented directly into QuTiP.

The circuit image visualization requires LaTeX and ImageMagick for display.
The module automatically generates the LaTeX code for plotting the circuit,
produces the pdf and converts it to the png format. On Mac and Linux,
ImageMagick can be easily installed with the command conda install imagemagick if you have conda installed.
Otherwise, please follow the installation instructions on the ImageMagick documentation.

More information related to installing these packages is also available in the
installation guide (:ref:`circuit_plot_packages`).

On Windows, you need to download and install ImageMagick installer.
In addition, you also need perl (for ``pdfcrop``) and
Ghostscript (additional dependency of ImageMagick for png conversion).

If you want to check whether all dependencies are installed,
see if the following three commands work correctly:
``pdflatex``, ``pdfcrop`` and ``magick anypdf.pdf anypdf.png``,
where ``anypdf.pdf`` is any pdf file you have.

An example code for plotting the example quantum circuit from above is given:

.. code-block:: python
Expand Down

0 comments on commit 6d7bcdc

Please sign in to comment.