Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply black code formatter #2891

Merged
merged 6 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
pip install flake8 isort>=5.0 mypy nbstripout nbformat
- name: Lint with flake8
pip install flake8 black isort>=5.0 mypy nbstripout nbformat
- name: Lint
run: |
make lint
docs:
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ tutorial: FORCE

lint: FORCE
flake8
black --check .
isort --check .
python scripts/update_headers.py --check
mypy pyro
Expand All @@ -29,6 +30,7 @@ license: FORCE
python scripts/update_headers.py

format: license FORCE
black .
isort .

version: FORCE
Expand Down
99 changes: 54 additions & 45 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# 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.
#
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))

# -- General configuration ------------------------------------------------

Expand All @@ -38,15 +38,15 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.intersphinx', #
'sphinx.ext.todo', #
'sphinx.ext.mathjax', #
'sphinx.ext.ifconfig', #
'sphinx.ext.viewcode', #
'sphinx.ext.githubpages', #
'sphinx.ext.graphviz', #
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
"sphinx.ext.intersphinx", #
"sphinx.ext.todo", #
"sphinx.ext.mathjax", #
"sphinx.ext.ifconfig", #
"sphinx.ext.viewcode", #
"sphinx.ext.githubpages", #
"sphinx.ext.graphviz", #
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
]

# Disable documentation inheritance so as to avoid inheriting
Expand All @@ -56,31 +56,32 @@
autodoc_inherit_docstrings = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'Pyro'
copyright = u'2017-2018, Uber Technologies, Inc'
author = u'Uber AI Labs'
project = u"Pyro"
copyright = u"2017-2018, Uber Technologies, Inc"
author = u"Uber AI Labs"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

version = ''
version = ""

if 'READTHEDOCS' not in os.environ:
if "READTHEDOCS" not in os.environ:
# if developing locally, use pyro.__version__ as version
from pyro import __version__ # noqaE402

version = __version__

# release version
Expand All @@ -99,7 +100,7 @@
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
Expand All @@ -110,10 +111,10 @@
# -- Options for HTML output ----------------------------------------------

# logo
html_logo = '_static/img/pyro_logo_wide.png'
html_logo = "_static/img/pyro_logo_wide.png"

# logo
html_favicon = '_static/img/favicon/favicon.ico'
html_favicon = "_static/img/favicon/favicon.ico"

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
Expand All @@ -126,36 +127,33 @@
# documentation.

html_theme_options = {
'navigation_depth': 3,
'logo_only': True,
"navigation_depth": 3,
"logo_only": True,
}

# 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 = ['_static']
html_style = 'css/pyro.css'
html_static_path = ["_static"]
html_style = "css/pyro.css"

# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Pyrodoc'
htmlhelp_basename = "Pyrodoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -165,34 +163,41 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Pyro.tex', u'Pyro Documentation', u'Uber AI Labs', 'manual'),
(master_doc, "Pyro.tex", u"Pyro Documentation", u"Uber AI Labs", "manual"),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, 'pyro', u'Pyro Documentation', [author], 1)]
man_pages = [(master_doc, "pyro", u"Pyro Documentation", [author], 1)]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Pyro', u'Pyro Documentation', author, 'Pyro',
'Deep Universal Probabilistic Programming.', 'Miscellaneous'),
(
master_doc,
"Pyro",
u"Pyro Documentation",
author,
"Pyro",
"Deep Universal Probabilistic Programming.",
"Miscellaneous",
),
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/3/', None),
'torch': ('https://pytorch.org/docs/master/', None),
'funsor': ('http://funsor.pyro.ai/en/stable/', None),
'opt_einsum': ('https://optimized-einsum.readthedocs.io/en/stable/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
'Bio': ('https://biopython.readthedocs.io/en/latest/', None),
'horovod': ('https://horovod.readthedocs.io/en/stable/', None),
"python": ("https://docs.python.org/3/", None),
"torch": ("https://pytorch.org/docs/master/", None),
"funsor": ("http://funsor.pyro.ai/en/stable/", None),
"opt_einsum": ("https://optimized-einsum.readthedocs.io/en/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
"Bio": ("https://biopython.readthedocs.io/en/latest/", None),
"horovod": ("https://horovod.readthedocs.io/en/stable/", None),
}

# document class constructors (__init__ methods):
Expand All @@ -205,13 +210,17 @@ def skip(app, what, name, obj, skip, options):


def setup(app):
app.add_css_file('css/pyro.css')
app.add_css_file("css/pyro.css")


# app.connect("autodoc-skip-member", skip)


# @jpchen's hack to get rtd builder to install latest pytorch
# See similar line in the install section of .travis.yml
if 'READTHEDOCS' in os.environ:
os.system('pip install numpy')
os.system('pip install torch==1.9.0+cpu torchvision==0.10.0+cpu '
'-f https://download.pytorch.org/whl/torch_stable.html')
if "READTHEDOCS" in os.environ:
os.system("pip install numpy")
os.system(
"pip install torch==1.9.0+cpu torchvision==0.10.0+cpu "
"-f https://download.pytorch.org/whl/torch_stable.html"
)
Loading