Skip to content

Commit

Permalink
Overhaul Quil to LaTeX circuit generation (rigetti#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Davis authored and karalekas committed Nov 1, 2019
1 parent 42fbddb commit dc07bae
Show file tree
Hide file tree
Showing 15 changed files with 1,022 additions and 702 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Changelog
running the image, a user will be dropped into an `ipython` REPL that has
pyQuil and its requirements preinstalled, along with quilc and qvm servers
running in the background (@karalekas, gh-1035, gh-1039).
- Circuit diagram generation has had a makeover! In particular, the
`pyquil.latex` module provides two mechanisms for generating diagrams from
pyQuil programs: `pyquil.latex.to_latex` generates human-readable LaTeX
output expressing a `Program` as a circuit diagram, and
`pyquil.latex.display` renders a `Program` as an `IPython.display.Image` for
inline viewing in Jupyter Notebooks (@kilimanjaro, gh-1074).

### Improvements and Changes

Expand Down
22 changes: 0 additions & 22 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
ProjectQ
========

The Quil to LaTeX generation code in `latex_config.py` and
`latex_generation.py` contains content from ProjectQ-Framework.

https://github.com/ProjectQ-Framework/ProjectQ

Copyright 2017 ProjectQ-Framework (www.projectq.ch)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

contextvars
===========

Expand Down
24 changes: 24 additions & 0 deletions docs/source/apidocs/visualization.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Visualization
=============

pyQuil programs may be converted to LaTeX circuit diagrams, or even rendered immediately in a Jupyter Notebook. The main entry point of LaTeX generation is :py:func:`~pyquil.latex.to_latex`. For inline rendering in a notebook, the main entry point is :py:func:`~pyquil.latex.display`.


Both of these functions take an optional :py:class:`~pyquil.latex.DiagramSettings`, which may be used to control some aspects of circuit layout and appearance.

.. currentmodule:: pyquil.latex
.. autoclass:: DiagramSettings

.. rubric:: Attributes
.. autosummary::
:template: autosumm.rst

~DiagramSettings.texify_numerical_constants
~DiagramSettings.impute_missing_qubits
~DiagramSettings.label_qubit_lines
~DiagramSettings.abbreviate_controlled_rotations
~DiagramSettings.qubit_line_open_wire_length
~DiagramSettings.right_align_terminal_measurements

.. autofunction:: to_latex
.. autofunction:: display
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Contents
apidocs/simulators
apidocs/noise
apidocs/operator_estimation
apidocs/visualization

Indices and Tables
------------------
Expand Down
224 changes: 224 additions & 0 deletions examples/LaTeXQuilCircuits.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pyquil/latex/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from pyquil.latex.latex_generation import to_latex
from pyquil.latex._diagram import DiagramSettings
from pyquil.latex._ipython import display
Loading

0 comments on commit dc07bae

Please sign in to comment.