Skip to content

Commit 589e423

Browse files
committed
apply black, isort
1 parent be94326 commit 589e423

19 files changed

+1827
-1561
lines changed

.flake8

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
ignore = E203, E266, E501, W503
3+
max-line-length = 80
4+
max-complexity = 18
5+
select = B,C,E,F,W,T4,B9

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ upload: clean setup.py
1212
clean:
1313
@find . | grep -E "(__pycache__|\.pyc|\.pyo$\)" | xargs rm -rf
1414
@rm -rf *.egg-info/ build/ dist/
15+
16+
format:
17+
isort -rc .
18+
black .
19+
20+
lint:
21+
black --check .
22+
flake8 .

docs/conf.py

+79-78
Original file line numberDiff line numberDiff line change
@@ -14,219 +14,214 @@
1414
import os
1515
import sys
1616

17+
# The version info for the project you're documenting, acts as replacement for
18+
# |version| and |release|, also used in various other places throughout the
19+
# built documents.
20+
#
21+
# The short X.Y version.
22+
from krypy import __version__
23+
1724
# If extensions (or modules to document with autodoc) are in another directory,
1825
# add these directories to sys.path here. If the directory is relative to the
1926
# documentation root, use os.path.abspath to make it absolute, like shown here.
20-
sys.path.insert(0, os.path.abspath('..'))
27+
sys.path.insert(0, os.path.abspath(".."))
2128

2229
# -- General configuration -----------------------------------------------------
2330

2431
# If your documentation needs a minimal Sphinx version, state it here.
25-
#needs_sphinx = '1.0'
32+
# needs_sphinx = '1.0'
2633

2734
# Add any Sphinx extension module names here, as strings. They can be extensions
2835
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
29-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.mathjax']
36+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx.ext.mathjax"]
3037

3138
# Add any paths that contain templates here, relative to this directory.
32-
templates_path = ['_templates']
39+
templates_path = ["_templates"]
3340

3441
# The suffix of source filenames.
35-
source_suffix = '.rst'
42+
source_suffix = ".rst"
3643

3744
# The encoding of source files.
38-
#source_encoding = 'utf-8-sig'
45+
# source_encoding = 'utf-8-sig'
3946

4047
# The master toctree document.
41-
master_doc = 'index'
48+
master_doc = "index"
4249

4350
# General information about the project.
44-
project = 'KryPy'
45-
copyright = '2013—2014, André Gaul'
51+
project = "KryPy"
52+
copyright = "2013—2014, André Gaul"
4653

47-
# The version info for the project you're documenting, acts as replacement for
48-
# |version| and |release|, also used in various other places throughout the
49-
# built documents.
50-
#
51-
# The short X.Y version.
52-
from krypy import __version__
53-
version = '.'.join(__version__.split('.')[:2])
54+
version = ".".join(__version__.split(".")[:2])
5455
# The full version, including alpha/beta/rc tags.
5556
release = __version__
5657

5758
# The language for content autogenerated by Sphinx. Refer to documentation
5859
# for a list of supported languages.
59-
#language = None
60+
# language = None
6061

6162
# There are two options for replacing |today|: either, you set today to some
6263
# non-false value, then it is used:
63-
#today = ''
64+
# today = ''
6465
# Else, today_fmt is used as the format for a strftime call.
65-
#today_fmt = '%B %d, %Y'
66+
# today_fmt = '%B %d, %Y'
6667

6768
# List of patterns, relative to source directory, that match files and
6869
# directories to ignore when looking for source files.
69-
exclude_patterns = ['_build']
70+
exclude_patterns = ["_build"]
7071

7172
# The reST default role (used for this markup: `text`) to use for all documents.
72-
#default_role = None
73+
# default_role = None
7374

7475
# If true, '()' will be appended to :func: etc. cross-reference text.
75-
#add_function_parentheses = True
76+
# add_function_parentheses = True
7677

7778
# If true, the current module name will be prepended to all description
7879
# unit titles (such as .. function::).
79-
#add_module_names = True
80+
# add_module_names = True
8081

8182
# If true, sectionauthor and moduleauthor directives will be shown in the
8283
# output. They are ignored by default.
83-
#show_authors = False
84+
# show_authors = False
8485

8586
# The name of the Pygments (syntax highlighting) style to use.
86-
pygments_style = 'sphinx'
87+
pygments_style = "sphinx"
8788

8889
# A list of ignored prefixes for module index sorting.
89-
#modindex_common_prefix = []
90+
# modindex_common_prefix = []
9091

91-
autoclass_content = 'both'
92+
autoclass_content = "both"
9293

9394
# -- Options for HTML output ---------------------------------------------------
9495

