forked from unitaryfund/mitiq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconf.py
358 lines (311 loc) · 12.5 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import pybtex.style.formatting
import pybtex.style.formatting.unsrt
import pybtex.style.template
from pybtex.plugin import register_plugin as pybtex_register_plugin
sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath("../../"))
# -- Project information -----------------------------------------------------
project = "Mitiq"
copyright = "2020, Tech Team @ Unitary Fund"
author = "Tech Team @ Unitary Fund"
# The full version, including alpha/beta/rc tags
directory_of_this_file = os.path.dirname(os.path.abspath(__file__))
with open(f"{directory_of_this_file}/../../VERSION.txt", "r") as f:
release = f.read().strip()
sys.path.append(os.path.abspath("sphinxext"))
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"myst_nb",
"sphinx.ext.mathjax",
"IPython.sphinxext.ipython_console_highlighting",
"IPython.sphinxext.ipython_directive",
"matplotlib.sphinxext.plot_directive",
"sphinx.ext.napoleon",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx_autodoc_typehints", # after napoleon and autodoc
"sphinx.ext.todo",
"sphinx.ext.doctest",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx.ext.ifconfig",
"sphinxcontrib.bibtex",
"sphinx_copybutton",
"nbsphinx",
"sphinx_gallery.load_style",
]
intersphinx_mapping = {
"python": ("https://docs.python.org/3.8", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
# Cirq is no longer using sphinx docs so interlinking is not possible.
# "cirq": ("https://quantumai.google/cirq", None),
"pyquil": ("https://pyquil-docs.rigetti.com/en/stable/", None),
"qiskit": ("https://qiskit.org/documentation/", None),
"qutip": ("https://qutip.org/docs/latest/", None),
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# The master toctree document.
master_doc = "index"
# -- Options for myst_parser -------------------------------------------------
# Specifies which of the parsers should handle each file extension.
source_suffix = {
".rst": "restructuredtext",
".ipynb": "myst-nb",
".myst": "myst-nb",
".mystnb": "myst-nb",
}
# Enables extensions to MyST parser that allows for richer markup options.
# For more info on these, see:
# https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html
myst_enable_extensions = [
"amsmath",
"colon_fence",
"deflist",
"dollarmath",
"html_image",
"smartquotes",
]
# Tells MyST to treat URIs beginning with these prefixes as external links.
# Links that don't begin with these will be treated as internal cross-links.
myst_url_schemes = ("http", "https", "mailto")
# -- Options for myst_nb -----------------------------------------------------
# Needed to explicitly set render priority for the `doctest` mode.
# https://myst-nb.readthedocs.io/en/latest/use/formatting_outputs.html#render-priority
nb_render_priority = {
"html": (
"application/vnd.jupyter.widget-view+json",
"application/javascript",
"text/html",
"image/svg+xml",
"image/png",
"image/jpeg",
"text/markdown",
"text/latex",
"text/plain",
),
"doctest": (
"application/vnd.jupyter.widget-view+json",
"application/javascript",
"text/html",
"image/svg+xml",
"image/png",
"image/jpeg",
"text/markdown",
"text/latex",
"text/plain",
),
}
# How long should Sphinx wait while a notebook is being evaluated before
# quitting.
execution_timeout = 600
# By default, if nothing has changed in the source, a notebook won't be
# re-run for a subsequent docs build.
jupyter_execute_notebooks = "cache"
execution_excludepatterns = ["bqskit.ipynb"]
# If SKIP_PYQUIL is True, do not re-run PyQuil notebooks.
if os.environ.get("SKIP_PYQUIL"):
print("Skipping PyQuil notebooks execution since SKIP_PYQUIL is True")
execution_excludepatterns.append("*pyquil*.ipynb")
# -- Options for autodoc -----------------------------------------------------
napoleon_google_docstring = True
napoleon_use_ivar = True
autodoc_mock_imports = [
"pyquil",
]
# autodoc-typehints extension setting
typehints_fully_qualified = False
always_document_param_types = True
set_type_checking_flag = False
typehints_document_rtype = True
# -- Options for Sphinxcontrib-bibtex ----------------------------------------
pybtex.style.formatting.unsrt.date = pybtex.style.template.words(sep="")[
"(", pybtex.style.template.field("year"), ")"
]
bibtex_bibfiles = ["refs.bib"]
# Links matching with the following regular expressions will be ignored
linkcheck_ignore = [
r"https://doi.org/10.1088/0034-4885/74/10/104401",
r"https://doi.org/10.1088/1367-2630/12/7/075008",
]
class ApsStyle(pybtex.style.formatting.unsrt.Style):
"""Style that mimicks APS journals."""
def __init__(
self,
label_style=None,
name_style=None,
sorting_style=None,
abbreviate_names=True,
min_crossrefs=2,
**kwargs,
):
super().__init__(
label_style=label_style,
name_style=name_style,
sorting_style=sorting_style,
abbreviate_names=abbreviate_names,
min_crossrefs=min_crossrefs,
**kwargs,
)
def format_title(self, e, which_field, as_sentence=True):
"""Set titles in italics."""
formatted_title = pybtex.style.template.field(
which_field, apply_func=lambda text: text.capitalize()
)
formatted_title = pybtex.style.template.tag("em")[formatted_title]
if as_sentence:
return pybtex.style.template.sentence[formatted_title]
else:
return formatted_title
def get_article_template(self, e):
volume_and_pages = pybtex.style.template.first_of[
# volume and pages
pybtex.style.template.optional[
pybtex.style.template.join[
" ",
pybtex.style.template.tag("strong")[
pybtex.style.template.field("volume")
],
", ",
pybtex.style.template.field(
"pages",
apply_func=pybtex.style.formatting.unsrt.dashify,
),
],
],
# pages only
pybtex.style.template.words[
"pages",
pybtex.style.template.field(
"pages", apply_func=pybtex.style.formatting.unsrt.dashify
),
],
]
template = pybtex.style.formatting.toplevel[
self.format_names("author"),
self.format_title(e, "title"),
pybtex.style.template.sentence(sep=" ")[
pybtex.style.template.field("journal"),
pybtex.style.template.optional[volume_and_pages],
pybtex.style.formatting.unsrt.date,
],
self.format_web_refs(e),
]
return template
def get_book_template(self, e):
template = pybtex.style.formatting.toplevel[
self.format_author_or_editor(e),
self.format_btitle(e, "title"),
self.format_volume_and_series(e),
pybtex.style.template.sentence(sep=" ")[
pybtex.style.template.sentence(add_period=False)[
pybtex.style.template.field("publisher"),
pybtex.style.template.optional_field("address"),
self.format_edition(e),
],
pybtex.style.formatting.unsrt.date,
],
pybtex.style.template.optional[
pybtex.style.template.sentence[self.format_isbn(e)]
],
pybtex.style.template.sentence[
pybtex.style.template.optional_field("note")
],
self.format_web_refs(e),
]
return template
def get_incollection_template(self, e):
template = pybtex.style.formatting.toplevel[
pybtex.style.template.sentence[self.format_names("author")],
self.format_title(e, "title"),
pybtex.style.template.words[
"In",
pybtex.style.template.sentence[
pybtex.style.template.optional[
self.format_editor(e, as_sentence=False)
],
self.format_btitle(e, "booktitle", as_sentence=False),
self.format_volume_and_series(e, as_sentence=False),
self.format_chapter_and_pages(e),
],
],
pybtex.style.template.sentence(sep=" ")[
pybtex.style.template.sentence(add_period=False)[
pybtex.style.template.optional_field("publisher"),
pybtex.style.template.optional_field("address"),
self.format_edition(e),
],
pybtex.style.formatting.unsrt.date,
],
self.format_web_refs(e),
]
return template
pybtex_register_plugin("pybtex.style.formatting", "apsstyle", ApsStyle)
# -- Options for other extensions --------------------------------------------
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "pydata_sphinx_theme" # 'alabaster', 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_thumbnails"]
# display logo on top-left of html pages
html_logo = "img/mitiq-logo.png"
html_favicon = "img/mitiq.ico"
myst_update_mathjax = False
nbsphinx_custom_formats = {
".mystnb": ["jupytext.reads", {"fmt": "mystnb"}],
}
nbsphinx_execute = "always"
nbsphinx_thumbnails = {
"examples/hamiltonians": "_static/vqe-cirq-pauli-sum-mitigation-plot.png",
"examples/braket_mirror_circuit": "_static/mirror-circuits.png",
"examples/maxcut-demo": "_static/max-cut.png",
"examples/cirq-ibmq-backends": "_static/cirq-mitiq-ibmq.png",
"examples/pennylane-ibmq-backends": "_static/zne-pennylane.png",
"examples/ibmq-backends": "_static/ibmq-gate-map.png",
"examples/simple_landscape": "_static/simple-landscape.png",
"examples/molecular_hydrogen": "_static/molecular-hydrogen-vqe.png",
"examples/molecular_hydrogen_pennylane": "_static/mol-h2-vqe-pl.png",
"examples/vqe-pyquil-demo": "_static/vqe-pyquil-demo.png",
"examples/pyquil_demo": "_static/pyquil-demo.png",
"examples/mitiq-paper/*": "_static/mitiq-codeblocks.png",
"examples/zne-braket-ionq": "_static/zne-braket-ionq.png",
"examples/bqskit": "_static/bqskit.png",
# default images if no thumbnail is specified
"examples/*": "_static/mitiq-logo.png",
}