9596
# The theme to use for HTML and HTML Help pages. See the documentation for
9697
# a list of builtin themes.
97-
html_theme = 'default'
98+
html_theme = "default"
9899

99100
# Theme options are theme-specific and customize the look and feel of a theme
100101
# further. For a list of options available for each theme, see the
101102
# documentation.
102-
#html_theme_options = {}
103+
# html_theme_options = {}
103104

104105
# Add any paths that contain custom themes here, relative to this directory.
105-
#html_theme_path = []
106+
# html_theme_path = []
106107

107108
# The name for this set of Sphinx documents. If None, it defaults to
108109
# "<project> v<release> documentation".
109-
#html_title = None
110+
# html_title = None
110111

111112
# A shorter title for the navigation bar. Default is the same as html_title.
112-
#html_short_title = None
113+
# html_short_title = None
113114

114115
# The name of an image file (relative to this directory) to place at the top
115116
# of the sidebar.
116-
#html_logo = None
117+
# html_logo = None
117118

118119
# The name of an image file (within the static path) to use as favicon of the
119120
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
120121
# pixels large.
121-
#html_favicon = None
122+
# html_favicon = None
122123

123124
# Add any paths that contain custom static files (such as style sheets) here,
124125
# relative to this directory. They are copied after the builtin static files,
125126
# so a file named "default.css" will overwrite the builtin "default.css".
126-
html_static_path = ['_static']
127+
html_static_path = ["_static"]
127128

128129
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
129130
# using the given strftime format.
130-
#html_last_updated_fmt = '%b %d, %Y'
131+
# html_last_updated_fmt = '%b %d, %Y'
131132

132133
# If true, SmartyPants will be used to convert quotes and dashes to
133134
# typographically correct entities.
134-
#html_use_smartypants = True
135+
# html_use_smartypants = True
135136

136137
# Custom sidebar templates, maps document names to template names.
137-
#html_sidebars = {}
138+
# html_sidebars = {}
138139

139140
# Additional templates that should be rendered to pages, maps page names to
140141
# template names.
141-
#html_additional_pages = {}
142+
# html_additional_pages = {}
142143

143144
# If false, no module index is generated.
144-
#html_domain_indices = True
145+
# html_domain_indices = True
145146

146147
# If false, no index is generated.
147-
#html_use_index = True
148+
# html_use_index = True
148149

149150
# If true, the index is split into individual pages for each letter.
150-
#html_split_index = False
151+
# html_split_index = False
151152

152153
# If true, links to the reST sources are added to the pages.
153-
#html_show_sourcelink = True
154+
# html_show_sourcelink = True
154155

155156
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
156-
#html_show_sphinx = True
157+
# html_show_sphinx = True
157158

158159
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
159-
#html_show_copyright = True
160+
# html_show_copyright = True
160161

161162
# If true, an OpenSearch description file will be output, and all pages will
162163
# contain a <link> tag referring to it. The value of this option must be the
163164
# base URL from which the finished HTML is served.
164-
#html_use_opensearch = ''
165+
# html_use_opensearch = ''
165166

166167
# This is the file name suffix for HTML files (e.g. ".xhtml").
167-
#html_file_suffix = None
168+
# html_file_suffix = None
168169

169170
# Output file base name for HTML help builder.
170-
htmlhelp_basename = 'KryPydoc'
171+
htmlhelp_basename = "KryPydoc"
171172

172173

173174
# -- Options for LaTeX output --------------------------------------------------
174175

175176
latex_elements = {
176-
# The paper size ('letterpaper' or 'a4paper').
177-
#'papersize': 'letterpaper',
178-
179-
# The font size ('10pt', '11pt' or '12pt').
180-
#'pointsize': '10pt',
181-
182-
# Additional stuff for the LaTeX preamble.
183-
#'preamble': '',
184-
'papersize': 'a4paper',
185-
'preamble': r'''
177+
# The paper size ('letterpaper' or 'a4paper').
178+
# 'papersize': 'letterpaper',
179+
# The font size ('10pt', '11pt' or '12pt').
180+
# 'pointsize': '10pt',
181+
# Additional stuff for the LaTeX preamble.
182+
# 'preamble': '',
183+
"papersize": "a4paper",
184+
"preamble": r"""
186185
\usepackage{amsmath}
187186
\usepackage{amssymb}
188-
'''
187+
""",
189188
}
190189

191190
# Grouping the document tree into LaTeX files. List of tuples
192191
# (source start file, target name, title, author, documentclass [howto/manual]).
193192
latex_documents = [
194-
('index', 'KryPy.tex', 'KryPy Documentation',
195-
'André Gaul', 'manual'),
193+
("index", "KryPy.tex", "KryPy Documentation", "André Gaul", "manual"),
196194
]
197195

198196
# The name of an image file (relative to this directory) to place at the top of
199197
# the title page.
200-
#latex_logo = None
198+
# latex_logo = None
201199

202200
# For "manual" documents, if this is true, then toplevel headings are parts,
203201
# not chapters.
204-
#latex_use_parts = False
202+
# latex_use_parts = False
205203

206204
# If true, show page references after internal links.
207-
#latex_show_pagerefs = False
205+
# latex_show_pagerefs = False
208206

209207
# If true, show URL addresses after external links.
210-
#latex_show_urls = False
208+
# latex_show_urls = False
211209

212210
# Documents to append as an appendix to all manuals.
213-
#latex_appendices = []
211+
# latex_appendices = []
214212

215213
# If false, no module index is generated.
216-
#latex_domain_indices = True
214+
# latex_domain_indices = True
217215

218216

219217
# -- Options for manual page output --------------------------------------------
220218

221219
# One entry per manual page. List of tuples
222220
# (source start file, name, description, authors, manual section).
223-
man_pages = [
224-
('index', 'krypy', 'KryPy Documentation',
225-
['André Gaul'], 1)
226-
]
221+
man_pages = [("index", "krypy", "KryPy Documentation", ["André Gaul"], 1)]
227222

228223
# If true, show URL addresses after external links.
229-
#man_show_urls = False
224+
# man_show_urls = False
230225

231226

232227
# -- Options for Texinfo output ------------------------------------------------
@@ -235,16 +230,22 @@
235230
# (source start file, target name, title, author,
236231
# dir menu entry, description, category)
237232
texinfo_documents = [
238-
('index', 'KryPy', 'KryPy Documentation',
239-
'André Gaul', 'KryPy', 'One line description of project.',
240-
'Miscellaneous'),
233+
(
234+
"index",
235+
"KryPy",
236+
"KryPy Documentation",
237+
"André Gaul",
238+
"KryPy",
239+
"One line description of project.",
240+
"Miscellaneous",
241+
),
241242
]
242243

243244
# Documents to append as an appendix to all manuals.
244-
#texinfo_appendices = []
245+
# texinfo_appendices = []
245246

246247
# If false, no module index is generated.
247-
#texinfo_domain_indices = True
248+
# texinfo_domain_indices = True
248249

249250
# How to display URL addresses: 'footnote', 'no', or 'inline'.
250-
#texinfo_show_urls = 'footnote'
251+
# texinfo_show_urls = 'footnote'

example.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
import numpy
2-
from krypy.linsys import LinearSystem, Gmres
3-
4-
linear_system = LinearSystem(A=numpy.diag([1e-3]+range(2, 101)),
5-
b=numpy.ones((100, 1)))
6-
sol = Gmres(linear_system)
72

3+
# use tex
84
# plot residuals
9-
from matplotlib import pyplot
5+
from matplotlib import pyplot, rc
106

11-
# use tex
12-
from matplotlib import rc
13-
rc('text', usetex=True)
7+
from krypy.linsys import Gmres, LinearSystem
148

159
# use beautiful style
1610
from mpltools import style
17-
style.use('ggplot')
11+
12+
linear_system = LinearSystem(
13+
A=numpy.diag([1e-3] + range(2, 101)), b=numpy.ones((100, 1))
14+
)
15+
sol = Gmres(linear_system)
16+
17+
18+
rc("text", usetex=True)
19+
20+
style.use("ggplot")
1821

1922
pyplot.figure(figsize=(6, 4), dpi=100)
20-
pyplot.xlabel('Iteration $i$')
21-
pyplot.ylabel(r'Relative residual norm $\frac{\|r_i\|}{\|b\|}$')
23+
pyplot.xlabel("Iteration $i$")
24+
pyplot.ylabel(r"Relative residual norm $\frac{\|r_i\|}{\|b\|}$")
2225
pyplot.semilogy(sol.resnorms)
2326

24-
pyplot.savefig('example.png', bbox_inches='tight')
27+
pyplot.savefig("example.png", bbox_inches="tight")

krypy/__init__.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
from . import linsys, deflation, recycling, utils
2-
from ._convenience import cg, minres, gmres
1+
from . import deflation, linsys, recycling, utils
32
from .__about__ import __version__
3+
from ._convenience import cg, gmres, minres
44

55
__all__ = [
6-
'linsys', 'deflation', 'recycling', 'utils', 'cg', 'minres', 'gmres', '__version__'
6+
"linsys",
7+
"deflation",
8+
"recycling",
9+
"utils",
10+
"cg",
11+
"minres",
12+
"gmres",
13+
"__version__",
714
]

0 commit comments

Comments
 (0)